mirror of https://github.com/apache/maven.git
[MNG-6983] Plugin key can get out of sync with artifactId and groupId
The plugin key is build as combination of artifactId and groupId but not updated if either of these two ids change. This can be a problem if artifactId or groupId is a variable. The calculated key will likely contain the unresolved property and is not updated once the variable is interpolated. This closes #372
This commit is contained in:
parent
68e02c27e1
commit
3645593bfa
|
@ -34,6 +34,7 @@ import java.util.Properties;
|
|||
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
||||
import org.apache.maven.artifact.InvalidArtifactRTException;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.building.FileModelSource;
|
||||
import org.apache.maven.model.building.ModelBuildingRequest;
|
||||
import org.apache.maven.model.building.ModelSource;
|
||||
|
@ -328,4 +329,17 @@ public class ProjectBuilderTest
|
|||
assertEquals( 1, project.getMailingLists().size() );
|
||||
assertEquals( 1, project.getResources().size() );
|
||||
}
|
||||
|
||||
public void testPropertyInPluginManagementGroupId()
|
||||
throws Exception
|
||||
{
|
||||
File pom = getProject( "MNG-6983" );
|
||||
|
||||
MavenSession session = createMavenSession( pom );
|
||||
MavenProject project = session.getCurrentProject();
|
||||
|
||||
for (Plugin buildPlugin : project.getBuildPlugins()) {
|
||||
assertNotNull( "Missing version for build plugin " + buildPlugin.getKey(), buildPlugin.getVersion() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<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>org.example</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<codehaus.groupId>org.codehaus.mojo</codehaus.groupId>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>${codehaus.groupId}</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source-config</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>.</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
<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>
|
||||
|
||||
<parent>
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>./parent-pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>child</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>${codehaus.groupId}</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -2314,18 +2314,12 @@
|
|||
return id.toString();
|
||||
}
|
||||
|
||||
//TODO we shall reset key variable when groupId/artifactId change
|
||||
private String key = null;
|
||||
/**
|
||||
* @return the key of the plugin, ie <code>groupId:artifactId</code>
|
||||
*/
|
||||
public String getKey()
|
||||
{
|
||||
if ( key == null )
|
||||
{
|
||||
key = constructKey( groupId, artifactId );
|
||||
}
|
||||
return key;
|
||||
return constructKey( groupId, artifactId );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue