本文整理汇总了Java中org.apache.maven.profiles.ProfileManager类的典型用法代码示例。如果您正苦于以下问题:Java ProfileManager类的具体用法?Java ProfileManager怎么用?Java ProfileManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProfileManager类属于org.apache.maven.profiles包,在下文中一共展示了ProfileManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpProject
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
private void setUpProject( File pomFile, AbstractMojo mojo )
throws Exception
{
MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
ArtifactRepositoryFactory artifactRepositoryFactory =
(ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, "never", "never" );
String localRepoUrl = "file://" + System.getProperty( "user.home" ) + "/.m2/repository";
ArtifactRepository localRepository =
artifactRepositoryFactory.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(),
policy, policy );
ProfileManager profileManager = new DefaultProfileManager( getContainer() );
MavenProject project = projectBuilder.buildWithDependencies( pomFile, localRepository, profileManager );
//this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test
project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() );
setVariableValueToObject( mojo, "project", project );
}
示例2: findEffectiveReactor
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
/**
* Manually constructs an list of effective reactor projects by recursively
* searching parent and submodule projects. This allows the intention of the
* reactor to be preserved, as long as it is fully available on disk, even
* when building a submodule directly.
*
* @param defaultReactor Return value to use if a comprehensive list can not
* be discovered.
* @param baseProject {@link MavenProject} where invocation started.
* @return A list of MavenProjects that can be treated as though within the
* current reactor.
* @throws ProjectBuildingException
*/
public static List<MavenProject> findEffectiveReactor(
final List<MavenProject> defaultReactor, final MavenSession session,
final MavenProject baseProject, final MavenProjectBuilder projectBuilder,
final ArtifactRepository localRepository) throws ProjectBuildingException
{
final Set<MavenProject> reactor = new HashSet<MavenProject>();
final Set<MavenProject> visited = new HashSet<MavenProject>();
final ProfileManager profileManager = getProfileManager(session);
findEffectiveReactor(reactor, visited, baseProject, baseProject,
projectBuilder, localRepository, profileManager);
if (reactor.size() <= 1 || !reactor.contains(baseProject)) return defaultReactor;
return new ArrayList<MavenProject>(reactor);
}
示例3: buildWithDependencies
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
public MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository,
ProfileManager profileManager, TransferListener transferListener )
throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException
{
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration();
configuration.setLocalRepository( localRepository );
configuration.setGlobalProfileManager( profileManager );
ProjectBuildingRequest request = injectSession( toRequest( configuration ) );
request.setResolveDependencies( true );
try
{
return projectBuilder.build( pom, request ).getProject();
}
catch ( ProjectBuildingException e )
{
throw transformError( e );
}
}
示例4: getLocalRoot
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
/**
* Finds the local root of the specified project.
*
* @param project The project to find the local root for.
* @param localRepository the local repo.
* @param globalProfileManager the global profile manager.
* @param logger The logger to log to.
* @return The local root (note this may be the project passed as an argument).
*/
public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProject project,
ArtifactRepository localRepository, ProfileManager globalProfileManager,
Log logger )
{
logger.info( "Searching for local aggregator root..." );
while ( true )
{
final File parentDir = project.getBasedir().getParentFile();
if ( parentDir != null && parentDir.isDirectory() )
{
logger.debug( "Checking to see if " + parentDir + " is an aggregator parent" );
File parent = new File( parentDir, "pom.xml" );
if ( parent.isFile() )
{
try
{
final MavenProject parentProject =
builder.build( parent, localRepository, globalProfileManager );
if ( getAllChildModules( parentProject, logger ).contains( project.getBasedir().getName() ) )
{
logger.debug( parentDir + " is an aggregator parent" );
project = parentProject;
continue;
}
else
{
logger.debug( parentDir + " is not an aggregator parent" );
}
}
catch ( ProjectBuildingException e )
{
logger.warn( e );
}
}
}
logger.debug( "Local aggregation root is " + project.getBasedir() );
return project;
}
}
示例5: getLocalRoot
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
/**
* Finds the local root of the specified project.
*
* @param project The project to find the local root for.
* @param localRepository the local repo.
* @param globalProfileManager the global profile manager.
* @param logger The logger to log to.
* @return The local root (note this may be the project passed as an argument).
*/
public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProject project,
ArtifactRepository localRepository, ProfileManager globalProfileManager,
Log logger )
{
logger.info( "Searching for local aggregator root..." );
while ( true )
{
final File parentDir = project.getBasedir().getParentFile();
if ( parentDir.isDirectory() )
{
logger.debug( "Checking to see if " + parentDir + " is an aggregator parent" );
File parent = new File( parentDir, "pom.xml" );
if ( parent.isFile() )
{
try
{
final MavenProject parentProject =
builder.build( parent, localRepository, globalProfileManager );
if ( getAllChildModules( parentProject, logger ).contains( project.getBasedir().getName() ) )
{
logger.debug( parentDir + " is an aggregator parent" );
project = parentProject;
continue;
}
else
{
logger.debug( parentDir + " is not an aggregator parent" );
}
}
catch ( ProjectBuildingException e )
{
logger.warn( e );
}
}
}
logger.debug( "Local aggregation root is " + project.getBasedir() );
return project;
}
}
示例6: getProfileManager
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
/**
* Convenience method to get the {@link ProfileManager} for a given
* {@link MavenSession}.
*/
@SuppressWarnings("deprecation")
private static ProfileManager getProfileManager(final MavenSession session) {
final PlexusContainer container = session.getContainer();
final Properties execution = session.getExecutionProperties();
return new DefaultProfileManager(container, execution);
}
示例7: build
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
public MavenProject build( File pom, ArtifactRepository localRepository, ProfileManager profileManager )
throws ProjectBuildingException
{
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration();
configuration.setLocalRepository( localRepository );
configuration.setGlobalProfileManager( profileManager );
return build( pom, configuration );
}
示例8: buildStandaloneSuperProject
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager )
throws ProjectBuildingException
{
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration();
configuration.setLocalRepository( localRepository );
configuration.setGlobalProfileManager( profileManager );
return buildStandaloneSuperProject( configuration );
}
示例9: resolveProject
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
@NotNull
public MavenExecutionResult resolveProject(@NotNull final File file,
@NotNull final List<String> activeProfiles,
@NotNull final List<String> inactiveProfiles,
List<ResolutionListener> listeners) {
MavenExecutionRequest request = createRequest(file, activeProfiles, inactiveProfiles, Collections.<String>emptyList());
ProjectBuilderConfiguration config = request.getProjectBuilderConfiguration();
request.getGlobalProfileManager().loadSettingsProfiles(mySettings);
ProfileManager globalProfileManager = request.getGlobalProfileManager();
globalProfileManager.loadSettingsProfiles(request.getSettings());
List<Exception> exceptions = new ArrayList<Exception>();
MavenProject project = null;
try {
// copied from DefaultMavenProjectBuilder.buildWithDependencies
MavenProjectBuilder builder = getComponent(MavenProjectBuilder.class);
project = builder.build(new File(file.getPath()), config);
builder.calculateConcreteState(project, config, false);
// copied from DefaultLifecycleExecutor.execute
findExtensions(project);
// end copied from DefaultLifecycleExecutor.execute
Artifact projectArtifact = project.getArtifact();
Map managedVersions = project.getManagedVersionMap();
ArtifactMetadataSource metadataSource = getComponent(ArtifactMetadataSource.class);
project.setDependencyArtifacts(project.createArtifacts(getComponent(ArtifactFactory.class), null, null));
ArtifactResolver resolver = getComponent(ArtifactResolver.class);
ArtifactResolutionResult result = resolver
.resolveTransitively(project.getDependencyArtifacts(), projectArtifact, managedVersions, myLocalRepository,
project.getRemoteArtifactRepositories(), metadataSource, null, listeners);
project.setArtifacts(result.getArtifacts());
// end copied from DefaultMavenProjectBuilder.buildWithDependencies
}
catch (Exception e) {
return handleException(e);
}
return new MavenExecutionResult(project, exceptions);
}
示例10: createProfileManager
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
private ProfileManager createProfileManager(List<String> activeProfiles, List<String> inactiveProfiles, Properties executionProperties) {
ProfileManager profileManager = new DefaultProfileManager(getContainer(), executionProperties);
profileManager.explicitlyActivate(activeProfiles);
profileManager.explicitlyDeactivate(inactiveProfiles);
return profileManager;
}
示例11: getProfileManager
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
private ProfileManager getProfileManager() throws Exception {
return (ProfileManager) ReflectionUtils.getDeclaredFieldValue(embedder, "profileManager");
}
示例12: resolveProject
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
@NotNull
public MavenExecutionResult resolveProject(@NotNull final File file,
@NotNull final List<String> activeProfiles,
List<ResolutionListener> listeners) {
MavenExecutionRequest request = createRequest(file, activeProfiles, Collections.<String>emptyList(), Collections.<String>emptyList());
ProjectBuilderConfiguration config = request.getProjectBuilderConfiguration();
request.getGlobalProfileManager().loadSettingsProfiles(mySettings);
ProfileManager globalProfileManager = request.getGlobalProfileManager();
globalProfileManager.loadSettingsProfiles(request.getSettings());
List<Exception> exceptions = new ArrayList<Exception>();
MavenProject project = null;
try {
// copied from DefaultMavenProjectBuilder.buildWithDependencies
MavenProjectBuilder builder = getComponent(MavenProjectBuilder.class);
project = builder.build(new File(file.getPath()), config);
builder.calculateConcreteState(project, config, false);
// copied from DefaultLifecycleExecutor.execute
findExtensions(project);
// end copied from DefaultLifecycleExecutor.execute
Artifact projectArtifact = project.getArtifact();
Map managedVersions = project.getManagedVersionMap();
ArtifactMetadataSource metadataSource = getComponent(ArtifactMetadataSource.class);
project.setDependencyArtifacts(project.createArtifacts(getComponent(ArtifactFactory.class), null, null));
ArtifactResolver resolver = getComponent(ArtifactResolver.class);
ArtifactResolutionResult result = resolver
.resolveTransitively(project.getDependencyArtifacts(), projectArtifact, managedVersions, myLocalRepository,
project.getRemoteArtifactRepositories(), metadataSource, null, listeners);
project.setArtifacts(result.getArtifacts());
// end copied from DefaultMavenProjectBuilder.buildWithDependencies
}
catch (Exception e) {
return handleException(e);
}
return new MavenExecutionResult(project, exceptions);
}
示例13: toRequest
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
private ProjectBuildingRequest toRequest( ProjectBuilderConfiguration configuration )
{
DefaultProjectBuildingRequest request = new DefaultProjectBuildingRequest();
request.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 );
request.setResolveDependencies( false );
request.setLocalRepository( configuration.getLocalRepository() );
request.setBuildStartTime( configuration.getBuildStartTime() );
request.setUserProperties( configuration.getUserProperties() );
request.setSystemProperties( configuration.getExecutionProperties() );
ProfileManager profileManager = configuration.getGlobalProfileManager();
if ( profileManager != null )
{
request.setActiveProfileIds( profileManager.getExplicitlyActivatedIds() );
request.setInactiveProfileIds( profileManager.getExplicitlyDeactivatedIds() );
}
else
{
/*
* MNG-4900: Hack to workaround deficiency of legacy API which makes it impossible for plugins to access the
* global profile manager which is required to build a POM like a CLI invocation does. Failure to consider
* the activated profiles can cause repo declarations to be lost which in turn will result in artifact
* resolution failures, in particular when using the enhanced local repo which guards access to local files
* based on the configured remote repos.
*/
MavenSession session = legacySupport.getSession();
if ( session != null )
{
MavenExecutionRequest req = session.getRequest();
if ( req != null )
{
request.setActiveProfileIds( req.getActiveProfiles() );
request.setInactiveProfileIds( req.getInactiveProfiles() );
}
}
}
return request;
}
示例14: build
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
MavenProject build( File pom, ArtifactRepository localRepository, ProfileManager profileManager )
throws ProjectBuildingException;
示例15: buildStandaloneSuperProject
import org.apache.maven.profiles.ProfileManager; //导入依赖的package包/类
MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager )
throws ProjectBuildingException;