mirror of https://github.com/apache/maven.git
[MNG-7648] Fix locationTracking in DefaultModelBuildingRequest copy constructor (#940)
- Fix locationTracking in DefaultModelBuildingRequest copy constructor - Add location tracking unit test
This commit is contained in:
parent
8150c62749
commit
6178f6ed86
|
@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.InputLocation;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.building.FileModelSource;
|
||||
import org.apache.maven.model.building.ModelBuildingRequest;
|
||||
|
@ -321,7 +323,7 @@ public class ProjectBuilderTest extends AbstractCoreMavenComponentTestCase {
|
|||
MavenProject project = session.getCurrentProject();
|
||||
|
||||
for (Plugin buildPlugin : project.getBuildPlugins()) {
|
||||
assertNotNull("Missing version for build plugin " + buildPlugin.getKey(), buildPlugin.getVersion());
|
||||
assertNotNull(buildPlugin.getVersion(), "Missing version for build plugin " + buildPlugin.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,4 +349,32 @@ public class ProjectBuilderTest extends AbstractCoreMavenComponentTestCase {
|
|||
}
|
||||
assertEquals(0, errors);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocationTrackingResolution() throws Exception {
|
||||
File pom = getProject("MNG-7648");
|
||||
|
||||
MavenSession session = createMavenSession(pom);
|
||||
MavenProject project = session.getCurrentProject();
|
||||
|
||||
InputLocation dependencyLocation = null;
|
||||
for (Dependency dependency : project.getDependencies()) {
|
||||
if (dependency.getManagementKey().equals("org.apache.maven.its:a:jar")) {
|
||||
dependencyLocation = dependency.getLocation("version");
|
||||
}
|
||||
}
|
||||
assertNotNull(dependencyLocation, "missing dependency");
|
||||
assertEquals(
|
||||
"org.apache.maven.its:bom:0.1", dependencyLocation.getSource().getModelId());
|
||||
|
||||
InputLocation pluginLocation = null;
|
||||
for (Plugin plugin : project.getBuildPlugins()) {
|
||||
if (plugin.getKey().equals("org.apache.maven.plugins:maven-clean-plugin")) {
|
||||
pluginLocation = plugin.getLocation("version");
|
||||
}
|
||||
}
|
||||
assertNotNull(pluginLocation, "missing build plugin");
|
||||
assertEquals(
|
||||
"org.apache.maven.its:parent:0.1", pluginLocation.getSource().getModelId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<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.apache.maven.its</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>0.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>location-tracking</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>remote-repo</id>
|
||||
<url>file://${basedir}/../../src/test/remote-repo</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>bom</artifactId>
|
||||
<version>0.1</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<!-- version from BOM -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<!-- version from parent -->
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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.apache.maven.its</groupId>
|
||||
<artifactId>bom</artifactId>
|
||||
<version>0.1</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Maven Integration Test :: Dummy BOM</name>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<version>0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>bom</artifactId>
|
||||
<version>0.1</version>
|
||||
<versioning>
|
||||
<versions>
|
||||
<version>0.1</version>
|
||||
</versions>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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.apache.maven.its</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>0.1</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Maven Integration Test :: Dummy Parent</name>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>0.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>0.1</version>
|
||||
<versioning>
|
||||
<versions>
|
||||
<version>0.1</version>
|
||||
</versions>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -87,6 +87,7 @@ public class DefaultModelBuildingRequest implements ModelBuildingRequest {
|
|||
setValidationLevel(request.getValidationLevel());
|
||||
setProcessPlugins(request.isProcessPlugins());
|
||||
setTwoPhaseBuilding(request.isTwoPhaseBuilding());
|
||||
setLocationTracking(request.isLocationTracking());
|
||||
setProfiles(request.getProfiles());
|
||||
setActiveProfileIds(request.getActiveProfileIds());
|
||||
setInactiveProfileIds(request.getInactiveProfileIds());
|
||||
|
|
Loading…
Reference in New Issue