mirror of https://github.com/apache/maven.git
o Added (pom|project)? to the eval pattern in the regex param extractor, to trim ${project.artifactid} to mean the same as ${artifactId} within the pom.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163490 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ba74921b31
commit
77d3e6c5f5
|
@ -7,3 +7,4 @@ maven-component.i*
|
||||||
.settings
|
.settings
|
||||||
mboot.jar
|
mboot.jar
|
||||||
dummy
|
dummy
|
||||||
|
build.ajproperties
|
||||||
|
|
|
@ -31,6 +31,11 @@
|
||||||
<artifactId>maven-model</artifactId>
|
<artifactId>maven-model</artifactId>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-user-model</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>maven-artifact</artifactId>
|
<artifactId>maven-artifact</artifactId>
|
||||||
|
|
|
@ -267,6 +267,7 @@ public class DefaultMaven
|
||||||
{
|
{
|
||||||
return new MavenSession( container,
|
return new MavenSession( container,
|
||||||
pluginManager,
|
pluginManager,
|
||||||
|
request.getUserModel(),
|
||||||
request.getLocalRepository(),
|
request.getLocalRepository(),
|
||||||
request.getEventDispatcher(),
|
request.getEventDispatcher(),
|
||||||
request.getLog(),
|
request.getLog(),
|
||||||
|
|
|
@ -33,11 +33,13 @@ import org.apache.maven.execution.MavenExecutionResponse;
|
||||||
import org.apache.maven.execution.MavenInitializingExecutionRequest;
|
import org.apache.maven.execution.MavenInitializingExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenProjectExecutionRequest;
|
import org.apache.maven.execution.MavenProjectExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenReactorExecutionRequest;
|
import org.apache.maven.execution.MavenReactorExecutionRequest;
|
||||||
|
import org.apache.maven.model.user.UserModel;
|
||||||
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||||
import org.apache.maven.monitor.event.DefaultEventMonitor;
|
import org.apache.maven.monitor.event.DefaultEventMonitor;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.monitor.logging.DefaultLog;
|
import org.apache.maven.monitor.logging.DefaultLog;
|
||||||
import org.apache.maven.plugin.Plugin;
|
import org.apache.maven.plugin.Plugin;
|
||||||
|
import org.apache.maven.util.UserModelUtils;
|
||||||
import org.codehaus.classworlds.ClassWorld;
|
import org.codehaus.classworlds.ClassWorld;
|
||||||
import org.codehaus.plexus.embed.ArtifactEnabledEmbedder;
|
import org.codehaus.plexus.embed.ArtifactEnabledEmbedder;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
|
@ -117,7 +119,9 @@ public class MavenCli
|
||||||
File projectFile = new File( userDir, POMv4 );
|
File projectFile = new File( userDir, POMv4 );
|
||||||
|
|
||||||
EventDispatcher eventDispatcher = new DefaultEventDispatcher();
|
EventDispatcher eventDispatcher = new DefaultEventDispatcher();
|
||||||
|
|
||||||
|
UserModel userModel = UserModelUtils.getUserModel();
|
||||||
|
|
||||||
if ( projectFile.exists() )
|
if ( projectFile.exists() )
|
||||||
{
|
{
|
||||||
if ( commandLine.hasOption( CLIManager.REACTOR ) )
|
if ( commandLine.hasOption( CLIManager.REACTOR ) )
|
||||||
|
@ -127,6 +131,7 @@ public class MavenCli
|
||||||
String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );
|
String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );
|
||||||
|
|
||||||
request = new MavenReactorExecutionRequest( localRepository,
|
request = new MavenReactorExecutionRequest( localRepository,
|
||||||
|
userModel,
|
||||||
eventDispatcher,
|
eventDispatcher,
|
||||||
mavenProperties,
|
mavenProperties,
|
||||||
commandLine.getArgList(),
|
commandLine.getArgList(),
|
||||||
|
@ -137,6 +142,7 @@ public class MavenCli
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
request = new MavenProjectExecutionRequest( localRepository,
|
request = new MavenProjectExecutionRequest( localRepository,
|
||||||
|
userModel,
|
||||||
eventDispatcher,
|
eventDispatcher,
|
||||||
mavenProperties,
|
mavenProperties,
|
||||||
commandLine.getArgList(),
|
commandLine.getArgList(),
|
||||||
|
@ -145,7 +151,7 @@ public class MavenCli
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
request = new MavenInitializingExecutionRequest( localRepository, eventDispatcher, mavenProperties, commandLine.getArgList() );
|
request = new MavenInitializingExecutionRequest( localRepository, userModel, eventDispatcher, mavenProperties, commandLine.getArgList() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.maven.execution;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
import org.apache.maven.model.user.UserModel;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.monitor.event.EventMonitor;
|
import org.apache.maven.monitor.event.EventMonitor;
|
||||||
import org.apache.maven.monitor.logging.Log;
|
import org.apache.maven.monitor.logging.Log;
|
||||||
|
@ -48,9 +48,13 @@ implements MavenExecutionRequest
|
||||||
|
|
||||||
private EventDispatcher eventDispatcher;
|
private EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
public AbstractMavenExecutionRequest( ArtifactRepository localRepository, EventDispatcher eventDispatcher, Properties parameters, List goals )
|
private final UserModel userModel;
|
||||||
|
|
||||||
|
public AbstractMavenExecutionRequest( ArtifactRepository localRepository, UserModel userModel, EventDispatcher eventDispatcher, Properties parameters, List goals )
|
||||||
{
|
{
|
||||||
this.localRepository = localRepository;
|
this.localRepository = localRepository;
|
||||||
|
|
||||||
|
this.userModel = userModel;
|
||||||
|
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
|
|
||||||
|
@ -58,6 +62,11 @@ implements MavenExecutionRequest
|
||||||
|
|
||||||
this.eventDispatcher = eventDispatcher;
|
this.eventDispatcher = eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserModel getUserModel()
|
||||||
|
{
|
||||||
|
return userModel;
|
||||||
|
}
|
||||||
|
|
||||||
public ArtifactRepository getLocalRepository()
|
public ArtifactRepository getLocalRepository()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.execution;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.model.user.UserModel;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.monitor.event.EventMonitor;
|
import org.apache.maven.monitor.event.EventMonitor;
|
||||||
import org.apache.maven.monitor.logging.Log;
|
import org.apache.maven.monitor.logging.Log;
|
||||||
|
@ -52,4 +53,6 @@ public interface MavenExecutionRequest
|
||||||
void addEventMonitor( EventMonitor monitor );
|
void addEventMonitor( EventMonitor monitor );
|
||||||
|
|
||||||
EventDispatcher getEventDispatcher();
|
EventDispatcher getEventDispatcher();
|
||||||
|
|
||||||
|
UserModel getUserModel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.execution;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.model.user.UserModel;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -30,9 +31,9 @@ import java.util.Properties;
|
||||||
public class MavenInitializingExecutionRequest
|
public class MavenInitializingExecutionRequest
|
||||||
extends AbstractMavenExecutionRequest
|
extends AbstractMavenExecutionRequest
|
||||||
{
|
{
|
||||||
public MavenInitializingExecutionRequest( ArtifactRepository localRepository, EventDispatcher eventDispatcher, Properties properties, List goals )
|
public MavenInitializingExecutionRequest( ArtifactRepository localRepository, UserModel userModel, EventDispatcher eventDispatcher, Properties properties, List goals )
|
||||||
{
|
{
|
||||||
super( localRepository, eventDispatcher, properties, goals );
|
super( localRepository, userModel, eventDispatcher, properties, goals );
|
||||||
|
|
||||||
type = "initializing";
|
type = "initializing";
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.execution;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.model.user.UserModel;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -35,12 +36,13 @@ extends AbstractMavenExecutionRequest
|
||||||
private File pom;
|
private File pom;
|
||||||
|
|
||||||
public MavenProjectExecutionRequest( ArtifactRepository localRepository,
|
public MavenProjectExecutionRequest( ArtifactRepository localRepository,
|
||||||
|
UserModel userModel,
|
||||||
EventDispatcher eventDispatcher,
|
EventDispatcher eventDispatcher,
|
||||||
Properties properties,
|
Properties properties,
|
||||||
List goals,
|
List goals,
|
||||||
File pom )
|
File pom )
|
||||||
{
|
{
|
||||||
super( localRepository, eventDispatcher, properties, goals );
|
super( localRepository, userModel, eventDispatcher, properties, goals );
|
||||||
|
|
||||||
this.pom = pom;
|
this.pom = pom;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.execution;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.model.user.UserModel;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
@ -40,11 +41,11 @@ extends AbstractMavenExecutionRequest
|
||||||
|
|
||||||
private File baseDirectory;
|
private File baseDirectory;
|
||||||
|
|
||||||
public MavenReactorExecutionRequest( ArtifactRepository localRepository, EventDispatcher eventDispatcher,
|
public MavenReactorExecutionRequest( ArtifactRepository localRepository, UserModel userModel, EventDispatcher eventDispatcher,
|
||||||
Properties properties, List goals, String includes,
|
Properties properties, List goals, String includes,
|
||||||
String excludes, File baseDirectory )
|
String excludes, File baseDirectory )
|
||||||
{
|
{
|
||||||
super( localRepository, eventDispatcher, properties, goals );
|
super( localRepository, userModel, eventDispatcher, properties, goals );
|
||||||
|
|
||||||
this.includes = includes;
|
this.includes = includes;
|
||||||
|
|
||||||
|
@ -78,6 +79,6 @@ extends AbstractMavenExecutionRequest
|
||||||
|
|
||||||
public MavenProjectExecutionRequest createProjectExecutionRequest( MavenProject project )
|
public MavenProjectExecutionRequest createProjectExecutionRequest( MavenProject project )
|
||||||
{
|
{
|
||||||
return new MavenProjectExecutionRequest( localRepository, getEventDispatcher(), parameters, goals, project.getFile() );
|
return new MavenProjectExecutionRequest( localRepository, getUserModel(), getEventDispatcher(), parameters, goals, project.getFile() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.execution;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.model.user.UserModel;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.monitor.logging.Log;
|
import org.apache.maven.monitor.logging.Log;
|
||||||
import org.apache.maven.plugin.PluginManager;
|
import org.apache.maven.plugin.PluginManager;
|
||||||
|
@ -62,12 +63,16 @@ public class MavenSession
|
||||||
|
|
||||||
private Log log;
|
private Log log;
|
||||||
|
|
||||||
public MavenSession( PlexusContainer container, PluginManager pluginManager, ArtifactRepository localRepository,
|
private final UserModel userModel;
|
||||||
|
|
||||||
|
public MavenSession( PlexusContainer container, PluginManager pluginManager, UserModel userModel, ArtifactRepository localRepository,
|
||||||
EventDispatcher eventDispatcher, Log log, List goals )
|
EventDispatcher eventDispatcher, Log log, List goals )
|
||||||
{
|
{
|
||||||
this.container = container;
|
this.container = container;
|
||||||
|
|
||||||
this.pluginManager = pluginManager;
|
this.pluginManager = pluginManager;
|
||||||
|
|
||||||
|
this.userModel = userModel;
|
||||||
|
|
||||||
this.localRepository = localRepository;
|
this.localRepository = localRepository;
|
||||||
|
|
||||||
|
@ -79,7 +84,7 @@ public class MavenSession
|
||||||
|
|
||||||
this.goals = goals;
|
this.goals = goals;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlexusContainer getContainer()
|
public PlexusContainer getContainer()
|
||||||
{
|
{
|
||||||
return container;
|
return container;
|
||||||
|
@ -143,6 +148,11 @@ public class MavenSession
|
||||||
{
|
{
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserModel getUserModel()
|
||||||
|
{
|
||||||
|
return userModel;
|
||||||
|
}
|
||||||
|
|
||||||
public void addImpliedExecution( String goal, String implied ) throws CycleDetectedException
|
public void addImpliedExecution( String goal, String implied ) throws CycleDetectedException
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class RegexBasedModelInterpolator
|
||||||
implements ModelInterpolator
|
implements ModelInterpolator
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Pattern EXPRESSION_PATTERN = Pattern.compile( "\\$\\{([^}]+)\\}" );
|
private static final Pattern EXPRESSION_PATTERN = Pattern.compile( "\\$\\{(pom|project\\.)?([^}]+)\\}" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Added: Feb 3, 2005 by jdcasey
|
* Added: Feb 3, 2005 by jdcasey
|
||||||
|
@ -87,7 +87,7 @@ public class RegexBasedModelInterpolator
|
||||||
while ( matcher.find() )
|
while ( matcher.find() )
|
||||||
{
|
{
|
||||||
String wholeExpr = matcher.group( 0 );
|
String wholeExpr = matcher.group( 0 );
|
||||||
String realExpr = matcher.group( 1 );
|
String realExpr = matcher.group( 2 );
|
||||||
|
|
||||||
String value = null;
|
String value = null;
|
||||||
try
|
try
|
||||||
|
|
|
@ -0,0 +1,193 @@
|
||||||
|
package org.apache.maven.util;
|
||||||
|
|
||||||
|
import org.apache.maven.model.user.JdkProfile;
|
||||||
|
import org.apache.maven.model.user.MavenProfile;
|
||||||
|
import org.apache.maven.model.user.ServerProfile;
|
||||||
|
import org.apache.maven.model.user.UserModel;
|
||||||
|
import org.apache.maven.model.user.io.xpp3.MavenUserModelXpp3Reader;
|
||||||
|
import org.apache.maven.model.user.io.xpp3.MavenUserModelXpp3Writer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public final class UserModelUtils
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String JDK_PROFILE_ENVAR = "maven.jdkVersion";
|
||||||
|
|
||||||
|
public static final String MAVEN_PROFILE_ENVAR = "maven.mavenProfileId";
|
||||||
|
|
||||||
|
public static final String SERVER_PROFILE_ENVAR = "maven.serverProfileId";
|
||||||
|
|
||||||
|
private static final String USER_MODEL_LOCATION = "/.m2/user.xml";
|
||||||
|
|
||||||
|
private UserModelUtils()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ServerProfile getActiveServer( UserModel userModel )
|
||||||
|
{
|
||||||
|
List servers = userModel.getServerProfiles();
|
||||||
|
|
||||||
|
String serverId = System.getProperty( SERVER_PROFILE_ENVAR );
|
||||||
|
if ( serverId == null || serverId.trim().length() < 1 )
|
||||||
|
{
|
||||||
|
serverId = userModel.getDefaultProfiles().getServerProfileId();
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerProfile active = null;
|
||||||
|
for ( Iterator it = servers.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
ServerProfile server = (ServerProfile) it.next();
|
||||||
|
if ( serverId.equals( server.getId() ) )
|
||||||
|
{
|
||||||
|
active = server;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JdkProfile getActiveJdk( UserModel userModel )
|
||||||
|
{
|
||||||
|
List jdks = userModel.getJdkProfiles();
|
||||||
|
|
||||||
|
String jdkId = System.getProperty( JDK_PROFILE_ENVAR );
|
||||||
|
if ( jdkId == null || jdkId.trim().length() < 1 )
|
||||||
|
{
|
||||||
|
jdkId = userModel.getDefaultProfiles().getJdkVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
JdkProfile active = null;
|
||||||
|
for ( Iterator it = jdks.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
JdkProfile jdk = (JdkProfile) it.next();
|
||||||
|
if ( jdkId.equals( jdk.getVersion() ) )
|
||||||
|
{
|
||||||
|
active = jdk;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MavenProfile getActiveRuntimeProfile( UserModel userModel )
|
||||||
|
{
|
||||||
|
List mavenProfiles = userModel.getMavenProfiles();
|
||||||
|
|
||||||
|
String mavenProfileId = System.getProperty( MAVEN_PROFILE_ENVAR );
|
||||||
|
if ( mavenProfileId == null || mavenProfileId.trim().length() < 1 )
|
||||||
|
{
|
||||||
|
mavenProfileId = userModel.getDefaultProfiles().getMavenProfileId();
|
||||||
|
}
|
||||||
|
|
||||||
|
MavenProfile active = null;
|
||||||
|
for ( Iterator it = mavenProfiles.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
MavenProfile mavenProfile = (MavenProfile) it.next();
|
||||||
|
if ( mavenProfileId.equals( mavenProfile.getId() ) )
|
||||||
|
{
|
||||||
|
active = mavenProfile;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: don't throw Exception.
|
||||||
|
public static UserModel getUserModel() throws Exception
|
||||||
|
{
|
||||||
|
UserModel model = null;
|
||||||
|
|
||||||
|
File modelFile = getUserModelFile();
|
||||||
|
if ( modelFile.exists() && modelFile.isFile() )
|
||||||
|
{
|
||||||
|
MavenUserModelXpp3Reader modelReader = new MavenUserModelXpp3Reader();
|
||||||
|
FileReader reader = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reader = new FileReader( modelFile );
|
||||||
|
|
||||||
|
model = modelReader.read( reader );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ( reader != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: don't throw Exception.
|
||||||
|
public static void setUserModel( UserModel userModel ) throws Exception
|
||||||
|
{
|
||||||
|
File modelFile = getUserModelFile();
|
||||||
|
|
||||||
|
File modelDir = modelFile.getParentFile();
|
||||||
|
if ( !modelDir.exists() )
|
||||||
|
{
|
||||||
|
modelDir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
MavenUserModelXpp3Writer modelWriter = new MavenUserModelXpp3Writer();
|
||||||
|
|
||||||
|
FileWriter writer = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writer = new FileWriter( modelFile );
|
||||||
|
|
||||||
|
modelWriter.write( writer, userModel );
|
||||||
|
|
||||||
|
writer.flush();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ( writer != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File getUserModelFile()
|
||||||
|
{
|
||||||
|
String userDir = System.getProperty( "user.home" );
|
||||||
|
|
||||||
|
String modelPath = userDir + USER_MODEL_LOCATION;
|
||||||
|
|
||||||
|
modelPath = modelPath.replaceAll( "\\\\", "/" );
|
||||||
|
modelPath = modelPath.replaceAll( "//", "/" );
|
||||||
|
|
||||||
|
File userModelFile = new File( modelPath );
|
||||||
|
|
||||||
|
return userModelFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
|
import org.apache.maven.model.user.UserModel;
|
||||||
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||||
import org.apache.maven.monitor.logging.DefaultLog;
|
import org.apache.maven.monitor.logging.DefaultLog;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
@ -41,7 +42,7 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
PluginManager mgr = (PluginManager)lookup(PluginManager.ROLE);
|
PluginManager mgr = (PluginManager)lookup(PluginManager.ROLE);
|
||||||
|
|
||||||
PlexusContainer container = getContainer();
|
PlexusContainer container = getContainer();
|
||||||
MavenSession session = new MavenSession(container, mgr, repo, new DefaultEventDispatcher(), new DefaultLog(container.getLogger()), Collections.EMPTY_LIST);
|
MavenSession session = new MavenSession(container, mgr, new UserModel(), repo, new DefaultEventDispatcher(), new DefaultLog(container.getLogger()), Collections.EMPTY_LIST);
|
||||||
|
|
||||||
Build build = new Build();
|
Build build = new Build();
|
||||||
build.setDirectory(expected.substring(0, expected.length() - "/classes".length()));
|
build.setDirectory(expected.substring(0, expected.length() - "/classes".length()));
|
||||||
|
@ -73,7 +74,7 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
PluginManager mgr = (PluginManager)lookup(PluginManager.ROLE);
|
PluginManager mgr = (PluginManager)lookup(PluginManager.ROLE);
|
||||||
|
|
||||||
PlexusContainer container = getContainer();
|
PlexusContainer container = getContainer();
|
||||||
MavenSession session = new MavenSession(container, mgr, repo, new DefaultEventDispatcher(), new DefaultLog(container.getLogger()), Collections.EMPTY_LIST);
|
MavenSession session = new MavenSession(container, mgr, new UserModel(), repo, new DefaultEventDispatcher(), new DefaultLog(container.getLogger()), Collections.EMPTY_LIST);
|
||||||
Object value = PluginParameterExpressionEvaluator.evaluate( role, session );
|
Object value = PluginParameterExpressionEvaluator.evaluate( role, session );
|
||||||
|
|
||||||
assertNotNull( value );
|
assertNotNull( value );
|
||||||
|
@ -86,7 +87,7 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
PluginManager mgr = (PluginManager)lookup(PluginManager.ROLE);
|
PluginManager mgr = (PluginManager)lookup(PluginManager.ROLE);
|
||||||
|
|
||||||
PlexusContainer container = getContainer();
|
PlexusContainer container = getContainer();
|
||||||
MavenSession session = new MavenSession(container, mgr, repo, new DefaultEventDispatcher(), new DefaultLog(container.getLogger()), Collections.EMPTY_LIST);
|
MavenSession session = new MavenSession(container, mgr, new UserModel(), repo, new DefaultEventDispatcher(), new DefaultLog(container.getLogger()), Collections.EMPTY_LIST);
|
||||||
|
|
||||||
Object value = PluginParameterExpressionEvaluator.evaluate( "#localRepository", session );
|
Object value = PluginParameterExpressionEvaluator.evaluate( "#localRepository", session );
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ public class MBoot
|
||||||
|
|
||||||
String[] builds = new String[] {
|
String[] builds = new String[] {
|
||||||
"maven-model",
|
"maven-model",
|
||||||
|
"maven-user-model",
|
||||||
"maven-monitor",
|
"maven-monitor",
|
||||||
"maven-plugin",
|
"maven-plugin",
|
||||||
"maven-artifact",
|
"maven-artifact",
|
||||||
|
@ -477,9 +478,21 @@ public class MBoot
|
||||||
// Generating sources
|
// Generating sources
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
File model = new File( basedir, "maven.mdo" );
|
File base = new File(basedir);
|
||||||
|
|
||||||
|
String[] basedirFiles = base.list();
|
||||||
|
|
||||||
|
File model = null;
|
||||||
|
for ( int i = 0; i < basedirFiles.length; i++ )
|
||||||
|
{
|
||||||
|
if(basedirFiles[i].endsWith(".mdo"))
|
||||||
|
{
|
||||||
|
model = new File(base, basedirFiles[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( model.exists() )
|
if ( model != null && model.exists() )
|
||||||
{
|
{
|
||||||
System.out.println( "Model exists!" );
|
System.out.println( "Model exists!" );
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
<model>
|
||||||
|
<id>mavenUserModel</id>
|
||||||
|
<name>MavenUserModel</name>
|
||||||
|
<description><![CDATA[Maven's user-config model for Java project.]]></description>
|
||||||
|
<defaults>
|
||||||
|
<default>
|
||||||
|
<key>package</key>
|
||||||
|
<value>org.apache.maven.model.user</value>
|
||||||
|
</default>
|
||||||
|
</defaults>
|
||||||
|
<classes>
|
||||||
|
<class rootElement="true">
|
||||||
|
<name>UserModel</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<fields>
|
||||||
|
<field>
|
||||||
|
<name>jdkProfiles</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<description><![CDATA[Configuration for different java environment profiles.]]></description>
|
||||||
|
<association>
|
||||||
|
<type>JdkProfile</type>
|
||||||
|
<multiplicity>*</multiplicity>
|
||||||
|
</association>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>serverProfiles</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<description><![CDATA[Server-access profiles.]]></description>
|
||||||
|
<association>
|
||||||
|
<type>ServerProfile</type>
|
||||||
|
<multiplicity>*</multiplicity>
|
||||||
|
</association>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>mavenProfiles</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<description><![CDATA[Collection of runtime configurations for local repo, etc.]]></description>
|
||||||
|
<association>
|
||||||
|
<type>MavenProfile</type>
|
||||||
|
<multiplicity>*</multiplicity>
|
||||||
|
</association>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>defaultProfiles</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<association>
|
||||||
|
<type>DefaultProfiles</type>
|
||||||
|
</association>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
<codeSegments/>
|
||||||
|
</class>
|
||||||
|
<!-- @todo: is any of this too CVS specific? Investigate other SCMs -->
|
||||||
|
<class>
|
||||||
|
<name>JdkProfile</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<description><![CDATA[Describes one Java environment]]></description>
|
||||||
|
<fields>
|
||||||
|
<field>
|
||||||
|
<name>version</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>true</required>
|
||||||
|
<description><![CDATA[The JDK major version (eg. '1.4').]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>javaHome</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>true</required>
|
||||||
|
<description><![CDATA[The JDK home.]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class>
|
||||||
|
<name>ServerProfile</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<fields>
|
||||||
|
<field>
|
||||||
|
<name>id</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>true</required>
|
||||||
|
<description><![CDATA[The ID of this configuration for external reference.]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>host</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>true</required>
|
||||||
|
<description><![CDATA[The hostname for this configuration.]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>username</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<description><![CDATA[The username used to access this server with this config.]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>passphrase</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<description><![CDATA[The passphrase used to access this server with this config.]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>privateKey</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<description><![CDATA[The private key location used to access this server with this config.]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class>
|
||||||
|
<name>MavenProfile</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<fields>
|
||||||
|
<field>
|
||||||
|
<name>id</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>true</required>
|
||||||
|
<description><![CDATA[The ID of this configuration for external reference.]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>localRepository</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>true</required>
|
||||||
|
<description><![CDATA[The local repository to use for this runtime profile.]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>passwordStore</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>true</required>
|
||||||
|
<description><![CDATA[The keystore used to store passwords for this runtime profile.]]></description>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
<class>
|
||||||
|
<name>DefaultProfiles</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<fields>
|
||||||
|
<field>
|
||||||
|
<name>serverProfileId</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>false</required>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>mavenProfileId</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>true</required>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>jdkVersion</name>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<required>false</required>
|
||||||
|
<type>String</type>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
</model>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-component</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>maven-user-model</artifactId>
|
||||||
|
</project>
|
Loading…
Reference in New Issue