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.

A straight forward project configuration could look like this:

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

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

jreleaser {
    project {
        authors = ['Duke']
        license = 'Apache-2.0'
        links {
            homepage = 'https://acme.com/app'
        }
        inceptionYear = '2021'
    }

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

You could also use the Kordamp plugins to setup the project 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.47.0'
    id 'org.jreleaser' version '1.2.0'
}

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.

Which ever option you choose to get started, make sure to 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 :jar
> Task :startScripts
> Task :distTar
> Task :distZip
> Task :assembleDist

> Task :jreleaserFullRelease
[INFO]  JReleaser 1.2.0
[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]    [sign] 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]  Writing output properties to out/jreleaser/output.properties
[INFO]  JReleaser succeeded after 0.894s

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).

Next Steps