Closed Sami32 closed 6 years ago
Configured properties on the execution do not automatically make it into project.properties, you want to use the properties
object instead:
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<properties>
<changelogAsVariable>${project.basedir}/releasenotes.md</changelogAsVariable>
</properties>
<source>
def file = new File(properties.changelogAsVariable) // <--- use properties object not project.properties
project.properties.release_description = file.getText('UTF-8')
</source>
</configuration>
</execution>
Thanks a lot, that worked :)
Did you plan to fix it?
Its not broken so nothing to fix ;-) . per-execution properties should not (and are not meant to) mutate the entire project's properties.
Btw you could just:
<source>
def file = new File(basedir, 'releasenotes.md')
project.properties.release_description = file.getText('UTF-8')
</source>
... and avoid using the
Also FYI the properties object is a combined view of project.properties, custom properties and overrides.
Hehe nice, thank you very much for the advice and knowledge sharing 😄
I admit that this configuration come from the older gmaven-plugin 1.5 ;)
Or i misunderstood you or it doesn't work: ( Unrecognised tag: 'source')
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<source>
def file = new File(basedir, 'releasenotes.md')
project.properties.release_description = file.getText('UTF-8')
</source>
</execution>
</executions>
</plugin>
yes, sorry, you still need <configuration>
, when I said configuration I mean using the <configuration><properties>
element to pass in configuration as a property to the script that is executing, and then dereferencing the property and constructing a file from the string. You can instead just construct the file in the script.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
def file = new File(basedir, 'releasenotes.md')
project.properties.release_description = file.getText('UTF-8')
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
While try to use the following configuration Maven throw me a NPE. I probably did a configuration mistake but
NullPointerException
shouldn't have appeared IMHO.