o Refactored the MavenSettings code into the settings.mdo/Settings class.

o Added code to cache the active proxy and profile inside the Settings instance for quicker lookup.

o Added a method to initialize a new active profile for a Settings instance in the event one didn't exist.

o Started adding offline mode. So far, I've implemented:

  - Warning when a mojo declares a requirement for connectivity, but we're offline.

  - INFO message stating when maven is running in offline mode.

  - Addition to the Profile class in o.a.m.settings package to allow specification of offline mode by declaring: <offline>true</offline>


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163969 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-04-18 21:50:55 +00:00
parent 72997ebd53
commit 61406495be
22 changed files with 291 additions and 217 deletions

View File

@ -18,7 +18,7 @@
<dependency>
<groupId>marmalade</groupId>
<artifactId>marmalade-core</artifactId>
<version>1.0-alpha-2</version>
<version>1.0-alpha-3-SNAPSHOT</version>
</dependency>
</dependencies>
<build>

View File

@ -1,5 +1,3 @@
<?xml version="1.0"?>
<mojo xmlns="marmalade:mojo">
<metadata>
<id>it0015</id>

View File

@ -32,7 +32,7 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.reactor.ReactorException;
import org.apache.maven.settings.MavenSettings;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.Proxy;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
@ -76,6 +76,8 @@ public class DefaultMaven
protected PlexusContainer container;
protected ArtifactRepositoryFactory artifactRepositoryFactory;
protected WagonManager wagonManager;
// ----------------------------------------------------------------------
// Project execution
@ -87,12 +89,18 @@ public class DefaultMaven
{
throw new ReactorException( "You must specify at least one goal. Try 'install'." );
}
if( request.getSettings().getActiveProfile().isOffline() )
{
getLogger().info( "Maven is running in offline mode." );
}
EventDispatcher dispatcher = request.getEventDispatcher();
String event = MavenEvents.REACTOR_EXECUTION;
// TODO: goals are outer loop
dispatcher.dispatchStart( event, request.getBaseDirectory() );
try
{
List projects;
@ -285,12 +293,15 @@ public class DefaultMaven
/**
* @todo [BP] this might not be required if there is a better way to pass
* them in. It doesn't feel quite right.
*
* @todo [JC] we should at least provide a mapping of protocol-to-proxy for
* the wagons, shouldn't we?
*/
private void resolveParameters( MavenExecutionRequest request ) throws ComponentLookupException
{
WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
MavenSettings settings = request.getSettings();
Settings settings = request.getSettings();
Proxy proxy = settings.getActiveProxy();

View File

@ -18,7 +18,7 @@ package org.apache.maven.artifact.repository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.Repository;
import org.apache.maven.settings.MavenSettings;
import org.apache.maven.settings.Settings;
/**
* @author jdcasey
@ -28,7 +28,7 @@ public interface ArtifactRepositoryFactory
public static final String ROLE = ArtifactRepositoryFactory.class.getName();
public ArtifactRepository createArtifactRepository( Repository modelRepository, MavenSettings settings,
public ArtifactRepository createArtifactRepository( Repository modelRepository, Settings settings,
ArtifactRepositoryLayout repositoryLayout );
void setGlobalSnapshotPolicy( String snapshotPolicy );

View File

@ -18,7 +18,7 @@ package org.apache.maven.artifact.repository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.Repository;
import org.apache.maven.settings.MavenSettings;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.Server;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@ -33,7 +33,7 @@ public class DefaultArtifactRepositoryFactory
{
private String globalSnapshotPolicy = null;
public ArtifactRepository createArtifactRepository( Repository modelRepository, MavenSettings settings,
public ArtifactRepository createArtifactRepository( Repository modelRepository, Settings settings,
ArtifactRepositoryLayout repositoryLayout )
{
Server repoProfile = null;

View File

@ -25,7 +25,6 @@ import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.maven.Maven;
import org.apache.maven.MavenConstants;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
@ -41,7 +40,7 @@ import org.apache.maven.monitor.event.DefaultEventMonitor;
import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.plugin.Plugin;
import org.apache.maven.settings.MavenSettings;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.MavenSettingsBuilder;
import org.apache.maven.settings.Profile;
import org.codehaus.classworlds.ClassWorld;
@ -65,8 +64,6 @@ public class MavenCli
{
public static final String POMv4 = "pom.xml";
public static final String userHome = System.getProperty( "user.home" );
public static File userDir = new File( System.getProperty( "user.dir" ) );
public static int main( String[] args, ClassWorld classWorld )
@ -153,17 +150,23 @@ public class MavenCli
MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) embedder.lookup( MavenSettingsBuilder.ROLE );
MavenSettings settings = settingsBuilder.buildSettings();
Settings settings = settingsBuilder.buildSettings();
ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder.lookup(
ArtifactRepositoryFactory.ROLE );
boolean snapshotPolicySet = false;
if ( commandLine.hasOption( CLIManager.OFFLINE ) )
{
settings.getActiveProfile().setOffline(true);
// TODO: this will still check to download if the artifact does not exist locally, instead of failing as it should in offline mode
artifactRepositoryFactory.setGlobalSnapshotPolicy( ArtifactRepository.SNAPSHOT_POLICY_NEVER );
snapshotPolicySet = true;
}
else if ( commandLine.hasOption( CLIManager.UPDATE_SNAPSHOTS ) )
if ( !snapshotPolicySet && commandLine.hasOption( CLIManager.UPDATE_SNAPSHOTS ) )
{
artifactRepositoryFactory.setGlobalSnapshotPolicy( ArtifactRepository.SNAPSHOT_POLICY_ALWAYS );
}
@ -352,44 +355,18 @@ public class MavenCli
//
// ----------------------------------------------------------------------
protected static File getUserConfigurationDirectory()
{
File mavenUserConfigurationDirectory = new File( userHome, MavenConstants.MAVEN_USER_CONFIGURATION_DIRECTORY );
if ( !mavenUserConfigurationDirectory.exists() )
{
if ( !mavenUserConfigurationDirectory.mkdirs() )
{
//throw a configuration exception
}
}
return mavenUserConfigurationDirectory;
}
protected static ArtifactRepository getLocalRepository( MavenSettings settings,
protected static ArtifactRepository getLocalRepository( Settings settings,
ArtifactRepositoryFactory repoFactory,
ArtifactRepositoryLayout repositoryLayout )
throws Exception
{
Profile profile = settings.getActiveProfile();
String localRepository = null;
if ( profile != null )
{
localRepository = profile.getLocalRepository();
}
if ( localRepository == null )
{
File userConfigurationDirectory = getUserConfigurationDirectory();
localRepository =
new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
}
Repository repo = new Repository();
repo.setId( "local" );
repo.setUrl( "file://" + localRepository );
repo.setUrl( "file://" + profile.getLocalRepository() );
return repoFactory.createArtifactRepository( repo, settings, repositoryLayout );
}

View File

@ -21,7 +21,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.monitor.event.EventMonitor;
import org.apache.maven.monitor.logging.Log;
import org.apache.maven.settings.MavenSettings;
import org.apache.maven.settings.Settings;
import java.util.List;
@ -47,13 +47,13 @@ public class DefaultMavenExecutionRequest
private final EventDispatcher eventDispatcher;
private final MavenSettings settings;
private final Settings settings;
private final String baseDirectory;
private boolean recursive = true;
public DefaultMavenExecutionRequest( ArtifactRepository localRepository, MavenSettings settings,
public DefaultMavenExecutionRequest( ArtifactRepository localRepository, Settings settings,
EventDispatcher eventDispatcher, List goals, List files, String baseDirectory )
{
this.localRepository = localRepository;
@ -69,7 +69,7 @@ public class DefaultMavenExecutionRequest
this.baseDirectory = baseDirectory;
}
public MavenSettings getSettings()
public Settings getSettings()
{
return settings;
}

View File

@ -21,7 +21,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.monitor.event.EventMonitor;
import org.apache.maven.monitor.logging.Log;
import org.apache.maven.settings.MavenSettings;
import org.apache.maven.settings.Settings;
import java.util.List;
@ -49,7 +49,7 @@ public interface MavenExecutionRequest
EventDispatcher getEventDispatcher();
MavenSettings getSettings();
Settings getSettings();
String getBaseDirectory();

View File

@ -22,7 +22,7 @@ import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.monitor.logging.Log;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.MavenSettings;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.util.dag.CycleDetectedException;
@ -59,10 +59,10 @@ public class MavenSession
private Log log;
private final MavenSettings settings;
private final Settings settings;
public MavenSession( MavenProject project, PlexusContainer container, PluginManager pluginManager,
MavenSettings settings, ArtifactRepository localRepository, EventDispatcher eventDispatcher,
Settings settings, ArtifactRepository localRepository, EventDispatcher eventDispatcher,
Log log, List goals )
{
this.project = project;
@ -138,7 +138,7 @@ public class MavenSession
return log;
}
public MavenSettings getSettings()
public Settings getSettings()
{
return settings;
}

View File

@ -32,6 +32,7 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.logging.Logger;
@ -222,17 +223,17 @@ public class DefaultLifecycleExecutor
* phase in the lifecycle and if it does place it at the end of the list of goals
* to execute for that given phase.
*
* @param mavenSession
* @param session
* @throws Exception
*/
private void processPluginPhases( Plugin plugin, MavenSession mavenSession, Map phaseMap )
private void processPluginPhases( Plugin plugin, MavenSession session, Map phaseMap )
throws Exception
{
String groupId = plugin.getGroupId();
String artifactId = plugin.getArtifactId();
pluginManager.verifyPlugin( groupId, artifactId, mavenSession );
pluginManager.verifyPlugin( groupId, artifactId, session );
PluginDescriptor pluginDescriptor = pluginManager.getPluginDescriptor( groupId, artifactId );
@ -264,7 +265,7 @@ public class DefaultLifecycleExecutor
"' was declared in pom.xml, but does not exist" );
}
configureMojo( mojoDescriptor, phaseMap );
configureMojo( mojoDescriptor, phaseMap, session.getSettings() );
}
}
else
@ -273,7 +274,7 @@ public class DefaultLifecycleExecutor
{
MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next();
configureMojo( mojoDescriptor, phaseMap );
configureMojo( mojoDescriptor, phaseMap, session.getSettings() );
}
}
}
@ -285,13 +286,21 @@ public class DefaultLifecycleExecutor
*
* @param mojoDescriptor
*/
private void configureMojo( MojoDescriptor mojoDescriptor, Map phaseMap )
private void configureMojo( MojoDescriptor mojoDescriptor, Map phaseMap, Settings settings )
{
if ( mojoDescriptor.getPhase() != null )
if( settings.getActiveProfile().isOffline() && mojoDescriptor.requiresOnline() )
{
Phase phase = (Phase) phaseMap.get( mojoDescriptor.getPhase() );
String goal = mojoDescriptor.getGoal();
getLogger().warn( goal + " requires online mode, but maven is currently offline. Disabling " + goal + "." );
}
else
{
if ( mojoDescriptor.getPhase() != null )
{
Phase phase = (Phase) phaseMap.get( mojoDescriptor.getPhase() );
phase.getGoals().add( mojoDescriptor.getId() );
phase.getGoals().add( mojoDescriptor.getId() );
}
}
}
@ -357,7 +366,7 @@ public class DefaultLifecycleExecutor
}
}
configureMojo( mojoDescriptor, phaseMap );
configureMojo( mojoDescriptor, phaseMap, session.getSettings() );
}
private void executePhase( String phase, MavenSession session, Map phaseMap )

View File

@ -741,6 +741,8 @@ public class DefaultPluginManager
ArtifactFilter filter = new ScopeArtifactFilter( scope );
boolean systemOnline = !context.getSettings().getActiveProfile().isOffline();
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(),
context.getRemoteRepositories(),
context.getLocalRepository(),

View File

@ -39,8 +39,8 @@ import org.apache.maven.project.interpolation.ModelInterpolator;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
import org.apache.maven.settings.MavenSettings;
import org.apache.maven.settings.MavenSettingsBuilder;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@ -125,6 +125,19 @@ 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();
}
catch ( Exception e )
{
throw new ProjectBuildingException( "Cannot read settings.", e );
}
boolean systemOnline = !settings.getActiveProfile().isOffline();
MavenProject project = build( model, localRepository, resolveDependencies );
@ -146,6 +159,17 @@ public class DefaultMavenProjectBuilder
ArtifactRepository localRepository )
throws ProjectBuildingException
{
Settings settings = null;
try
{
settings = mavenSettingsBuilder.buildSettings();
}
catch ( Exception e )
{
throw new ProjectBuildingException( "Cannot read settings.", e );
}
Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
return build( model, localRepository, false );
@ -279,6 +303,16 @@ public class DefaultMavenProjectBuilder
if ( resolveDependencies )
{
Settings settings;
try
{
settings = mavenSettingsBuilder.buildSettings();
}
catch ( Exception e )
{
throw new ProjectBuildingException( "Cannot read settings.", e );
}
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, this );
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(),
@ -350,7 +384,7 @@ public class DefaultMavenProjectBuilder
private List buildArtifactRepositories( List repositories )
throws ProjectBuildingException
{
MavenSettings settings = null;
Settings settings = null;
try
{
@ -398,7 +432,7 @@ public class DefaultMavenProjectBuilder
{
List remotePluginRepositories = new ArrayList();
MavenSettings settings = mavenSettingsBuilder.buildSettings();
Settings settings = mavenSettingsBuilder.buildSettings();
for ( Iterator it = pluginRepositories.iterator(); it.hasNext(); )
{
@ -438,7 +472,7 @@ public class DefaultMavenProjectBuilder
return null;
}
MavenSettings settings = mavenSettingsBuilder.buildSettings();
Settings settings = mavenSettingsBuilder.buildSettings();
String repoLayoutId = dmRepo.getLayout();

View File

@ -19,6 +19,7 @@ package org.apache.maven.settings;
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;
@ -33,6 +34,8 @@ public class DefaultMavenSettingsBuilder
extends AbstractLogEnabled
implements MavenSettingsBuilder, Initializable
{
public static final String userHome = System.getProperty( "user.home" );
/** @configuration */
private String settingsPath;
@ -55,9 +58,11 @@ public class DefaultMavenSettingsBuilder
// ----------------------------------------------------------------------
// TODO: don't throw Exception.
public MavenSettings buildSettings()
public Settings buildSettings()
throws Exception
{
Settings settings = null;
if ( settingsFile.exists() && settingsFile.isFile() )
{
FileReader reader = null;
@ -67,21 +72,39 @@ public class DefaultMavenSettingsBuilder
SettingsXpp3Reader modelReader = new SettingsXpp3Reader();
Settings model = modelReader.read( reader );
return new MavenSettings( model );
settings = modelReader.read( reader );
}
finally
{
IOUtil.close( reader );
}
}
else
if(settings == null)
{
getLogger().debug( "Settings model not found. Creating empty instance of MavenSettings." );
return new MavenSettings();
settings = new Settings();
}
if(settings.getActiveProfile() == null)
{
File mavenUserConfigurationDirectory = new File( userHome, MavenConstants.MAVEN_USER_CONFIGURATION_DIRECTORY );
if ( !mavenUserConfigurationDirectory.exists() )
{
if ( !mavenUserConfigurationDirectory.mkdirs() )
{
//throw a configuration exception
}
}
String localRepository =
new File( mavenUserConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
settings.initializeActiveProfile( localRepository );
}
return settings;
}
private File getSettingsFile()

View File

@ -1,128 +0,0 @@
package org.apache.maven.settings;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Iterator;
import java.util.List;
/**
* @author jdcasey
* @version $Id$
*/
public class MavenSettings
{
private static final String DEFAULT_LOCAL_REPOSITORY = "/.m2/repository";
private final Settings settings;
public MavenSettings()
{
settings = new Settings();
Profile profile = new Profile();
profile.setActive( true );
String userHome = System.getProperty( "user.home" );
profile.setLocalRepository( userHome + DEFAULT_LOCAL_REPOSITORY );
settings.addProfile( profile );
}
public MavenSettings( Settings settings )
{
this.settings = settings;
}
public Server getServer( String serverId )
{
Server match = null;
List servers = settings.getServers();
if ( servers != null && serverId != null )
{
for ( Iterator it = servers.iterator(); it.hasNext(); )
{
Server server = (Server) it.next();
if ( serverId.equals( server.getId() ) )
{
match = server;
break;
}
}
}
return match;
}
public Profile getActiveProfile()
{
Profile active = null;
List profiles = settings.getProfiles();
if ( profiles != null && !profiles.isEmpty() )
{
if ( profiles.size() > 1 )
{
for ( Iterator it = profiles.iterator(); it.hasNext(); )
{
Profile profile = (Profile) it.next();
if ( profile.isActive() )
{
active = profile;
break;
}
}
}
else
{
// If we only have one profile, use it as the active one.
active = (Profile) profiles.get( 0 );
}
}
return active;
}
public Proxy getActiveProxy()
{
Proxy active = null;
List proxies = settings.getProxies();
if ( proxies != null && !proxies.isEmpty() )
{
if ( proxies.size() > 1 )
{
for ( Iterator it = proxies.iterator(); it.hasNext(); )
{
Proxy proxy = (Proxy) it.next();
if ( proxy.isActive() )
{
active = proxy;
break;
}
}
}
else
{
// If we only have one profile, use it as the active one.
active = (Proxy) proxies.get( 0 );
}
}
return active;
}
}

View File

@ -25,6 +25,6 @@ public interface MavenSettingsBuilder
String ROLE = MavenSettingsBuilder.class.getName();
// TODO: Don't throw Exception.
MavenSettings buildSettings()
Settings buildSettings()
throws Exception;
}

View File

@ -123,7 +123,9 @@ Offline Mode Design
It is not possible to determine whether a file-based location will
be available except on a case-by-case basis (or a root-url by
root-url basis).
root-url basis). We may want to move the offline sensitivity entirely to
Maven-Artifact, below, so we can be smarter about testing filesystem-based
repositories, etc.
* If not otherwise specified, all other wagons are assumed to be
remote-only, and are therefore sensitive to offline mode.
@ -131,6 +133,12 @@ Offline Mode Design
** Maven-Artifact
This is wholly dependent on Maven-Wagon, above.
We could possibly use a flag on a particular Wagon to see whether it supports
offline mode, and then test to see if the file-based basedir for an aritfact
repository works...if it doesn't work, we can mark that repository offline...
OTOH, all offline-mode checks can probably be run from Wagon-based APIs.
** Maven-SCM

View File

@ -53,7 +53,9 @@ public abstract class MavenTestCase
protected File getLocalRepositoryPath()
{
return getTestFile( "src/test/resources/local-repo" );
File markerFile = getFileForClasspathResource( "local-repo/marker.txt" );
return markerFile.getAbsoluteFile().getParentFile();
}
protected File getFileForClasspathResource( String resource )

View File

@ -9,7 +9,7 @@ import org.apache.maven.model.Model;
import org.apache.maven.monitor.event.DefaultEventDispatcher;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.MavenSettings;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
@ -58,7 +58,7 @@ public class PluginParameterExpressionEvaluatorTest
MavenProject project = new MavenProject( model );
project.setFile( new File( "pom.xml" ).getCanonicalFile() );
MavenSession session = new MavenSession( project, container, mgr, new MavenSettings(), repo,
MavenSession session = new MavenSession( project, container, mgr, new Settings(), repo,
new DefaultEventDispatcher(), new DefaultLog( container.getLogger() ),
Collections.EMPTY_LIST );
@ -86,7 +86,7 @@ public class PluginParameterExpressionEvaluatorTest
PlexusContainer container = getContainer();
MavenSession session = new MavenSession( null, // don't need a project for this test.
container, mgr, new MavenSettings(), repo,
container, mgr, new Settings(), repo,
new DefaultEventDispatcher(), new DefaultLog( container.getLogger() ),
Collections.EMPTY_LIST );
@ -107,7 +107,7 @@ public class PluginParameterExpressionEvaluatorTest
PlexusContainer container = getContainer();
MavenSession session = new MavenSession( null, // don't need a project for this test.
container, mgr, new MavenSettings(), repo,
container, mgr, new Settings(), repo,
new DefaultEventDispatcher(), new DefaultLog( container.getLogger() ),
Collections.EMPTY_LIST );

View File

@ -30,12 +30,12 @@ public class ProjectClasspathTest
extends MavenTestCase
{
private String dir = "src/test/resources/projects/scope/";
private String dir = "projects/scope/";
public void testProjectClasspath()
throws Exception
{
File f = getTestFile( dir + "project-with-scoped-dependencies.xml" );
File f = getFileForClasspathResource( dir + "project-with-scoped-dependencies.xml" );
// XXX: Because this test fails, we resort to crude reflection hacks, see PLX-108 for the solution
// assertEquals( ProjectClasspathArtifactResolver.class, getContainer().lookup( ArtifactResolver.ROLE ).getClass() );

View File

@ -0,0 +1 @@
this is just a marker file.

View File

@ -66,6 +66,8 @@ public class MojoDescriptor
private String requiresDependencyResolution = null;
private boolean requiresProject = true;
private boolean requiresOnline = false;
private String language = DEFAULT_LANGUAGE;
@ -180,6 +182,28 @@ public class MojoDescriptor
return requiresProject;
}
// ----------------------------------------------------------------------
// Online vs. Offline requirement
// ----------------------------------------------------------------------
public void setRequiresOnline( boolean requiresOnline )
{
this.requiresOnline = requiresOnline;
}
// blech! this isn't even intelligible as a method name. provided for
// consistency...
public boolean isRequiresOnline()
{
return requiresOnline;
}
// more english-friendly method...keep the code clean! :)
public boolean requiresOnline()
{
return requiresOnline;
}
public void setRequirements( List requirements )
{
this.requirements = requirements;

View File

@ -17,7 +17,8 @@
<version>1.0.0</version>
<description>Root element of the user configuration file.</description>
<fields>
<field>
<!-- [JC] Not ready to use yet, so I'm making if unavailable for now. -->
<!-- field>
<name>jdks</name>
<version>1.0.0</version>
<description><![CDATA[
@ -31,7 +32,7 @@
<type>Jdk</type>
<multiplicity>*</multiplicity>
</association>
</field>
</field -->
<field>
<name>proxies</name>
<version>1.0.0</version>
@ -77,10 +78,113 @@
</association>
</field>
</fields>
<codeSegments/>
<codeSegments>
<codeSegment>
<version>1.0.0</version>
<code><![CDATA[
private Profile activeProfile;
private Proxy activeProxy;
public synchronized void initializeActiveProfile(String localRepository)
{
if(getActiveProfile() == null)
{
Profile profile = new Profile();
profile.setLocalRepository(localRepository);
profile.setActive(true);
addProfile(profile);
activeProfile = profile;
}
}
public synchronized Profile getActiveProfile()
{
if(activeProfile == null)
{
List profiles = getProfiles();
if ( profiles != null && !profiles.isEmpty() )
{
if ( profiles.size() > 1 )
{
for ( Iterator it = profiles.iterator(); it.hasNext(); )
{
Profile profile = (Profile) it.next();
if ( profile.isActive() )
{
activeProfile = profile;
break;
}
}
}
else
{
// If we only have one profile, use it as the active one.
activeProfile = (Profile) profiles.get( 0 );
}
}
}
return activeProfile;
}
public synchronized Proxy getActiveProxy()
{
if(activeProxy == null)
{
List proxies = getProxies();
if ( proxies != null && !proxies.isEmpty() )
{
if ( proxies.size() > 1 )
{
for ( Iterator it = proxies.iterator(); it.hasNext(); )
{
Proxy proxy = (Proxy) it.next();
if ( proxy.isActive() )
{
activeProxy = proxy;
break;
}
}
}
else
{
// If we only have one proxy, use it as the active one.
activeProxy = (Proxy) proxies.get( 0 );
}
}
}
return activeProxy;
}
public Server getServer( String serverId )
{
Server match = null;
List servers = getServers();
if ( servers != null && serverId != null )
{
for ( Iterator it = servers.iterator(); it.hasNext(); )
{
Server server = (Server) it.next();
if ( serverId.equals( server.getId() ) )
{
match = server;
break;
}
}
}
return match;
}
]]></code>
</codeSegment>
</codeSegments>
</class>
<!-- @todo: is any of this too CVS specific? Investigate other SCMs -->
<class>
<!-- [JC] Commenting out until we're ready to use it... -->
<!-- class>
<name>Jdk</name>
<version>1.0.0</version>
<description><![CDATA[Describes one Java environment]]></description>
@ -108,7 +212,7 @@
<type>String</type>
</field>
</fields>
</class>
</class -->
<class>
<name>Proxy</name>
<version>1.0.0</version>
@ -226,12 +330,21 @@
<description><![CDATA[The local repository.]]></description>
<type>String</type>
</field>
<field>
<!-- [JC] Not ready to use yet, so I'm making if unavailable for now. -->
<!-- field>
<name>passwordStore</name>
<version>1.0.0</version>
<required>true</required>
<required>false</required>
<description><![CDATA[The keystore used to store passwords.]]></description>
<type>String</type>
</field -->
<field>
<name>offline</name>
<version>1.0.0</version>
<required>false</required>
<description><![CDATA[Indicate whether maven should operate in offline mode full-time.]]></description>
<type>boolean</type>
<defaultValue>false</defaultValue>
</field>
</fields>
</class>