NOTE: You can open this sample inside an IDE using the https://www.jetbrains.com/help/idea/gradle.html#gradle_import_project_start[IntelliJ native importer] or https://projects.eclipse.org/projects/tools.buildship[Eclipse Buildship].

This sample shows how to publish a Java library to a repository.
The library has no dependencies and the build has minimal configuration.

====
include::sample[dir="groovy",files="build.gradle[]"]
include::sample[dir="kotlin",files="build.gradle.kts[]"]
====

To publish the library:

[listing.terminal.sample-command]
----
$ ./gradlew publish

BUILD SUCCESSFUL
5 actionable tasks: 5 executed
$ tree build/publishing-repository
build/publishing-repository
└── org
    └── gradle
        └── sample
            └── library-publishing
                ├── 1.0.2
                │   ├── library-publishing-1.0.2.jar
                │   ├── library-publishing-1.0.2.jar.md5
                │   ├── library-publishing-1.0.2.jar.sha1
                │   ├── library-publishing-1.0.2.jar.sha256
                │   ├── library-publishing-1.0.2.jar.sha512
                │   ├── library-publishing-1.0.2.module
                │   ├── library-publishing-1.0.2.module.md5
                │   ├── library-publishing-1.0.2.module.sha1
                │   ├── library-publishing-1.0.2.module.sha256
                │   ├── library-publishing-1.0.2.module.sha512
                │   ├── library-publishing-1.0.2.pom
                │   ├── library-publishing-1.0.2.pom.md5
                │   ├── library-publishing-1.0.2.pom.sha1
                │   ├── library-publishing-1.0.2.pom.sha256
                │   └── library-publishing-1.0.2.pom.sha512
                ├── maven-metadata.xml
                ├── maven-metadata.xml.md5
                ├── maven-metadata.xml.sha1
                ├── maven-metadata.xml.sha256
                └── maven-metadata.xml.sha512

5 directories, 20 files
----

For more information, see link:{userManualPath}/java_library_plugin.html[Java Library Plugin reference chapter].
