Skip to content

Commit

Permalink
Merge pull request #88 from mojohaus/issue/81
Browse files Browse the repository at this point in the history
#81 IllegalArgumentException when using goal released-version with maven 3.6.2/3.6.3
  • Loading branch information
stefanseifert committed Feb 18, 2020
2 parents 82bbcb1 + ccbfb61 commit 310534c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/it/released-version/invoker.properties
@@ -0,0 +1,2 @@
invoker.goals = test
invoker.buildResult = success
64 changes: 64 additions & 0 deletions src/it/released-version/pom.xml
@@ -0,0 +1,64 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin-released-version-it</artifactId>
<version>1.0-SNAPSHOT</version>
<name>build-helper-maven-plugin-released-version-it</name>

<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>released-version</id>
<goals>
<goal>released-version</goal>
</goals>
<configuration>
<propertyPrefix>myReleasedVersion</propertyPrefix>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>mk-target-dir</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}" />
</tasks>
</configuration>
</execution>

<execution>
<id>echo-released-version</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>myReleasedVersion.version=${myReleasedVersion.version}</echo>
<echo>myReleasedVersion.majorVersion=${myReleasedVersion.majorVersion}</echo>
<echo>myReleasedVersion.minorVersion=${myReleasedVersion.minorVersion}</echo>
<echo>myReleasedVersion.incrementalVersion=${myReleasedVersion.incrementalVersion}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
9 changes: 9 additions & 0 deletions src/it/released-version/verify.groovy
@@ -0,0 +1,9 @@
File file = new File( basedir, "build.log" );
assert file.exists();

String text = file.getText("utf-8");

// its difficult to check the positove case with an existing released version in an IT - so currently we test only the case when no version is detected
assert text.contains("No released version found.")

return true;
Expand Up @@ -92,7 +92,7 @@ private void defineVersionProperty( String name, int value )
public void execute()
{
org.apache.maven.artifact.Artifact artifact =
artifactFactory.createArtifact( getProject().getGroupId(), getProject().getArtifactId(), "", "", "" );
artifactFactory.createArtifact( getProject().getGroupId(), getProject().getArtifactId(), getProject().getVersion(), "", "" );
try
{
ArtifactVersion releasedVersion = null;
Expand Down Expand Up @@ -127,6 +127,9 @@ public void execute()
defineVersionProperty( "buildNumber", releasedVersion.getBuildNumber() );
defineVersionProperty( "qualifier", releasedVersion.getQualifier() );
}
else {
getLog().debug("No released version found.");
}

}
catch ( ArtifactMetadataRetrievalException e )
Expand Down

0 comments on commit 310534c

Please sign in to comment.