Shared Gradle convention plugins for NVA (Nasjonalt vitenarkiv) microservices. These precompiled script plugins replace copy-pasted build logic across NVA repositories.
Published to Maven Central as com.github.bibsysdev:nva-gradle-plugins.
- Java 21 (Amazon Corretto recommended)
- Gradle 9.x
Since the plugins are published as a library (not to the Gradle Plugin Portal), a resolutionStrategy is needed to map plugin IDs to the Maven artifact:
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id.startsWith('nva.')) {
useModule("com.github.bibsysdev:nva-gradle-plugins:${requested.version}")
}
}
}
}plugins {
id 'nva.root-module-conventions' version '1.0.1'
}plugins {
id 'nva.java-conventions' version '1.0.1'
}
repositories {
mavenCentral()
}If your repo has a build-logic module with its own precompiled script plugins, declare the dependency there instead of using versions in plugin blocks:
// build-logic/build.gradle
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
implementation 'com.github.bibsysdev:nva-gradle-plugins:1.0.1'
}// build-logic/src/main/groovy/myproject.java-conventions.gradle
plugins {
id 'nva.java-conventions' // no version — resolved from build-logic dependency
}| Plugin ID | Apply to | Description |
|---|---|---|
nva.configuration |
any | Creates the nva {} extension. Applied automatically by others. |
nva.java-conventions |
submodules | Java 21, Error Prone, PMD, JaCoCo, Spotless, Spectral, JUnit 5 |
nva.formatting-conventions |
any | Spotless: Google Java Format, Groovy Gradle, Markdown, YAML |
nva.root-module-conventions |
root project | Aggregated JaCoCo coverage, dependency updates |
All plugins read from the shared nva {} extension:
nva {
java {
languageVersion = 21 // Java toolchain version (default: 21)
}
spotless {
enabled = true // Apply formatting before build/test
enforced = true // Fail build if formatting needed
}
errorprone {
allErrorsAsWarnings = true // Treat Error Prone errors as warnings
}
pmd {
ignoreFailures = false // Allow PMD violations without failing
rulesetFile = rootProject.file('pmd.xml') // Custom PMD ruleset (default: bundled)
}
dependencyAnalysis {
enforced = false // Fail build on dependency analysis issues
}
spectral {
documents = ['docs/*.yaml'] // OpenAPI docs to lint (only active when set)
rulesetFile = file('.spectral.yaml') // Custom Spectral ruleset (default: bundled)
}
jacoco {
minMethodCoverage = 1.000 // Minimum method coverage ratio (0.0-1.0)
minClassCoverage = 1.000 // Minimum class coverage ratio (0.0-1.0)
}
}To configure across all submodules from the root build.gradle:
subprojects {
pluginManager.withPlugin('nva.java-conventions') {
nva {
pmd {
ignoreFailures = true
}
}
}
}./gradlew build # Build, test, and run all checks
./gradlew test # Run tests only
./gradlew publishToMavenLocal # Publish to local Maven for testingSee PUBLISHING.md for release instructions.