From 28695cf94e7852f4aa874fa954ed4cc13a57533d Mon Sep 17 00:00:00 2001 From: John Engelman Date: Fri, 27 Jun 2014 16:21:19 -0500 Subject: [PATCH] close #60, lazily evaluate args for runShadow task --- ChangeLog.md | 1 + .../plugins/shadow/ShadowApplicationPlugin.groovy | 4 +++- .../gradle/plugins/shadow/PublishingSpec.groovy | 12 ++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 05d081049..67cf71914 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ v1.0.1 + Fix issue where non-class files are dropped when using relocation ([Issue #58](https://github.com/johnrengelman/shadow/issues/58)) + Do not create a / directory inside the output jar. ++ Fix `runShadow` task to evaluate the `shadowJar.archiveFile` property at execution time. ([Issue #60](https://github.com/johnrengelman/shadow/issues/60)) v1.0.0 ====== diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.groovy index a24d809e9..71d1251a4 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.groovy +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.groovy @@ -57,8 +57,10 @@ class ShadowApplicationPlugin implements Plugin { run.description = 'Runs this project as a JVM application using the shadow jar' run.group = ApplicationPlugin.APPLICATION_GROUP run.main = '-jar' - run.args = [jar.archivePath] run.conventionMapping.jvmArgs = { pluginConvention.applicationDefaultJvmArgs } + run.doFirst { + args = [jar.archivePath.path] + args + } } private void addCreateScriptsTask(Project project) { diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy index d89167814..51eab4c3a 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy @@ -149,8 +149,8 @@ class PublishingSpec extends PluginSpecification { file('src/main/java/myapp/Main.java') << """ |package myapp; |public class Main { - | static void main(String[] args) { - | System.out.println("Hello World!"); + | public static void main(String[] args) { + | System.out.println("TestApp: Hello World! (" + args[0] + ")"); | } |} """.stripMargin() @@ -171,12 +171,17 @@ class PublishingSpec extends PluginSpecification { |dependencies { | compile 'shadow:a:1.0' |} + | + |runShadow { + | args 'foo' + |} """.stripMargin() settingsFile << "rootProject.name = 'myapp'" when: runner.arguments << 'installShadow' + runner.arguments << 'runShadow' ExecutionResult result = runner.run() then: @@ -200,5 +205,8 @@ class PublishingSpec extends PluginSpecification { and: assert startScript.text.contains("-jar \$APP_HOME/lib/myapp-1.0-all.jar") + + and: + assert result.standardOutput.contains('TestApp: Hello World! (foo)') } }