Skip to content

Commit 310534c

Browse files
Merge pull request #88 from mojohaus/issue/81
#81 IllegalArgumentException when using goal released-version with maven 3.6.2/3.6.3
2 parents 82bbcb1 + ccbfb61 commit 310534c

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
invoker.goals = test
2+
invoker.buildResult = success

src/it/released-version/pom.xml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<groupId>org.codehaus.mojo</groupId>
5+
<artifactId>build-helper-maven-plugin-released-version-it</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>build-helper-maven-plugin-released-version-it</name>
8+
9+
<build>
10+
<defaultGoal>package</defaultGoal>
11+
<plugins>
12+
<plugin>
13+
<groupId>@project.groupId@</groupId>
14+
<artifactId>@project.artifactId@</artifactId>
15+
<version>@project.version@</version>
16+
<executions>
17+
<execution>
18+
<id>released-version</id>
19+
<goals>
20+
<goal>released-version</goal>
21+
</goals>
22+
<configuration>
23+
<propertyPrefix>myReleasedVersion</propertyPrefix>
24+
</configuration>
25+
</execution>
26+
</executions>
27+
</plugin>
28+
<plugin>
29+
<artifactId>maven-antrun-plugin</artifactId>
30+
<executions>
31+
<execution>
32+
<id>mk-target-dir</id>
33+
<phase>compile</phase>
34+
<goals>
35+
<goal>run</goal>
36+
</goals>
37+
<configuration>
38+
<tasks>
39+
<mkdir dir="${project.build.directory}" />
40+
</tasks>
41+
</configuration>
42+
</execution>
43+
44+
<execution>
45+
<id>echo-released-version</id>
46+
<phase>test</phase>
47+
<goals>
48+
<goal>run</goal>
49+
</goals>
50+
<configuration>
51+
<tasks>
52+
<echo>myReleasedVersion.version=${myReleasedVersion.version}</echo>
53+
<echo>myReleasedVersion.majorVersion=${myReleasedVersion.majorVersion}</echo>
54+
<echo>myReleasedVersion.minorVersion=${myReleasedVersion.minorVersion}</echo>
55+
<echo>myReleasedVersion.incrementalVersion=${myReleasedVersion.incrementalVersion}</echo>
56+
</tasks>
57+
</configuration>
58+
</execution>
59+
</executions>
60+
</plugin>
61+
</plugins>
62+
</build>
63+
64+
</project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
File file = new File( basedir, "build.log" );
2+
assert file.exists();
3+
4+
String text = file.getText("utf-8");
5+
6+
// 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
7+
assert text.contains("No released version found.")
8+
9+
return true;

src/main/java/org/codehaus/mojo/buildhelper/ReleasedVersionMojo.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private void defineVersionProperty( String name, int value )
9292
public void execute()
9393
{
9494
org.apache.maven.artifact.Artifact artifact =
95-
artifactFactory.createArtifact( getProject().getGroupId(), getProject().getArtifactId(), "", "", "" );
95+
artifactFactory.createArtifact( getProject().getGroupId(), getProject().getArtifactId(), getProject().getVersion(), "", "" );
9696
try
9797
{
9898
ArtifactVersion releasedVersion = null;
@@ -127,6 +127,9 @@ public void execute()
127127
defineVersionProperty( "buildNumber", releasedVersion.getBuildNumber() );
128128
defineVersionProperty( "qualifier", releasedVersion.getQualifier() );
129129
}
130+
else {
131+
getLog().debug("No released version found.");
132+
}
130133

131134
}
132135
catch ( ArtifactMetadataRetrievalException e )

0 commit comments

Comments
 (0)