This project hosts convention plugins for Gradle projects at Opencast.
Using convention plugins enables us to reuse build configuration across our JVM open source projects.
There is only one convention plugin at present:
com.opencastsoftware.gradle.java-conventions
- this plugin declares shared Gradle build configuration for Java projects.
Our gradle-convention-plugins are published for Java 11 and above.
Gradle (build.gradle):
plugins {
id 'com.opencastsoftware.gradle.java-conventions' version '0.2.0'
}
Gradle Kotlin DSL (build.gradle.kts):
plugins {
id("com.opencastsoftware.gradle.java-conventions") version "0.2.0"
}
In practice, we typically use Gradle version catalogs to declare our plugin dependencies.
Version Catalog (gradle/libs.versions.toml):
[versions]
gradleJavaConventions = "0.2.0"
[plugins]
gradleJavaConventions = { id = "com.opencastsoftware.gradle.java-conventions", version.ref = "gradleJavaConventions" }
Gradle (build.gradle.kts):
plugins {
alias(libs.plugins.gradleJavaConventions)
}
After declaring a dependency on this plugin, git versioning, Kotlin DSL formatting, license headers and Maven Central publishing will be configured for your Gradle project.
It's necessary to fill in certain properties in your project's build script:
repositories
- we don't configure this by default in the Java conventions plugin as you may have more complex needs. A good default isrepositories { mavenCentral() }
.group
- we don't configure this by default in the Java conventions plugin as you may wish to publish to a nested namespace. A good default iscom.opencastsoftware
.description
- you need to provide your own description for your project!java.toolchain.languageVersion
- this controls the Java toolchain version that will be used to build your project. The minimum version supported by this plugin is Java 11, but you may wish to use a newer JDK.mavenPublishing
properties - there are a lot of properties of the Maven POM file that are project-specific, such as developers, project-specific URLs, inception year etc.- the
options.release
version for Java compile tasks. You can compile your code for older versions Java VM if required. See the javac documentation and JEP 247: Compile for Older Platform Versions.
Please see the prettier4j project's build script for examples of all of the properties above.
All code in this repository is licensed under the Apache License, Version 2.0. See LICENSE.