gradle Initializing Gradle Initializing a New Java Library


Prerequisite: Installing Gradle

Once you have Gradle installed, you can setup a new or existing project by running

gradle init --type=java-library

Note that there are other project types like Scala you can get started with, but we'll use Java for this example.

You will end up with:

├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └──
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
    ├── main
    │   └── java
    │       └──
    └── test
        └── java

You can now run gradle tasks and see that you can build a jar, run tests, produce javadocs and much more even though your build.gradle file is:

apply plugin: 'java'

repositories {

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.21'
    testCompile 'junit:junit:4.12'