- Visual Studio Code Gradle Extension
- Visual Studio Code Build Task
- Java Gradle Visual Studio Code
- Vscode Gradle Build
- Visual Studio C# Examples
How-To – Use Gradle inside Visual Studio Code to build your Kotlin/Native applications (on a Mac) von Martin Majewski. In macOS Programming. In my last How-To – Build and run a Kotlin/Native application with Visual Studio Code on macOS I showed you how to setup, build, and run your first Kotlin/Native application using the barebone Kotlin/Native compiler inside Visual Studio Code. Have you tried opening the android folder separately in Visual Studio code or Android Studio? What's the content of your app/build.gradle file? It's complaining about line 24. – iRuth May 11 '19 at 20:09. Visual Studio Plugin behavior; Plugin Description; None. Generates minimal solution file. C Application. Adds a project representing the C application to the solution file. Adds a project for each specified linkage representing the shared and/or static library to the solution file.
Although we can use IDE for creating new java projects, if we use a build tool like gradle and create the project from ground up then not only we have more control, we can also change between IDEs as we feel the need.
Create new application
Create new java-application type Java project using gradle -
Please note: The Build Init plugin is currently incubating. Please be aware that the DSL and other configuration may change in later Gradle versions. To know more about gradle supported java projects read Gradle Build Init plugin documentation.
This command create a gradle.build file with the contents

Gradle tasks
To check all tasks of the project run -
You will see list of tasks available for the project and short description about what the task is about. If you want to run any of the task then just run

where <task name> is the task from the previous command. For example If you run -
then the distribution(compressed executable) file will be found in buld>distributions folder. There is tar and zip archive. You can extract and use either of them.
You can create new custom tasks or add plugin that have prebuilt task that you can use.
Code Coverage metric

Code coverage is one of the most important metric for any project. From Wikipedia -
In computer science, test coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs. A program with high test coverage, measured as a percentage, has had more of its source code executed during testing which suggests it has a lower chance of containing undetected software bugs compared to a program with low test coverage.
We are going to use JaCoCo1 for test coverage. At first we need to add JaCoCo as dependencies -
Now if we run -
we will see that there is two new task available under Verification tasks
Visual Studio Code Gradle Extension
now we can create code coverage report by running -
Visual Studio Code Build Task

but I want to create code coverage report when I run gradle test command which run all tests for the project. To do so edit your gradle.build file -
Now run gradle build or gradle test to generate the Code Coverage Report. The Code Coverage Report can be found in build>reports>jacoco>test>html. Open the index.html file here to view the Coverage Report
Java Gradle Visual Studio Code
Please Note: We can use JaCoCo to generate Code Coverage Report for Continuous Code Quality tools like SonarQube2. I will discuss about it in future articles.
Vscode Gradle Build
References:
Visual Studio C# Examples
JaCoCo is a free code coverage library for Java, which has been created by the EclEmma team based on the lessons learned from using and integration existing libraries for many years. ↩
SonarQube -
SonarQubeis an open source platform for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells and security vulnerabilities on 20+ Programming languages. SonarQube offers reports on duplicated code, coding standards, unit tests, code coverage, code complexity, comments, bugs, and security vulnerabilities. SonarQube can record metrics history and provides evolution graphs. SonarQube’s greatest asset is that it provides fully automated analysis and integration with Maven, Ant, Gradle, MSBuild and continuous integration tools. SonarQube also integrates with Eclipse, Visual Studio and IntelliJ IDEA development environments through the SonarLint plugins and integrates with external tools like LDAP, Active Directory, GitHub, etc. ↩
