update to new container

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-04-19 09:00:48 +00:00
parent 32c12bd7c2
commit d377256c93
4 changed files with 30 additions and 28 deletions

View File

@ -16,7 +16,7 @@
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-container-artifact</artifactId>
<version>1.0-alpha-2</version>
<version>1.0-alpha-3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>

View File

@ -24,6 +24,7 @@ import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
import org.codehaus.plexus.component.discovery.AbstractComponentDiscoverer;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import java.io.Reader;
import java.util.ArrayList;
@ -51,7 +52,7 @@ public class MavenPluginDiscoverer
}
public ComponentSetDescriptor createComponentDescriptors( Reader componentDescriptorConfiguration, String source )
throws Exception
throws PlexusConfigurationException
{
PluginDescriptor pluginDescriptor;
@ -59,10 +60,10 @@ public class MavenPluginDiscoverer
{
pluginDescriptor = builder.build( componentDescriptorConfiguration );
}
catch ( Exception e )
catch ( PlexusConfigurationException e )
{
// If the plugin is not valid, we cannot continue as it may make the lifecycle ebhave differently than expected
throw new Exception( "Cannot process plugin descriptor: " + source, e );
// If the plugin is not valid, we cannot continue as it may make the lifecycle ebhave differently than expected
throw new PlexusConfigurationException( "Cannot process plugin descriptor: " + source, e );
}
// ----------------------------------------------------------------------

View File

@ -45,6 +45,7 @@ import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@ -125,9 +126,9 @@ public class DefaultMavenProjectBuilder
// Always cache files in the source tree over those in the repository
modelCache.put( createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion() ), model );
Settings settings = null;
try
{
settings = mavenSettingsBuilder.buildSettings();
@ -136,7 +137,7 @@ public class DefaultMavenProjectBuilder
{
throw new ProjectBuildingException( "Cannot read settings.", e );
}
boolean systemOnline = !settings.getActiveProfile().isOffline();
MavenProject project = build( model, localRepository, resolveDependencies );
@ -160,7 +161,7 @@ public class DefaultMavenProjectBuilder
throws ProjectBuildingException
{
Settings settings = null;
try
{
settings = mavenSettingsBuilder.buildSettings();
@ -169,7 +170,7 @@ public class DefaultMavenProjectBuilder
{
throw new ProjectBuildingException( "Cannot read settings.", e );
}
Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
return build( model, localRepository, false );
@ -312,7 +313,7 @@ public class DefaultMavenProjectBuilder
{
throw new ProjectBuildingException( "Cannot read settings.", e );
}
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, this );
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(),
@ -583,7 +584,7 @@ public class DefaultMavenProjectBuilder
}
public void contextualize( Context context )
throws Exception
throws ContextException
{
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}

View File

@ -16,16 +16,15 @@ package org.apache.maven.settings;
* limitations under the License.
*/
import java.io.File;
import java.io.FileReader;
import org.apache.maven.MavenConstants;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.util.IOUtil;
import java.io.File;
import java.io.FileReader;
/**
* @author jdcasey
* @version $Id$
@ -36,7 +35,9 @@ public class DefaultMavenSettingsBuilder
{
public static final String userHome = System.getProperty( "user.home" );
/** @configuration */
/**
* @configuration
*/
private String settingsPath;
private File settingsFile;
@ -46,7 +47,6 @@ public class DefaultMavenSettingsBuilder
// ----------------------------------------------------------------------
public void initialize()
throws Exception
{
settingsFile = getSettingsFile();
@ -62,7 +62,7 @@ public class DefaultMavenSettingsBuilder
throws Exception
{
Settings settings = null;
if ( settingsFile.exists() && settingsFile.isFile() )
{
FileReader reader = null;
@ -79,17 +79,18 @@ public class DefaultMavenSettingsBuilder
IOUtil.close( reader );
}
}
if(settings == null)
if ( settings == null )
{
getLogger().debug( "Settings model not found. Creating empty instance of MavenSettings." );
settings = new Settings();
}
if(settings.getActiveProfile() == null)
if ( settings.getActiveProfile() == null )
{
File mavenUserConfigurationDirectory = new File( userHome, MavenConstants.MAVEN_USER_CONFIGURATION_DIRECTORY );
File mavenUserConfigurationDirectory = new File( userHome,
MavenConstants.MAVEN_USER_CONFIGURATION_DIRECTORY );
if ( !mavenUserConfigurationDirectory.exists() )
{
if ( !mavenUserConfigurationDirectory.mkdirs() )
@ -98,12 +99,11 @@ public class DefaultMavenSettingsBuilder
}
}
String localRepository =
new File( mavenUserConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
String localRepository = new File( mavenUserConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
settings.initializeActiveProfile( localRepository );
}
return settings;
}