o restoring assembly descriptor so that I can actually build from within this module

o all the use of an embedder request with no settings file information and have the defaults just kick in



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@491334 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2006-12-30 22:21:18 +00:00
parent 646c67db17
commit df12fcab5d
3 changed files with 154 additions and 115 deletions

View File

@ -27,7 +27,7 @@
<artifactId>maven-embedder</artifactId>
<name>Maven Embedder</name>
<properties>
<bundleVersion>2.1.0.v20061129-1142</bundleVersion>
<bundleVersion>2.1.0.v20061230-1718</bundleVersion>
</properties>
<build>
<resources>

View File

@ -14,7 +14,6 @@
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<outputFileNameMapping></outputFileNameMapping>
<unpack>true</unpack>
<scope>runtime</scope>
<excludes>

View File

@ -155,6 +155,7 @@ public class MavenEmbedder
/**
* This option determines whether the embedder is to be aligned to the user
* installation.
*
* @deprecated not used
*/
private boolean alignWithUserInstallation;
@ -165,65 +166,49 @@ public class MavenEmbedder
// Accessors
// ----------------------------------------------------------------------
/**
* @deprecated not used.
*/
/** @deprecated not used. */
public void setInteractiveMode( boolean interactiveMode )
{
this.interactiveMode = interactiveMode;
}
/**
* @deprecated not used.
*/
/** @deprecated not used. */
public boolean isInteractiveMode()
{
return interactiveMode;
}
/**
* @deprecated not used.
*/
/** @deprecated not used. */
public void setOffline( boolean offline )
{
this.offline = offline;
}
/**
* @deprecated not used.
*/
/** @deprecated not used. */
public boolean isOffline()
{
return offline;
}
/**
* @deprecated not used.
*/
/** @deprecated not used. */
public void setGlobalChecksumPolicy( String globalChecksumPolicy )
{
this.globalChecksumPolicy = globalChecksumPolicy;
}
/**
* @deprecated not used.
*/
/** @deprecated not used. */
public String getGlobalChecksumPolicy()
{
return globalChecksumPolicy;
}
/**
* @deprecated not used.
*/
/** @deprecated not used. */
public boolean isAlignWithUserInstallation()
{
return alignWithUserInstallation;
}
/**
* @deprecated not used
*/
/** @deprecated not used */
public void setAlignWithUserInstallation( boolean alignWithUserInstallation )
{
this.alignWithUserInstallation = alignWithUserInstallation;
@ -254,9 +239,7 @@ public class MavenEmbedder
return classWorld;
}
/**
* @deprecated not used.
*/
/** @deprecated not used. */
public void setLocalRepositoryDirectory( File localRepositoryDirectory )
{
this.localRepositoryDirectory = localRepositoryDirectory;
@ -308,7 +291,8 @@ public class MavenEmbedder
* write the model.
* requires a start()-ed embedder.
*/
public void writeModel( Writer writer, Model model )
public void writeModel( Writer writer,
Model model )
throws IOException
{
checkStarted();
@ -330,11 +314,13 @@ public class MavenEmbedder
return mavenProjectBuilder.build( mavenProject, localRepository, profileManager );
}
public MavenProject readProjectWithDependencies( File mavenProject, TransferListener transferListener )
public MavenProject readProjectWithDependencies( File mavenProject,
TransferListener transferListener )
throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException
{
checkStarted();
return mavenProjectBuilder.buildWithDependencies( mavenProject, localRepository, profileManager, transferListener );
return mavenProjectBuilder.buildWithDependencies( mavenProject, localRepository, profileManager,
transferListener );
}
public MavenProject readProjectWithDependencies( File mavenProject )
@ -386,7 +372,9 @@ public class MavenEmbedder
return new DefaultMavenExecutionResult( project, Collections.EMPTY_LIST );
}
public List collectProjects( File basedir, String[] includes, String[] excludes )
public List collectProjects( File basedir,
String[] includes,
String[] excludes )
throws MojoExecutionException
{
checkStarted();
@ -418,19 +406,29 @@ public class MavenEmbedder
// Artifacts
// ----------------------------------------------------------------------
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type )
public Artifact createArtifact( String groupId,
String artifactId,
String version,
String scope,
String type )
{
checkStarted();
return artifactFactory.createArtifact( groupId, artifactId, version, scope, type );
}
public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier )
public Artifact createArtifactWithClassifier( String groupId,
String artifactId,
String version,
String type,
String classifier )
{
checkStarted();
return artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
}
public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
public void resolve( Artifact artifact,
List remoteRepositories,
ArtifactRepository localRepository )
throws ArtifactResolutionException, ArtifactNotFoundException
{
checkStarted();
@ -459,7 +457,8 @@ public class MavenEmbedder
try
{
InputStream is = classLoader.getResourceAsStream( "/plugins/" + summaryPluginDescriptor.getArtifactId() + ".xml" );
InputStream is =
classLoader.getResourceAsStream( "/plugins/" + summaryPluginDescriptor.getArtifactId() + ".xml" );
pluginDescriptor = pluginDescriptorBuilder.build( new InputStreamReader( is ) );
}
@ -471,7 +470,9 @@ public class MavenEmbedder
return pluginDescriptor;
}
private SummaryPluginDescriptor makeMockPlugin( String groupId, String artifactId, String name )
private SummaryPluginDescriptor makeMockPlugin( String groupId,
String artifactId,
String name )
{
return new SummaryPluginDescriptor( groupId, artifactId, name );
}
@ -494,7 +495,8 @@ public class MavenEmbedder
PlexusConfiguration configuration = descriptor.getConfiguration();
PlexusConfiguration[] phasesConfigurations = configuration.getChild( "lifecycles" ).getChild( 0 ).getChild( "phases" ).getChildren( "phase" );
PlexusConfiguration[] phasesConfigurations =
configuration.getChild( "lifecycles" ).getChild( 0 ).getChild( "phases" ).getChildren( "phase" );
try
{
@ -534,7 +536,8 @@ public class MavenEmbedder
return createLocalRepository( mavenTools.getLocalRepositoryPath( settings ), DEFAULT_LOCAL_REPO_ID );
}
public ArtifactRepository createLocalRepository( String url, String repositoryId )
public ArtifactRepository createLocalRepository( String url,
String repositoryId )
{
if ( !url.startsWith( "file:" ) )
{
@ -544,7 +547,8 @@ public class MavenEmbedder
return createRepository( url, repositoryId );
}
public ArtifactRepository createRepository( String url, String repositoryId )
public ArtifactRepository createRepository( String url,
String repositoryId )
{
checkStarted();
// snapshots vs releases
@ -556,18 +560,23 @@ public class MavenEmbedder
String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag );
ArtifactRepositoryPolicy snapshotsPolicy =
new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag );
ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag );
ArtifactRepositoryPolicy releasesPolicy =
new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag );
return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout,
snapshotsPolicy, releasesPolicy );
}
// ----------------------------------------------------------------------
// Internal utility code
// ----------------------------------------------------------------------
private List getPomFiles( File basedir, String[] includes, String[] excludes )
private List getPomFiles( File basedir,
String[] includes,
String[] excludes )
{
DirectoryScanner scanner = new DirectoryScanner();
@ -603,7 +612,6 @@ public class MavenEmbedder
public void start( MavenEmbedRequest req )
throws MavenEmbedderException
{
// ----------------------------------------------------------------------
// Set the maven.home system property which is need by components like
// the plugin registry builder.
@ -611,7 +619,8 @@ public class MavenEmbedder
if ( classWorld == null && classLoader == null )
{
throw new IllegalStateException( "A classWorld or classloader must be specified using setClassLoader|World(ClassLoader)." );
throw new IllegalStateException(
"A classWorld or classloader must be specified using setClassLoader|World(ClassLoader)." );
}
try
@ -679,24 +688,39 @@ public class MavenEmbedder
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
defaultArtifactRepositoryLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, DEFAULT_LAYOUT_ID );
defaultArtifactRepositoryLayout =
(ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, DEFAULT_LAYOUT_ID );
lifecycleExecutor = (LifecycleExecutor) container.lookup( LifecycleExecutor.ROLE );
wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
settings = mavenTools.buildSettings( req.getUserSettingsFile(),
req.getGlobalSettingsFile(),
null );
started = true;
profileManager.loadSettingsProfiles( settings );
// ----------------------------------------------------------------------------
// Settings
//
// If the settings file and the global settings file are null then we will use
// the defaults that Maven provides.
// ----------------------------------------------------------------------------
if ( req.getUserSettingsFile() == null )
{
req.setUserSettingsFile( mavenTools.getUserSettingsPath( null ) );
}
if ( req.getGlobalSettingsFile() == null )
{
req.setGlobalSettingsFile( mavenTools.getGlobalSettingsPath() );
}
settings = mavenTools.buildSettings( req.getUserSettingsFile(), req.getGlobalSettingsFile(), null );
resolveParameters( settings );
started = true;
localRepository = createLocalRepository( settings );
profileManager.loadSettingsProfiles( settings );
}
catch ( DuplicateRealmException e )
{
@ -762,8 +786,6 @@ public class MavenEmbedder
}
}
// ----------------------------------------------------------------------
// Lifecycle
// ----------------------------------------------------------------------
@ -806,25 +828,40 @@ public class MavenEmbedder
throws SettingsConfigurationException
{
checkStarted();
return mavenTools.buildSettings( userSettingsPath,
globalSettingsPath,
interactive,
offline,
usePluginRegistry,
return mavenTools.buildSettings( userSettingsPath, globalSettingsPath, interactive, offline, usePluginRegistry,
pluginUpdateOverride );
}
public Settings buildSettings( File userSettingsPath,
File globalSettingsPath,
boolean interactive,
boolean offline,
boolean usePluginRegistry,
boolean pluginUpdateOverride )
throws SettingsConfigurationException
{
checkStarted();
return mavenTools.buildSettings( userSettingsPath, globalSettingsPath, interactive, offline, usePluginRegistry,
Boolean.valueOf( pluginUpdateOverride ) );
}
public Settings buildSettings( File userSettingsPath,
File globalSettingsPath,
Boolean pluginUpdateOverride )
throws SettingsConfigurationException
{
checkStarted();
return mavenTools.buildSettings( userSettingsPath,
globalSettingsPath,
pluginUpdateOverride );
return mavenTools.buildSettings( userSettingsPath, globalSettingsPath, pluginUpdateOverride );
}
public Settings buildSettings( File userSettingsPath,
File globalSettingsPath,
boolean pluginUpdateOverride )
throws SettingsConfigurationException
{
checkStarted();
return mavenTools.buildSettings( userSettingsPath, globalSettingsPath, Boolean.valueOf( pluginUpdateOverride ) );
}
public File getUserSettingsPath( String optionalSettingsPath )
{
@ -844,9 +881,12 @@ public class MavenEmbedder
return mavenTools.getLocalRepositoryPath( settings );
}
private void checkStarted() {
if (!started) {
throw new IllegalStateException("The embedder is not started, you need to call start() on the embedder prior to calling this method");
private void checkStarted()
{
if ( !started )
{
throw new IllegalStateException(
"The embedder is not started, you need to call start() on the embedder prior to calling this method" );
}
}
}