Gradle

Your project should be able to produce binary distributions, a feat typically achieved by configuring the application plugin.

You also have to configure the jreleaser-gradle-plugin. We recommend using the Kordamp plugins as they provide additional benefits, however their use is optional. A sample project using Kordamp may look like this:

build.gradle
plugins {
    id 'java-library'
    id 'application'
    id 'org.kordamp.gradle.java-project' version '0.45.0'
    id 'org.jreleaser' version '0.9.1-SNAPSHOT'
}

application {
    mainClass = 'com.acme.Main'
}

config {
    info {
        name          = 'app'
        description   = 'App'
        inceptionYear = '2021'
        vendor        = 'Acme'

        links {
            website      = 'https://acme.com/app'
            issueTracker = 'https://github.com/duke/app/issues'
            scm          = 'https://github.com/duke/app.git'
        }

        scm {
            url                 = 'https://github.com/duke/app'
            connection          = 'scm:git:https://github.com/duke/app.git'
            developerConnection = 'scm:git:git@github.com:duke/app.git'
        }

        people {
            person {
                id    = 'duke'
                name  = 'Java Duke'
                roles = ['developer', 'author']
            }
        }
    }

    licensing {
        licenses {
            license {
                id = 'Apache-2.0'
            }
        }
    }
}

jreleaser {
    release {
        github {
            owner = 'duke'
            overwrite = true
        }
    }
    distributions {
        app {
           artifact {
               path = 'build/distributions/{{distributionName}}-{{projectVersion}}.zip'
           }
        }
    }
}

This setup configures the project with the following

  • Generate additional JAR manifest entries.

  • Generate a -sources JAR file with all sources per project.

  • Configure the javadoc task for each project using information found in the config block, such as author, copyright year, default settings.

  • Generate a -javadoc JAR file with the output of the javadoc task, per project.

  • Configure the license plugin with the license details

  • Configure the maven-publish plugin. The -sources and -javadoc JARs are automatically added to the default publication.

  • Configure the generated POM.

  • Configure the jacoco plugin.

  • Generate a source stats task.

  • Generate a task to collect pretty-printed sources.

Whereas a plain project would look like this:

build.gradle
plugins {
    id 'java-library'
    id 'application'
    id 'org.jreleaser' version '0.9.1-SNAPSHOT'
}

application {
    mainClass = 'com.acme.Main'
}

jreleaser {
    project {
        website = 'https://acme.com/app'
        authors = ['Duke']
        license = 'Apache-2.0'
        extraProperties.put('inceptionYear', '2021')
    }

    release {
        github {
            owner = 'duke'
            overwrite = true
        }
    }
    distributions {
        app {
           artifact {
               path = 'build/distributions/{{distributionName}}-{{projectVersion}}.zip'
           }
        }
    }
}

Edit the file to suite your needs. Once you have edited the file you may verify its configuration by invoking

$ gradle jreleaserConfig

At any time you may invoke any of the other commands, but when it’s time to make a release you have to invoke

$ gradle jreleaserFullRelease
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :minpom
> Task :jar
> Task :startScripts
> Task :distTar
> Task :distZip
> Task :assembleDist

> Task :jreleaserFullRelease
[INFO]  JReleaser 0.9.1-SNAPSHOT
[INFO]    - basedir set to /Home/duke/app
[INFO]  Loading properties from /Home/duke/.jreleaser/config.properties
[INFO]  Validating configuration
[INFO]  Project version set to 1.0.0
[INFO]  Release is not snapshot
[INFO]  Timestamp is 2021-03-28T12:25:16.219+02:00
[INFO]  HEAD is at c3e39f1
[INFO]  Platform is osx-x86_64
[INFO]  dryrun set to false
[INFO]  Generating changelog: out/jreleaser/release/CHANGELOG.md
[INFO]  Calculating checksums
[INFO]    [checksum] target/distributions/app/app-1.0.0.zip
[INFO]  Signing files
[INFO]  Signing is not enabled. Skipping
[INFO]  Uploading is not enabled. Skipping.
[INFO]  Releasing to https://github.com/duke/app
[INFO]   - Uploading app-1.0.0.zip
[INFO]   - Uploading checksums.txt
[INFO]  Preparing distributions
[INFO]    - Preparing app distribution
[INFO]  Packaging distributions
[INFO]    - Packaging app distribution
[INFO]  Publishing distributions
[INFO]    - Publishing app distribution
[INFO]  Announcing release
[INFO]  Announcing is not enabled. Skipping.
[INFO]  JReleaser succeeded after 0.894s
[INFO]  Writing output properties to out/jreleaser/output.properties

--------------------------------------------------------------------
1 projects                                       CONF        EXEC
--------------------------------------------------------------------
: .................................. SUCCESS [  0.287 s] [  2.182 s]
--------------------------------------------------------------------

This command performs the following actions:

  • checksums all artifacts.

  • signs all files (if signing is enabled).

  • creates a release at the chosen Git repository.

  • prepares, packages, and uploads configured packagers (brew, jbang, etc).

  • announces the release (if configured).