Skip to content

Commit

Permalink
'Fix mojohaus#5 groupId' not always pulling from parent pom
Browse files Browse the repository at this point in the history
'groupId' not always pulling from parent pom

'Fix mojohaus#5 groupId' not always pulling from parent pom - test case
  • Loading branch information
tomerc committed Jul 17, 2015
1 parent 59eb7a6 commit 47f3943
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/codehaus/mojo/versions/SetMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void execute()
{
found = true;
// if the change is not one we have swept up already
applyChange( project, reactor, files, m.getGroupId(), m.getArtifactId(),
applyChange( project, reactor, files, mGroupId, m.getArtifactId(),
StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : m.getVersion() );
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.codehaus.mojo.versions.api;

import junit.framework.TestCase;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
import org.codehaus.stax2.XMLInputFactory2;

import javax.xml.stream.XMLInputFactory;
import java.io.File;
import java.io.StringReader;
import java.net.URL;

/**
Expand Down Expand Up @@ -42,6 +45,17 @@ public void testLongProperties()
assertNotSame( oldVersion, newVersion );
}

public void testGroupIdNotOnChildPom()
throws Exception
{
URL url = getClass().getResource( "PomHelperTest.noGroupIdOnChild.pom.xml" );
StringBuilder input = PomHelper.readXmlFile( new File( url.getPath() ) );
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = reader.read(new StringReader(input.toString()));

assertEquals("org.myorg", PomHelper.getGroupId(model));
}

public void test_Version_Version_Equal()
throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<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>
<parent>
<groupId>org.myorg</groupId>
<artifactId>myorg-parent</artifactId>
<version>3.0-SNAPSHOT</version>
</parent>
<artifactId>it-set-004</artifactId>
<packaging>jar</packaging>
<version>${V1234567890123456789012}</version>
<name>set version for pom with no dependencies</name>
</project>

0 comments on commit 47f3943

Please sign in to comment.