From a6aba5b45858d502b39184d7afb166c9955d0de2 Mon Sep 17 00:00:00 2001 From: Paul Fridrick Date: Thu, 15 Oct 2020 16:11:53 +0200 Subject: [PATCH] Fix archive baseName Signed-off-by: Paul Fridrick --- ...DepthUserGuideSamplesIntegrationTest.groovy | 4 ++-- .../MiscUserGuideIntegrationTest.groovy | 4 ++-- ...stributionApplicationIntegrationTest.groovy | 18 +++++++++--------- ...stributionAdvancedAppIntegrationTest.groovy | 6 +++--- .../DistributionZipIntegrationTest.groovy | 2 +- .../plugins/PlayDistributionPlugin.java | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/docTest/groovy/org/gradle/playframework/InDepthUserGuideSamplesIntegrationTest.groovy b/src/docTest/groovy/org/gradle/playframework/InDepthUserGuideSamplesIntegrationTest.groovy index a6442026..47ec3907 100644 --- a/src/docTest/groovy/org/gradle/playframework/InDepthUserGuideSamplesIntegrationTest.groovy +++ b/src/docTest/groovy/org/gradle/playframework/InDepthUserGuideSamplesIntegrationTest.groovy @@ -42,7 +42,7 @@ abstract class InDepthUserGuideSamplesIntegrationTest extends Specification { } List distributionArchives(File sampleDir) { - [new ZipTestFixture(new File(sampleDir, "build/distributions/main.zip")), - new TarTestFixture(new File(sampleDir, "build/distributions/main.tar"))] + [new ZipTestFixture(new File(sampleDir, "build/distributions/custom-distribution.zip")), + new TarTestFixture(new File(sampleDir, "build/distributions/custom-distribution.tar"))] } } diff --git a/src/docTest/groovy/org/gradle/playframework/MiscUserGuideIntegrationTest.groovy b/src/docTest/groovy/org/gradle/playframework/MiscUserGuideIntegrationTest.groovy index eca34208..23fd8064 100644 --- a/src/docTest/groovy/org/gradle/playframework/MiscUserGuideIntegrationTest.groovy +++ b/src/docTest/groovy/org/gradle/playframework/MiscUserGuideIntegrationTest.groovy @@ -73,8 +73,8 @@ class MiscUserGuideIntegrationTest extends InDepthUserGuideSamplesIntegrationTes then: distributionArchives(sample.dir)*.containsDescendants( - "main/README.md", - "main/bin/runPlayBinaryAsUser.sh" + "custom-distribution/README.md", + "custom-distribution/bin/runPlayBinaryAsUser.sh" ) where: diff --git a/src/integTest/groovy/org/gradle/playframework/application/PlayDistributionApplicationIntegrationTest.groovy b/src/integTest/groovy/org/gradle/playframework/application/PlayDistributionApplicationIntegrationTest.groovy index cb2babd1..a26f897c 100644 --- a/src/integTest/groovy/org/gradle/playframework/application/PlayDistributionApplicationIntegrationTest.groovy +++ b/src/integTest/groovy/org/gradle/playframework/application/PlayDistributionApplicationIntegrationTest.groovy @@ -51,20 +51,20 @@ abstract class PlayDistributionApplicationIntegrationTest extends PlayMultiVersi } List archives() { - [ zip("build/distributions/main.zip"), tar("build/distributions/main.tar") ] + [ zip("build/distributions/${playApp.name}.zip"), tar("build/distributions/${playApp.name}.tar") ] } void verifyArchives() { archives()*.containsDescendants( - "main/lib/${playApp.name}.jar", - "main/lib/${playApp.name}-assets.jar", - "main/bin/main", - "main/bin/main.bat", - "main/conf/application.conf", - "main/README") + "${playApp.name}/lib/${playApp.name}.jar", + "${playApp.name}/lib/${playApp.name}-assets.jar", + "${playApp.name}/bin/main", + "${playApp.name}/bin/main.bat", + "${playApp.name}/conf/application.conf", + "${playApp.name}/README") } void verifyStagedFiles() { - File stageMainDir = file("build/stage/main") + File stageMainDir = file("build/stage/${playApp.name}") [ "lib/${playApp.name}.jar", "lib/${playApp.name}-assets.jar", @@ -89,7 +89,7 @@ abstract class PlayDistributionApplicationIntegrationTest extends PlayMultiVersi // Verify that the Class-Path attribute contains the correct runtime classpath def classpath = mainJar.manifest.mainAttributes.getValue("Class-Path") def classpathAsFilenames = Arrays.asList(classpath.split(" ")) - def dependencies = file("build/stage/main/lib/").listFiles().collect { it.name } - [ mainJar.file.name ] + def dependencies = file("build/stage/${playApp.name}/lib/").listFiles().collect { it.name } - [ mainJar.file.name ] assert dependencies.size() == classpathAsFilenames.size() assert classpathAsFilenames.containsAll(dependencies) } diff --git a/src/integTest/groovy/org/gradle/playframework/application/advanced/PlayDistributionAdvancedAppIntegrationTest.groovy b/src/integTest/groovy/org/gradle/playframework/application/advanced/PlayDistributionAdvancedAppIntegrationTest.groovy index b8913c99..d97a559f 100644 --- a/src/integTest/groovy/org/gradle/playframework/application/advanced/PlayDistributionAdvancedAppIntegrationTest.groovy +++ b/src/integTest/groovy/org/gradle/playframework/application/advanced/PlayDistributionAdvancedAppIntegrationTest.groovy @@ -20,15 +20,15 @@ class PlayDistributionAdvancedAppIntegrationTest extends PlayDistributionApplica super.verifyArchives() archives()*.containsDescendants( - "main/conf/jva.routes", - "main/conf/scala.routes") + "${playApp.name}/conf/jva.routes", + "${playApp.name}/conf/scala.routes") } @Override void verifyStagedFiles() { super.verifyStagedFiles() - File stageMainDir = file("build/stage/main") + File stageMainDir = file("build/stage/${playApp.name}") [ "conf/jva.routes", "conf/scala.routes" diff --git a/src/integTest/groovy/org/gradle/playframework/tasks/DistributionZipIntegrationTest.groovy b/src/integTest/groovy/org/gradle/playframework/tasks/DistributionZipIntegrationTest.groovy index 277420d9..28b9a66a 100644 --- a/src/integTest/groovy/org/gradle/playframework/tasks/DistributionZipIntegrationTest.groovy +++ b/src/integTest/groovy/org/gradle/playframework/tasks/DistributionZipIntegrationTest.groovy @@ -32,6 +32,6 @@ class DistributionZipIntegrationTest extends AbstractIntegrationTest { build "dist" then: - zip("build/distributions/main.zip").containsDescendants("main/additionalFile.txt") + zip("build/distributions/dist-play-app.zip").containsDescendants("dist-play-app/additionalFile.txt") } } diff --git a/src/main/java/org/gradle/playframework/plugins/PlayDistributionPlugin.java b/src/main/java/org/gradle/playframework/plugins/PlayDistributionPlugin.java index 1f063590..a9ac99d1 100644 --- a/src/main/java/org/gradle/playframework/plugins/PlayDistributionPlugin.java +++ b/src/main/java/org/gradle/playframework/plugins/PlayDistributionPlugin.java @@ -187,11 +187,11 @@ private Provider getBaseNameForDistribution(ProviderFactory providers, D @Override public String call() throws Exception { String baseName = (String) Distribution.class.getMethod("getBaseName").invoke(distribution); - return "".equals(baseName) ? "" : distribution.getName(); + return baseName != null && !baseName.isEmpty() ? baseName : distribution.getName(); } }); } else { - return distribution.getDistributionBaseName().map(baseName -> baseName.isEmpty() ? "" : distribution.getName()).orElse(distribution.getName()); + return distribution.getDistributionBaseName().map(baseName -> !baseName.isEmpty() ? baseName : distribution.getName()).orElse(distribution.getName()); } } @@ -238,7 +238,7 @@ public void execute(FileCopyDetails fileCopyDetails) { public String apply(File input) { calculateRenames(); String rename = renames.get(input); - if (rename!=null) { + if (rename != null) { return rename; } return input.getName();