mirror of https://github.com/apache/maven.git
Ignore missing modules during extension-scanning when MavenEmbedder.readProject(..) is called. At other times, as in the case of normal builds, don't suppress missing module exceptions.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@629571 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
793020c798
commit
d54cf5b9bb
|
@ -266,7 +266,7 @@ public class DefaultMaven
|
||||||
// instances just-in-time.
|
// instances just-in-time.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
buildExtensionScanner.scanForBuildExtensions( files, request );
|
buildExtensionScanner.scanForBuildExtensions( files, request, false );
|
||||||
}
|
}
|
||||||
catch ( ExtensionScanningException e )
|
catch ( ExtensionScanningException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,11 +31,13 @@ public interface BuildExtensionScanner
|
||||||
String ROLE = BuildExtensionScanner.class.getName();
|
String ROLE = BuildExtensionScanner.class.getName();
|
||||||
|
|
||||||
void scanForBuildExtensions( List files,
|
void scanForBuildExtensions( List files,
|
||||||
MavenExecutionRequest request )
|
MavenExecutionRequest request,
|
||||||
|
boolean ignoreMissingModules )
|
||||||
throws ExtensionScanningException, MissingModuleException;
|
throws ExtensionScanningException, MissingModuleException;
|
||||||
|
|
||||||
void scanForBuildExtensions( File pom,
|
void scanForBuildExtensions( File pom,
|
||||||
MavenExecutionRequest request )
|
MavenExecutionRequest request,
|
||||||
|
boolean ignoreMissingModules )
|
||||||
throws ExtensionScanningException, MissingModuleException;
|
throws ExtensionScanningException, MissingModuleException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,8 @@ public class DefaultBuildExtensionScanner
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scanForBuildExtensions( List files,
|
public void scanForBuildExtensions( List files,
|
||||||
MavenExecutionRequest request )
|
MavenExecutionRequest request,
|
||||||
|
boolean ignoreMissingModules )
|
||||||
throws ExtensionScanningException, MissingModuleException
|
throws ExtensionScanningException, MissingModuleException
|
||||||
{
|
{
|
||||||
List visited = new ArrayList();
|
List visited = new ArrayList();
|
||||||
|
@ -102,25 +103,27 @@ public class DefaultBuildExtensionScanner
|
||||||
{
|
{
|
||||||
File pom = (File) it.next();
|
File pom = (File) it.next();
|
||||||
|
|
||||||
scanInternal( pom, request, visited, internalFiles );
|
scanInternal( pom, request, visited, internalFiles, ignoreMissingModules );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scanForBuildExtensions( File pom,
|
public void scanForBuildExtensions( File pom,
|
||||||
MavenExecutionRequest request )
|
MavenExecutionRequest request,
|
||||||
|
boolean ignoreMissingModules )
|
||||||
throws ExtensionScanningException, MissingModuleException
|
throws ExtensionScanningException, MissingModuleException
|
||||||
{
|
{
|
||||||
List internalFiles = new ArrayList();
|
List internalFiles = new ArrayList();
|
||||||
|
|
||||||
internalFiles.add( pom );
|
internalFiles.add( pom );
|
||||||
|
|
||||||
scanInternal( pom, request, new ArrayList(), internalFiles );
|
scanInternal( pom, request, new ArrayList(), internalFiles, ignoreMissingModules );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanInternal( File pom,
|
private void scanInternal( File pom,
|
||||||
MavenExecutionRequest request,
|
MavenExecutionRequest request,
|
||||||
List visitedModelIds,
|
List visitedModelIds,
|
||||||
List reactorFiles )
|
List reactorFiles,
|
||||||
|
boolean ignoreMissingModules )
|
||||||
throws ExtensionScanningException, MissingModuleException
|
throws ExtensionScanningException, MissingModuleException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -195,7 +198,8 @@ public class DefaultBuildExtensionScanner
|
||||||
request,
|
request,
|
||||||
originalRemoteRepositories,
|
originalRemoteRepositories,
|
||||||
visitedModelIds,
|
visitedModelIds,
|
||||||
reactorFiles );
|
reactorFiles,
|
||||||
|
ignoreMissingModules );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +255,8 @@ public class DefaultBuildExtensionScanner
|
||||||
MavenExecutionRequest request,
|
MavenExecutionRequest request,
|
||||||
List originalRemoteRepositories,
|
List originalRemoteRepositories,
|
||||||
List visitedModelIds,
|
List visitedModelIds,
|
||||||
List reactorFiles )
|
List reactorFiles,
|
||||||
|
boolean ignoreMissingModules )
|
||||||
throws ExtensionScanningException, MissingModuleException
|
throws ExtensionScanningException, MissingModuleException
|
||||||
{
|
{
|
||||||
// FIXME: This gets a little sticky, because modules can be added by profiles that require
|
// FIXME: This gets a little sticky, because modules can be added by profiles that require
|
||||||
|
@ -309,13 +314,20 @@ public class DefaultBuildExtensionScanner
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !modulePomDirectory.exists() )
|
if ( !modulePomDirectory.exists() )
|
||||||
|
{
|
||||||
|
if ( ignoreMissingModules )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
throw new MissingModuleException( moduleSubpath, modulePomDirectory, containingPom );
|
throw new MissingModuleException( moduleSubpath, modulePomDirectory, containingPom );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reactorFiles.add( modulePomDirectory );
|
reactorFiles.add( modulePomDirectory );
|
||||||
|
|
||||||
scanInternal( modulePomDirectory, request, visitedModelIds, reactorFiles );
|
scanInternal( modulePomDirectory, request, visitedModelIds, reactorFiles, ignoreMissingModules );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,8 @@ public class DefaultBuildExtensionScannerTest
|
||||||
new DefaultBuildExtensionScanner( extensionManager, projectBuilder, modelLineageBuilder,
|
new DefaultBuildExtensionScanner( extensionManager, projectBuilder, modelLineageBuilder,
|
||||||
modelInterpolator, new ConsoleLogger( Logger.LEVEL_DEBUG,
|
modelInterpolator, new ConsoleLogger( Logger.LEVEL_DEBUG,
|
||||||
"test" ) ).scanForBuildExtensions( pomFile,
|
"test" ) ).scanForBuildExtensions( pomFile,
|
||||||
request );
|
request,
|
||||||
|
false );
|
||||||
|
|
||||||
mockManager.verifyAll();
|
mockManager.verifyAll();
|
||||||
}
|
}
|
||||||
|
@ -213,7 +214,8 @@ public class DefaultBuildExtensionScannerTest
|
||||||
new DefaultBuildExtensionScanner( extensionManager, projectBuilder, modelLineageBuilder,
|
new DefaultBuildExtensionScanner( extensionManager, projectBuilder, modelLineageBuilder,
|
||||||
modelInterpolator, new ConsoleLogger( Logger.LEVEL_DEBUG,
|
modelInterpolator, new ConsoleLogger( Logger.LEVEL_DEBUG,
|
||||||
"test" ) ).scanForBuildExtensions( pomFile,
|
"test" ) ).scanForBuildExtensions( pomFile,
|
||||||
request );
|
request,
|
||||||
|
false );
|
||||||
|
|
||||||
mockManager.verifyAll();
|
mockManager.verifyAll();
|
||||||
}
|
}
|
||||||
|
@ -324,7 +326,8 @@ public class DefaultBuildExtensionScannerTest
|
||||||
new DefaultBuildExtensionScanner( extensionManager, projectBuilder, modelLineageBuilder,
|
new DefaultBuildExtensionScanner( extensionManager, projectBuilder, modelLineageBuilder,
|
||||||
modelInterpolator, new ConsoleLogger( Logger.LEVEL_DEBUG,
|
modelInterpolator, new ConsoleLogger( Logger.LEVEL_DEBUG,
|
||||||
"test" ) ).scanForBuildExtensions( pomFile,
|
"test" ) ).scanForBuildExtensions( pomFile,
|
||||||
request );
|
request,
|
||||||
|
false );
|
||||||
|
|
||||||
mockManager.verifyAll();
|
mockManager.verifyAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,7 @@ public class MavenEmbedder
|
||||||
{
|
{
|
||||||
getLogger().debug( "Scanning for extensions: " + mavenProject );
|
getLogger().debug( "Scanning for extensions: " + mavenProject );
|
||||||
|
|
||||||
extensionScanner.scanForBuildExtensions( mavenProject, request );
|
extensionScanner.scanForBuildExtensions( mavenProject, request, true );
|
||||||
|
|
||||||
getLogger().debug( "Building MavenProject instance: " + mavenProject );
|
getLogger().debug( "Building MavenProject instance: " + mavenProject );
|
||||||
|
|
||||||
|
|
|
@ -338,6 +338,15 @@ public class MavenEmbedderTest
|
||||||
assertEquals( "scm:svn:https://host/trunk/parent/modules/child1", project.getScm().getDeveloperConnection() );
|
assertEquals( "scm:svn:https://host/trunk/parent/modules/child1", project.getScm().getDeveloperConnection() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testProjectReading_SkipMissingModuleSilently()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File pomFile = new File( basedir,
|
||||||
|
"src/test/projects/readProject-missingModuleIgnored/pom.xml" );
|
||||||
|
|
||||||
|
maven.readProject( pomFile );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void testProjectReadingWithDistributionStatus()
|
public void testProjectReadingWithDistributionStatus()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>missing.module</groupId>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>child1</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
</project>
|
Loading…
Reference in New Issue