mirror of https://github.com/apache/maven.git
[MNG-6533] Test: ProjectBuildingException miss reference to MavenProject
This commit is contained in:
parent
049b7a7ba8
commit
ae1c32aa09
|
@ -27,6 +27,7 @@ import java.util.Properties;
|
|||
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.building.FileModelSource;
|
||||
import org.apache.maven.model.building.ModelBuildingRequest;
|
||||
import org.apache.maven.model.building.ModelSource;
|
||||
import org.apache.maven.shared.utils.io.FileUtils;
|
||||
|
||||
|
@ -167,4 +168,44 @@ public class ProjectBuilderTest
|
|||
FileUtils.deleteDirectory( tempDir );
|
||||
}
|
||||
}
|
||||
|
||||
public void testReadErroneousMavenProjectContainsReference()
|
||||
throws Exception
|
||||
{
|
||||
File pomFile = new File( "src/test/resources/projects/artifactMissingVersion.xml" ).getAbsoluteFile();
|
||||
MavenSession mavenSession = createMavenSession( null );
|
||||
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
|
||||
configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
|
||||
configuration.setRepositorySession( mavenSession.getRepositorySession() );
|
||||
org.apache.maven.project.ProjectBuilder projectBuilder =
|
||||
lookup( org.apache.maven.project.ProjectBuilder.class );
|
||||
|
||||
// single project build entry point
|
||||
try
|
||||
{
|
||||
projectBuilder.build( pomFile, configuration );
|
||||
}
|
||||
catch ( ProjectBuildingException ex )
|
||||
{
|
||||
assertEquals( 1, ex.getResults().size() );
|
||||
MavenProject project = ex.getResults().get( 0 ).getProject();
|
||||
assertNotNull( project );
|
||||
assertEquals( "testArtifactMissingVersion", project.getArtifactId() );
|
||||
assertEquals( pomFile, project.getFile() );
|
||||
}
|
||||
|
||||
// multi projects build entry point
|
||||
try
|
||||
{
|
||||
projectBuilder.build( Collections.singletonList( pomFile ), false, configuration );
|
||||
}
|
||||
catch ( ProjectBuildingException ex )
|
||||
{
|
||||
assertEquals( 1, ex.getResults().size() );
|
||||
MavenProject project = ex.getResults().get( 0 ).getProject();
|
||||
assertNotNull( project );
|
||||
assertEquals( "testArtifactMissingVersion", project.getArtifactId() );
|
||||
assertEquals( pomFile, project.getFile() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<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>markerTest</groupId>
|
||||
<artifactId>testArtifactMissingVersion</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>missing</groupId>
|
||||
<artifactId>missing</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.4.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
Loading…
Reference in New Issue