Index
- Setup
- Create a simple application
- Create an application with root project
- Adding internal dependencies
- Publishing on maven repository
- Using "external" projects
- Using Spring boot
- Adding Junit and JaCoCo
- Profiles
Source code on github: https://github.com/kendarorg/Gradle101
000-Create a simple application
Preparation
-
Create directory "demo000" and enter it
-
Run 'gradle init' and select the following to setup a simple stub application with unit tests
- Type "1: base"
- Script DSL "1: Groovy"
- Project name, leave it blank (default)
- Source package set it to "org.demo"

Since now a file called "gradlew.bat" is created. You don't need to have gradle on the PATH variable anymore. This is a wrapper to the project-local gradle!
"The Gradle wrapper makes sure your build is always run with the same Gradle version, no matter who executes the build and where or that Gradle is installed or not, as long as the one uses the Gradle wrapper to build the project. This means you can design your build for that Gradle version and be sure that the build will not fail, just because someone is using a different version of Gradle and thus is also an important step in build reproducibility."
(from stackoverflow )
-
We can then build the project running "gradle build"

-
Now we can see several commands to analyze the project
- gradle projects: List the projects structure
- gradle tasks: Show all the available tasks


File structure
- gradlew.bat: A wrapper for gradle, in windows is gradlew.bat, on linux is gradlew.sh
- settings.gradle: Settings for the gradle build
- build.gradle: The tasks definition for the build
- gradle: (directory) Contains a stand-alone gradle to be used by gradlew
- src: (directory) Contains the sources for the project