本文整理匯總了Java中org.apache.maven.execution.MavenSession.getCurrentProject方法的典型用法代碼示例。如果您正苦於以下問題:Java MavenSession.getCurrentProject方法的具體用法?Java MavenSession.getCurrentProject怎麽用?Java MavenSession.getCurrentProject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.execution.MavenSession
的用法示例。
在下文中一共展示了MavenSession.getCurrentProject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DefaultPluginPrefixRequest
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
/**
* Creates a request for the specified plugin prefix and build session. The provided build session will be used to
* configure repository settings. If the session has a current project, its plugin repositories and model will be
* used as well.
*
* @param prefix The plugin prefix to resolve, must not be {@code null}.
* @param session The build session from which to derive further settings, must not be {@code null}.
*/
public DefaultPluginPrefixRequest( String prefix, MavenSession session )
{
setPrefix( prefix );
setRepositorySession( session.getRepositorySession() );
MavenProject project = session.getCurrentProject();
if ( project != null )
{
setRepositories( project.getRemotePluginRepositories() );
setPom( project.getModel() );
}
setPluginGroups( session.getPluginGroups() );
}
示例2: retrieveContext
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
Map<String, Object> retrieveContext( MavenSession session )
{
Map<String, Object> context = null;
if ( session != null )
{
PluginDescriptor desc = new PluginDescriptor();
desc.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
desc.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( "toolchains" ) );
MavenProject current = session.getCurrentProject();
if ( current != null )
{
//TODO: why is this using the context
context = session.getPluginContext( desc, current );
}
}
return ( context != null ) ? context : new HashMap<String, Object>();
}
示例3: testSystemScopeDependencyIsPresentInTheCompileClasspathElements
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements()
throws Exception
{
File pom = getProject( "it0063" );
Properties eps = new Properties();
eps.setProperty( "jre.home", new File( pom.getParentFile(), "jdk/jre" ).getPath() );
MavenSession session = createMavenSession( pom, eps );
MavenProject project = session.getCurrentProject();
// Here we will actually not have any artifacts because the ProjectDependenciesResolver is not involved here. So
// right now it's not valid to ask for artifacts unless plugins require the artifacts.
project.getCompileClasspathElements();
}
示例4: testSystemScopeDependencyIsPresentInTheCompileClasspathElements
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements()
throws Exception
{
File pom = getProject( "it0063" );
Properties eps = new Properties();
eps.setProperty( "jre.home", new File( pom.getParentFile(), "jdk/jre" ).getPath() );
MavenSession session = createMavenSession( pom, eps );
MavenProject project = session.getCurrentProject();
project.setArtifacts( resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ) );
List<String> elements = project.getCompileClasspathElements();
assertEquals( 2, elements.size() );
@SuppressWarnings( "deprecation" )
List<Artifact> artifacts = project.getCompileArtifacts();
assertEquals( 1, artifacts.size() );
assertTrue( artifacts.get( 0 ).getFile().getName().endsWith( "tools.jar" ) );
}
示例5: invokePITest
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
private void invokePITest() {
MavenEnvironment theEnvironment = MavenEnvironment.get();
MavenSession theSession = theEnvironment.getMavenSession();
for (MavenProject theProject : theSession.getAllProjects()) {
MavenProject theOldProject = theSession.getCurrentProject();
log.info("Invoking PITest for {}:{}", theProject.getGroupId(), theProject.getArtifact());
theSession.setCurrentProject(theProject);
String theCurrentVersion = getClass().getPackage().getImplementationVersion();
List<Dependency> theDependencies = new ArrayList<>();
theDependencies.add(dependency("de.mirkosertic.mavensonarsputnik", "pitest-plugins", theCurrentVersion));
try {
executeMojo(
plugin(
groupId("org.pitest"),
artifactId("pitest-maven"),
version(properties.getProperty("pitest.pluginversion")),
theDependencies
),
goal(properties.getProperty("pitest.pluginGoal")),
createConfiguration(),
executionEnvironment(
theProject,
theEnvironment.getMavenSession(),
theEnvironment.getBuildPluginManager()
)
);
} catch (Exception e) {
log.warn("Error invoking PITest, but analysis will continue", e);
} finally {
theSession.setCurrentProject(theOldProject);
}
}
}
示例6: afterProjectsRead
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
MavenProject project = session.getCurrentProject();
SourceFoldersUtils.addSourceFolders(project);
addPluginExecutions(project);
logger.info("Maven builder extension initialized");
}
示例7: newDependencyContext
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public DependencyContext newDependencyContext( MavenSession session, List<MojoExecution> mojoExecutions )
{
Set<String> scopesToCollect = new TreeSet<String>();
Set<String> scopesToResolve = new TreeSet<String>();
collectDependencyRequirements( scopesToResolve, scopesToCollect, mojoExecutions );
return new DependencyContext( session.getCurrentProject(), scopesToCollect, scopesToResolve );
}
示例8: execute
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
throws LifecycleExecutionException
{
DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions );
PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() );
for ( MojoExecution mojoExecution : mojoExecutions )
{
execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder );
}
}
示例9: findPluginForPrefix
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public Plugin findPluginForPrefix( String prefix, MavenSession session )
throws NoPluginFoundForPrefixException
{
// [prefix]:[goal]
if ( session.getCurrentProject() != null )
{
try
{
lifecyclePluginResolver.resolveMissingPluginVersions( session.getCurrentProject(), session );
}
catch ( PluginVersionResolutionException e )
{
// not critical here
logger.debug( e.getMessage(), e );
}
}
PluginPrefixRequest prefixRequest = new DefaultPluginPrefixRequest( prefix, session );
PluginPrefixResult prefixResult = pluginPrefixResolver.resolve( prefixRequest );
Plugin plugin = new Plugin();
plugin.setGroupId( prefixResult.getGroupId() );
plugin.setArtifactId( prefixResult.getArtifactId() );
return plugin;
}
示例10: DefaultPluginVersionRequest
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
/**
* Creates a request for the specified plugin by copying settings from the specified build session. If the session
* has a current project, its plugin repositories will be used as well.
*
* @param plugin The plugin for which to resolve a version, must not be {@code null}.
* @param repositoryRequest The repository request to copy from, must not be {@code null}.
*/
public DefaultPluginVersionRequest( Plugin plugin, MavenSession session )
{
setGroupId( plugin.getGroupId() );
setArtifactId( plugin.getArtifactId() );
setRepositorySession( session.getRepositorySession() );
MavenProject project = session.getCurrentProject();
if ( project != null )
{
setRepositories( project.getRemotePluginRepositories() );
}
}
示例11: setupPluginRealm
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public synchronized void setupPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session,
ClassLoader parent, List<String> imports, DependencyFilter filter )
throws PluginResolutionException, PluginContainerException
{
Plugin plugin = pluginDescriptor.getPlugin();
MavenProject project = session.getCurrentProject();
Map<String, ClassLoader> foreignImports = calcImports( project, parent, imports );
PluginRealmCache.Key cacheKey =
pluginRealmCache.createKey( plugin, parent, foreignImports, filter, project.getRemotePluginRepositories(),
session.getRepositorySession() );
PluginRealmCache.CacheRecord cacheRecord = pluginRealmCache.get( cacheKey );
if ( cacheRecord != null )
{
pluginDescriptor.setClassRealm( cacheRecord.realm );
pluginDescriptor.setArtifacts( new ArrayList<Artifact>( cacheRecord.artifacts ) );
for ( ComponentDescriptor<?> componentDescriptor : pluginDescriptor.getComponents() )
{
componentDescriptor.setRealm( cacheRecord.realm );
}
}
else
{
createPluginRealm( pluginDescriptor, session, parent, foreignImports, filter );
cacheRecord =
pluginRealmCache.put( cacheKey, pluginDescriptor.getClassRealm(), pluginDescriptor.getArtifacts() );
}
pluginRealmCache.register( project, cacheRecord );
}
示例12: PluginParameterExpressionEvaluator
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public PluginParameterExpressionEvaluator( MavenSession session, MojoExecution mojoExecution )
{
this.session = session;
this.mojoExecution = mojoExecution;
this.properties = session.getExecutionProperties();
this.project = session.getCurrentProject();
String basedir = null;
if ( project != null )
{
File projectFile = project.getBasedir();
// this should always be the case for non-super POM instances...
if ( projectFile != null )
{
basedir = projectFile.getAbsolutePath();
}
}
if ( ( basedir == null ) && ( session != null ) )
{
basedir = session.getExecutionRootDirectory();
}
if ( basedir == null )
{
basedir = System.getProperty( "user.dir" );
}
this.basedir = basedir;
}
示例13: testSystemScopeDependencies
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public void testSystemScopeDependencies()
throws Exception
{
MavenSession session = createMavenSession( null );
MavenProject project = session.getCurrentProject();
new ProjectBuilder( project )
.addDependency( "com.mycompany", "system-dependency", "1.0", Artifact.SCOPE_SYSTEM, new File( getBasedir(), "pom.xml" ).getAbsolutePath() );
Set<Artifact> artifactDependencies =
resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session );
assertEquals( 1, artifactDependencies.size() );
}
示例14: getMavenProject
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
/** Load the Maven project for the given artifact.
*
* @param artifact the artifact.
* @return the maven project.
*/
public MavenProject getMavenProject(Artifact artifact) {
try {
final MavenSession session = getMavenSession();
final MavenProject current = session.getCurrentProject();
final MavenProject prj = getMavenProjectBuilder().buildFromRepository(
artifact,
current.getRemoteArtifactRepositories(),
session.getLocalRepository());
return prj;
} catch (ProjectBuildingException e) {
getLog().warn(e);
}
return null;
}
示例15: HibernateExpressionEvaluator
import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public HibernateExpressionEvaluator( MavenSession session )
{
super( session, new MojoExecution( new MojoDescriptor() ), new DefaultPathTranslator(), null,
session.getCurrentProject(), session.getExecutionProperties() );
}