0

Please note: Although I mention the ShadowJar plugin in this question, it is just for providing full context. I am confident any Gradle Guru can answer this, regardless of their knowledge level of ShadowJar.

Currently my Groovy project is built with the following Gradle build invocation:

gradle clean build shadowJar

Running this invocation produces a packaged fat jar under build/libs with the version property specified in my gradle.properties file. For instance, if gradle.properties has a version=1.2.3, then the above invocation produces build/libs/myapp-1.2.3.jar.

What it doesn't produce, however, is a valid POM for my app. And so I found this answer and modified it a bit to produce:

task createPom << {
    pom {
        project {
            groupId ${group}
            artifactId 'myapp'
            version ${version}
        }
    }.writeTo("build/libs/pom.xml")
}

My thinking is that group and version (both specified in gradle.properties) would be "injected", and that this should produce a pom.xml in the same directory as my fat jar.

After adding the createPom task, I run:

gradle clean build shadowJar createPom

And I get this error:

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\workspace\blah\myapp\build.gradle' line: 89

* What went wrong:
Execution failed for task ':createPom'.
> No signature of method: java.lang.Object.$() is applicable for argument types: (java.util.Collections$EmptyMap, null) values: [[:], null]
Possible solutions: any(), is(java.lang.Object), wait(), find(), dump(), grep()

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 11.673 secs

What is going on here?

Community
  • 1
  • 1
smeeb
  • 27,777
  • 57
  • 250
  • 447

1 Answers1

1

The lines:

groupId ${group}
artifactId 'myapp'
version ${version}

Are not valid groovy, and should probably be:

groupId "${group}"
artifactId 'myapp'
version "${version}"
randers
  • 5,031
  • 5
  • 37
  • 64
tim_yates
  • 167,322
  • 27
  • 342
  • 338