Open
Description
Is your feature request related to a problem? Please describe.
The Java Plugin try to modify the project properties on-the-fly as the following example.
@Mojo(
name = "hello",
defaultPhase = LifecyclePhase.NONE,
requiresDependencyResolution = ResolutionScope.NONE,
threadSafe = true
)
public class HelloMojo extends AbstractMojo {
@Parameter(
defaultValue = "${project}",
required = true,
readonly = true
)
protected MavenProject project;
@Override
public void execute() throws MojoExecutionException,
MojoFailureException {
this.project.getProperties().setProperty("my-key", "my-value");
}
}
During executing integration test, the MavenExecutionResult
only collect the properties statically defined in the testing pom.xml
.
In this case it only prints project.build.sourceEncoding:UTF-8
@MavenJupiterExtension
class HelloMojoIT {
@MavenTest
void simpleHello(final MavenExecutionResult project) {
MavenITAssertions.
assertThat(project).
isSuccessful();
/*
* This only print the propertied defined at the testing pom.xml.
*
* The properties appended by the Java Plugin are not here.
*/
project.getMavenProjectResult().
getModel().
getProperties().
entrySet().
forEach(
e -> System.out.println(e.getKey() + ":" + e.getValue())
);
}
}
Describe the solution you'd like
It would be great if the ITF is able to collect the project properties modified by the Java Plugin to the result.
Describe alternatives you've considered
At the moment, I use the gmavenplus-plugin to print out those modified by java plugin project properties and use the assertion to compare string from the stdout
.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my-group</groupId>
<artifactId>simple-hello-project</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>The simple hello plugin</name>
<description>The build should be successful.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>my-group</groupId>
<artifactId>my-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>hello</id>
<phase>initialize</phase>
<goals>
<goal>hello</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!--
https://groovy.github.io/GMavenPlus/
https://github.com/groovy/GMavenPlus
https://groovy-lang.org/
https://github.com/apache/groovy
-->
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<id>print-share-secret</id>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script><![CDATA[
def myValue = '${my-key}'
println('[INFO] The value is: ' + myValue)
]]></script>
</scripts>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.12</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-ant</artifactId>
<version>4.0.12</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
MavenITAssertions.
assertThat(project).
isSuccessful().
out().
info().
isNotEmpty().
contains(
...
);
Additional context
N/A