From 7d1dd6f6ea3a7e6a97cf031b9b113b08f0877bcf Mon Sep 17 00:00:00 2001 From: Tobias Schulte Date: Thu, 31 Aug 2017 17:12:39 +0200 Subject: [PATCH] fix(jardiff): make jardiff incremental When building a -SNAPSHOT version and changing the source version for the jardiff, the old jardiff files were also packed in the war file, making it necessary to do a clean. Changing the source version of a jardiff does not require a clean build anymore. Closes #49 --- .../gradle/jnlp/war/JarDiffTask.groovy | 1 + .../GradleJnlpWarPluginIntegrationSpec.groovy | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/gradle-jnlp-plugin/src/main/groovy/de/gliderpilot/gradle/jnlp/war/JarDiffTask.groovy b/gradle-jnlp-plugin/src/main/groovy/de/gliderpilot/gradle/jnlp/war/JarDiffTask.groovy index d0e1b3d..c0d86cb 100644 --- a/gradle-jnlp-plugin/src/main/groovy/de/gliderpilot/gradle/jnlp/war/JarDiffTask.groovy +++ b/gradle-jnlp-plugin/src/main/groovy/de/gliderpilot/gradle/jnlp/war/JarDiffTask.groovy @@ -52,6 +52,7 @@ class JarDiffTask extends DefaultTask { @TaskAction void createJardiffs() { + project.delete(into.listFiles()) def toMap = { [file: it, baseName: it.name - ~/__V.*$/, version: it.name.replaceAll(/.*?__V(.*?)\.jar.*/, '$1')] } diff --git a/gradle-jnlp-plugin/src/test/groovy/de/gliderpilot/gradle/jnlp/war/GradleJnlpWarPluginIntegrationSpec.groovy b/gradle-jnlp-plugin/src/test/groovy/de/gliderpilot/gradle/jnlp/war/GradleJnlpWarPluginIntegrationSpec.groovy index fcd6e50..05232be 100644 --- a/gradle-jnlp-plugin/src/test/groovy/de/gliderpilot/gradle/jnlp/war/GradleJnlpWarPluginIntegrationSpec.groovy +++ b/gradle-jnlp-plugin/src/test/groovy/de/gliderpilot/gradle/jnlp/war/GradleJnlpWarPluginIntegrationSpec.groovy @@ -506,4 +506,55 @@ class GradleJnlpWarPluginIntegrationSpec extends AbstractJnlpIntegrationSpec { gv << gradleVersions } + @Unroll + def '[gradle #gv] incremental jardiff build works'() { + given: + gradleVersion = gv + + when: + runTasksSuccessfully('build', 'publish') + + version = '1.1' + runTasksSuccessfully('build', 'publish') + + version = '1.2' + warBuildFile.text = '''\ + jnlpWar { + versions { + "1.0" "$rootProject.group:$rootProject.name:1.0:webstart@zip" + } + launchers { + "1.2" { + jardiff { + from "1.0" + } + } + } + } + ''' + runTasksSuccessfully("build") + warBuildFile.text = '''\ + jnlpWar { + versions { + "1.1" "$rootProject.group:$rootProject.name:1.1:webstart@zip" + } + launchers { + "1.2" { + jardiff { + from "1.1" + } + } + } + } + ''' + runTasksSuccessfully("build") + + then: + !fileExists("war/build/tmp/warContent/lib/${moduleName}__V1.0-myalias__V1.2-myalias.diff.jar.pack.gz") + fileExists("war/build/tmp/warContent/lib/${moduleName}__V1.1-myalias__V1.2-myalias.diff.jar.pack.gz") + + where: + gv << gradleVersions + } + }