The Aurora Gradle Plugin is a plugin that will apply a sensible base line for JVM applications developed by the Norwegian Tax Authority. The base line will make sure that the application will comply with most of the requirements set forth by the Aurora team for applications that are to be deployed to the Aurora OpenShift Platform.
When applying the plugin to a project it will modify the build by reacting to added plugins to make sure they are according to the established standard, but it is possible to opt out of every change the plugin makes with a high degree of granularity. So, although the Aurora team encourages every project to be build in pretty much the same way, and to some extent requires that static analysis is performed on the source code, it is possible to skip individual steps if the need arises.
To get an overview of how applying the Aurora plugin will affect your project, see the Features section.
Put the following snippet in your ~/.gradle/init.gradle
file
allprojects {
ext.repos= {
mavenCentral()
jcenter()
}
repositories repos
buildscript {
repositories repos
}
}
settingsEvaluated { settings ->
settings.pluginManagement {
repositories {
maven {
url 'http://aurora/nexus/content/repositories/gradle-plugins/'
}
gradlePluginPortal()
maven { url "http://aurora/nexus/content/groups/public" }
}
}
}
If you are not developing inhouse, remove the maven repositores that start with aurora/nexus. You also have to change the distributionUrl property in gradle-wrapper.properties to a public repo in order to use the gradlew command. ../gradle/wrapper/gradle-wrapper.properties
<...>
distributionUrl=https\://services.gradle.org/distributions/gradle-<version>-bin.zip
<...>
Make sure that settings.gradle
contains
rootProject.name = artifactId
Put the following snippet in your gradle.properties
file
version=local-SNAPSHOT
groupId=no.skatteetaten.<you>.<groupId>
artifactId= <your name>
If you want to configure this plugin you can do so in the gradle.properties
file
aurora.applyCheckstylePlugin=false
For a complete reference of options look at the bottom of this file.
A complete example build.gradle.kts
file can look like this
plugins {
id("org.jetbrains.kotlin.jvm") version "1.3.41"
id("org.jetbrains.kotlin.plugin.spring") version "1.3.41"
id("org.springframework.boot") version "2.1.7.RELEASE"
id("org.jlleitschuh.gradle.ktlint") version "8.2.0"
id("com.github.ben-manes.versions") version "0.22.0"
id("com.gorylenko.gradle-git-properties") version "2.0.0"
id("org.sonarqube") version "2.7.1"
id("org.asciidoctor.convert") version "2.3.0"
id("no.skatteetaten.gradle.aurora") version "2.3.0"
}
dependencies {
implementation("io.fabric8:openshift-client:4.1.2")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.fabric8:openshift-server-mock:4.1.2")
testImplementation("io.mockk:mockk:1.8.9")
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.13")
testImplementation("com.fkorotkov:kubernetes-dsl:2.0.1")
testImplementation("com.nhaarman:mockito-kotlin:1.6.0")
testImplementation("com.squareup.okhttp3:mockwebserver:3.12.0")
}
The following plugins will be reacted upon by this Aurora Plugin
- spring-cloud-contract
- info.solidsoft.pitest
- org.asciidoctor.convert
- com.github.ben-manves.versions
- org.springframework.boot
- org.jetbrains.kotlin.jvm
- org.jetbrains.kotlin.plugin.spring
Since this plugin is intended for use by JVM based applications, and since the NTA heavily relies on Nexus for artifact
dependency management and artifact distribution, both the java and maven plugin will be applied automatically. The
sourceCompatibility
will be set to 1.8 by default. This can be changed with setting the
aurora.javaSourceCompatibility
property.
If you set the properties repositoryUsername
, repositoryPassword
, repositoryReleaseUrl
and repositorySnapshotUrl
in your ~/gradle/.gradle.properties
-file the plugin will register Maven deployer for both snapshots and releases.
These features can be opted out of with the following config;
aurora.applyNexusRepositories=false
aurora.applyMavenDeployer=false
aurora.applyDefaultPlugins=false
aurora.applyJavaDefaults=false
The project will be set up to build the application into a format compatible with the Delivery Bundle (Leveransepakke) format by applying the following configuration;
This will make sure that the application will be packaged in a zip file with all its dependencies and that this zip file will get the classifier Leveransepakke. Note that the default is to not generate a start script as this script, by default, will be generated when a Docker image is produced for the Delivery Bundle. If you require a custom script you will need to provide it itself, or configure the application plugin to generate it for you.
You can disable this with;
aurora.applyDeliveryBundleConfig: false
defaultTasks will be set to clean install
if this property has not already been set.
Testing with Junit5 is enabled by default, in order to turn off this feature specify
aurora.junit5Support=false
The plugin supports the Spock Framework can be turned on and configured with the following parameters:
aurora.applySpockSupport=true
aurora.groovyVersion : '2.5.7',
aurora.spockVersion : '1.3-groovy-2.5',
aurora.cglibVersion : '3.2.12',
aurora.objenesisVersion : '3.0.1',
The Aurora plugin will react to the Asciidoc plugin
The jar task is modified to include the generated documentation into static/docs and also registers an attribute snippetsDir for integration with Spring Rest Docs.
The Aurora plugin will by default activate several plugins for source code analysis and test coverage. They can all to some extent be changed or disabled by configuration.
Checkstyle
Checkstyle will be activated and configured to use the standard Aurora Checkstyle configuration. Errors from Checkstyle will by default not fail the build. The plugin can be configured with the following options;
aurora.applyCheckstylePlugin : true, // Should the Checkstyle plugin be activated
aurora.checkstyleConfigVersion: "2.1.7", // The version of the Aurora Checkstyle config. Default 2.1.6.
aurora.checkstyleConfigFile : 'checkstyle/checkstyle-with-metrics.xml' // The Aurora Checkstyle config file to use.
Other Checkstyle-parameters can be configured according to the Checkstyle Plugin User Guide). I.e.
checkstyle {
ignoreFailures = false
showViolations = false
}
Jacoco
By default the jacoco plugin will be activated. Default value for xml.destination = file("${buildDir}/reports/jacoco/report.xml"). It can be disabled with;
aurora.applyJacocoTestReport=false
PiTest
If the pitest plugin is applied it will produce reports in both HTML and XML
The plugin will react to Spring plugin and modify it to produce DeliveryBundles the way we want it it. It will also add
the auroraSpringBootStarter as a dependency using the version specified in aurora.auroraSpringBootStarterVersion
.
Support for JSR310 to get dateTimes properly is also added
If aurora.springDevTools
is set devtools will be included in the genererated app. This instruction should be set globally
in your ~/.gradle/gradle.properties
file and be turned of in ci server.
The Aurora plugin will react to Kotlin plugin and add dependencies on kotlin-reflect, stdlib-jdk8 and add
kotlinLogging (wrapper for Logback) with the version of aurora.kotlinLoggingVersion
. Kotln will be configured to target
java8, add Xjsr305=strict
and supress warnings
The Aurora plugin will react to spring.kotlin plugin and the jackson Kotlin module
The Aurora plugin will react to spring cloud contract plugin and add dependencies from the bom as well as configure the correct packet with base class and test framework.
It will also create a proper stubs jar file with the contracts in the. The dependencies added are wiremock and verifyer
This plugin is configured to ignore snapshots, releases, miletones aso. The report will be generated in json.
All configuration options and their default values are listed below;
aurora.applyDefaultPlugins = true,
aurora.applyJavaDefaults = true,
aurora.javaSourceCompatibility = "1.8",
aurora.applyDeliveryBundleConfig = true,
aurora.applySpockSupport = false,
aurora.groovyVersion = '2.5.7',
aurora.spockVersion = '1.3-groovy-2.5',
aurora.cglibVersion = '3.2.12',
aurora.objenesisVersion = '3.0.1',
aurora.applyCheckstylePlugin = true,
aurora.checkstyleConfigVersion = "2.1.7",
aurora.checkstyleConfigFile = 'checkstyle/checkstyle-with-metrics.xml',
aurora.applyJacocoTestReport = true,
aurora.applyMavenDeployer = true,
aurora.springCloudContractVersion : "2.1.3.RELEASE",
aurora.auroraSpringBootStarterVersion= "2.3.0",
aurora.kotlinLoggingVersion = "1.7.6",
aurora.applyJunit5Support = true