You can open this sample inside an IDE using the IntelliJ native importer or Eclipse Buildship.

If you are new to Gradle and wish to follow a more detailed tutorial for building Java libraries, we suggest you have an look at the Building Java Libraries guide.

This sample shows how a Java library can be built with Gradle. The library has no dependencies and the build has minimal configuration.

build.gradle
plugins {
    id 'java-library'
}

version = '1.0.2'
group = 'org.gradle.sample'
build.gradle.kts
plugins {
    `java-library`
}

version = "1.0.2"
group = "org.gradle.sample"

To build the library:

$ ./gradlew jar

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 executed

For more information, see Java Library Plugin reference chapter.

You can also generate this project locally using gradle init.