diff --git a/build.gradle b/build.gradle index d6e1654df47506e1c9f731eb01d0dfd9711a4daf..19ed517caf8af21def3bcf8277e0ac49c79e95cd 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ * Then build the JAR file: ./gradlew assemble * * One can then specify the model to run in the services: - * java -jar build/libs/nshmp-haz-v2-all.jar -model=<MODEL> + * java -jar build/libs/nshmp-haz-v2.jar -model=<MODEL> * * Where <MODEL> is one of the model enums in nshmp.www.Model */ @@ -121,10 +121,6 @@ jacocoTestReport { } check.dependsOn jacocoTestReport -shadowJar { - mergeServiceFiles() -} - tasks.withType(JavaCompile) { options.encoding = "UTF-8" options.compilerArgs.add("-parameters") diff --git a/gradle/jar.gradle b/gradle/jar.gradle index 12b7c181549e8a96ac5d8c880c4d6c40add1da9a..be5167f454a5f783b5b1f544814b43d1d118ecb1 100644 --- a/gradle/jar.gradle +++ b/gradle/jar.gradle @@ -1,28 +1,17 @@ +apply plugin: "com.github.johnrengelman.shadow" + /* - * The default jar task automatically builds a fat jar and adds - * a properties file with the application version. Note that - * 'git describe' only works when running gradle from the command + * Possibly record app version. The creation of this file + * on each build causes the classpath to appear changed so + * Gradle reruns tests, even though no code has changed. + * + * Note that 'git describe' only works when running gradle from the command * line so version values in eclipse builds will empty. Use thinJar * task to skip dependencies. */ -jar { +tasks.register("propertyFile") { + description = "Create a property file with application version" doFirst { - /* possible fat jar */ - if (rootProject.name == projectName && !thinJar) { - from { - configurations.compileClasspath.collect { - it.isDirectory() ? it : zipTree(it).matching { - exclude { it.path.contains('META-INF') } - } - } - } - } - - /* - * Possibly record app version. The creation of this file - * on each build causes the classpath to appear changed so - * Gradle reruns tests, even though no code has changed. - */ def props = new Properties() def propsFile = new File(project.buildDir.toString() + propsPath) if (propsFile.exists()) { @@ -36,3 +25,22 @@ jar { } } } + +/* + * Build a thin jar and add a properties file with the application version. + */ +jar { + archiveBaseName = "${projectName}-thin" + dependsOn propertyFile +} + +/* + * Build a fat jar to be used for running programs and Micronaut services. + */ +shadowJar { + dependsOn propertyFile + baseName = projectName + classifier = '' + archiveVersion = '' + mergeServiceFiles() +} diff --git a/gradle/tasks.gradle b/gradle/tasks.gradle index 24480005ac0d7d6c1f1a4755feeadaafcf405d71..5375745fcc94badeb800e85748a1da883fd964f8 100644 --- a/gradle/tasks.gradle +++ b/gradle/tasks.gradle @@ -1,11 +1,4 @@ -task thinJar(type: Jar) { - doFirst { - thinJar = true - } - with jar -} - /* * Create a zip file of all dependencies */