本文整理了Java中org.apache.maven.plugin.MojoExecution
类的一些代码示例,展示了MojoExecution
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MojoExecution
类的具体详情如下:
包路径:org.apache.maven.plugin.MojoExecution
类名称:MojoExecution
[英]MojoExecution
[中]莫约处决
代码示例来源:origin: apache/maven
private void append( MessageBuilder buffer, MojoExecution me )
{
buffer.mojo( me.getArtifactId() + ':' + me.getVersion() + ':' + me.getGoal() );
if ( me.getExecutionId() != null )
{
buffer.a( ' ' ).strong( '(' + me.getExecutionId() + ')' );
}
}
代码示例来源:origin: apache/maven
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
value = session.getLocalRepository();
value = session.getProjects();
value = project.getExecutionProject();
value = session.getRepositorySession();
value = mojoDescriptor.getPluginDescriptor();
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
if ( ( value == null ) && ( ( project != null ) && ( project.getProperties() != null ) ) )
value = project.getProperties().getProperty( expression );
代码示例来源:origin: apache/maven
for ( Plugin plugin : project.getBuild().getPlugins() )
MojoExecution mojoExecution = new MojoExecution( plugin, goal, execution.getId() );
mojoExecution.setLifecyclePhase( execution.getPhase() );
addMojoExecution( phaseBindings, mojoExecution, execution.getPriority() );
pluginManager.getMojoDescriptor( plugin, goal, project.getRemotePluginRepositories(),
session.getRepositorySession() );
Map<Integer, List<MojoExecution>> phaseBindings = mappings.get( mojoDescriptor.getPhase() );
if ( phaseBindings != null )
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, execution.getId() );
mojoExecution.setLifecyclePhase( mojoDescriptor.getPhase() );
addMojoExecution( phaseBindings, mojoExecution, execution.getPriority() );
代码示例来源:origin: apache/maven
private static String constructMessage( MojoExecution mojoExecution, Throwable cause )
{
String message;
if ( mojoExecution != null )
{
message =
"Execution " + mojoExecution.getExecutionId() + " of goal " + mojoExecution.getMojoDescriptor().getId()
+ " failed";
}
else
{
message = "Mojo execution failed";
}
if ( cause != null && StringUtils.isNotEmpty( cause.getMessage() ) )
{
message += ": " + cause.getMessage();
}
else
{
message += ".";
}
return message;
}
代码示例来源:origin: apache/maven
/**
* Get set of plugins having a goal/mojo used but not marked @threadSafe
*
* @return the set of plugins (without info on which goal is concerned)
*/
public Set<Plugin> getNonThreadSafePlugins()
{
Set<Plugin> plugins = new HashSet<>();
for ( ExecutionPlanItem executionPlanItem : planItem )
{
final MojoExecution mojoExecution = executionPlanItem.getMojoExecution();
if ( !mojoExecution.getMojoDescriptor().isThreadSafe() )
{
plugins.add( mojoExecution.getPlugin() );
}
}
return plugins;
}
代码示例来源:origin: org.apache.maven.plugin-tools/maven-script-ant
private void unpackFileBasedResources()
throws MojoExecutionException
{
if ( mojoExecution == null || mavenProject == null )
{
unconstructedParts.add( "Unpacked Ant build scripts (in Maven build directory)." );
return;
}
// What we need to write out any resources in the plugin to the target directory of the
// mavenProject using the Ant-based plugin:
//
// 1. Need a reference to the plugin JAR itself
// 2. Need a reference to the ${basedir} of the mavenProject
PluginDescriptor pluginDescriptor = mojoExecution.getMojoDescriptor().getPluginDescriptor();
File pluginJar = pluginDescriptor.getPluginArtifact().getFile();
String resourcesPath = pluginDescriptor.getArtifactId();
File outputDirectory = new File( mavenProject.getBuild().getDirectory() );
try
{
UnArchiver ua = new ZipUnArchiver( pluginJar );
ua.extract( resourcesPath, outputDirectory );
}
catch ( ArchiverException e )
{
throw new MojoExecutionException( "Error extracting resources from your Ant-based plugin.", e );
}
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-incremental
/**
* We use a specific status directory for each Mojo execution to store state
* which is needed during the next build invocation run.
* @return the directory for storing status information of the current Mojo execution.
*/
public File getMojoStatusDirectory()
throws MojoExecutionException
{
if ( mojoExecution == null )
{
throw new MojoExecutionException( "MojoExecution could not get resolved" );
}
File buildOutputDirectory = new File( mavenProject.getBuild().getDirectory() );
//X TODO the executionId contains -cli and -mojoname
//X we should remove those postfixes as it should not make
//X any difference whether being run on the cli or via build
String mojoStatusPath = MAVEN_STATUS_ROOT + File.separator
+ mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() + File.separator
+ mojoExecution.getMojoDescriptor().getGoal() + File.separator
+ mojoExecution.getExecutionId();
File mojoStatusDir = new File( buildOutputDirectory, mojoStatusPath );
if ( !mojoStatusDir.exists() )
{
mojoStatusDir.mkdirs();
}
return mojoStatusDir;
}
代码示例来源:origin: protostuff/protostuff-compiler
String computeSourceOutputDir(@Nullable File target) {
String output;
if (target != null) {
output = target.getAbsolutePath();
} else {
String phase = execution.getLifecyclePhase();
String buildDirectory = project.getBuild().getDirectory();
if (GENERATE_TEST_SOURCES.id().equals(phase)) {
output = buildDirectory + GENERATED_TEST_SOURCES;
} else {
output = buildDirectory + GENERATED_SOURCES;
}
}
LOGGER.debug("output = {}", output);
return output;
}
代码示例来源:origin: protostuff/protostuff
if (GENERATE_TEST_SOURCES_PHASE.equals(execution.getLifecyclePhase()))
project.addTestCompileSourceRoot(m.getOutputDir().getAbsolutePath());
project.addCompileSourceRoot(m.getOutputDir().getAbsolutePath());
if (GENERATE_TEST_SOURCES_PHASE.equals(execution.getLifecyclePhase()))
project.addTestCompileSourceRoot(m.getOutputDir().getAbsolutePath());
代码示例来源:origin: protostuff/protostuff-compiler
Path getSourcePath() {
if (source != null) {
return source.toPath();
}
String phase = execution.getLifecyclePhase();
String basedir;
basedir = getCanonicalPath(project.getBasedir());
String sourcePath;
if (GENERATE_TEST_SOURCES.id().equals(phase)) {
sourcePath = basedir + "/src/test/proto/";
} else {
sourcePath = basedir + "/src/main/proto/";
}
return Paths.get(sourcePath);
}
代码示例来源:origin: com.google.appengine/gcloud-maven-plugin
plugin.setVersion(DATANUCLEUS_VERSION);
plugin.addDependency(enhancer_api.equals("JDO") ? JDO_DEPENDENCY : JPA_DEPENDENCY);
for (Dependency transitiveDep : project.getDependencies()) {
plugin.addDependency(transitiveDep);
project.getRemotePluginRepositories(),
session.getRepositorySession());
} catch (PluginNotFoundException | PluginResolutionException | PluginDescriptorParsingException
| InvalidPluginDescriptorException e) {
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("enhance");
convertPlexusConfiguration(mojoDescriptor.getMojoConfiguration()));
MojoExecution exec = new MojoExecution(mojoDescriptor, configuration);
代码示例来源:origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness
throws Exception, ComponentConfigurationException
MavenProject project = session.getCurrentProject();
MojoDescriptor mojoDescriptor = execution.getMojoDescriptor();
Mojo mojo = (Mojo) lookup( mojoDescriptor.getRole(), mojoDescriptor.getRoleHint() );
Plugin plugin = project.getPlugin( mojoDescriptor.getPluginDescriptor().getPluginLookupKey() );
if ( plugin != null )
configuration = Xpp3Dom.mergeXpp3Dom( configuration, execution.getConfiguration() );
代码示例来源:origin: apache/maven
throws LifecycleExecutionException
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
mavenPluginManager.checkRequiredMavenVersion( mojoDescriptor.getPluginDescriptor() );
throw new LifecycleExecutionException( mojoExecution, session.getCurrentProject(), e );
if ( mojoDescriptor.isProjectRequired() && !session.getRequest().isProjectPresent() )
+ session.getExecutionRootDirectory() + ")."
+ " Please verify you invoked Maven from the correct directory." );
throw new LifecycleExecutionException( mojoExecution, null, cause );
if ( mojoDescriptor.isOnlineRequired() && session.isOffline() )
if ( MojoExecution.Source.CLI.equals( mojoExecution.getSource() ) )
forkedProject.setExecutionProject( null );
代码示例来源:origin: apache/maven
public <T> T getConfiguredMojo( Class<T> mojoInterface, MavenSession session, MojoExecution mojoExecution )
throws PluginConfigurationException, PluginContainerException
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
ClassRealm pluginRealm = pluginDescriptor.getClassRealm();
logger.debug( "Configuring mojo " + mojoDescriptor.getId() + " from plugin realm " + pluginRealm );
mojo = container.lookup( mojoInterface, mojoDescriptor.getRoleHint() );
PrintStream ps = new PrintStream( os );
ps.println( "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' in the plugin '"
+ pluginDescriptor.getId() + "'. A required class is missing: "
+ cause.getMessage() );
pluginRealm.display( ps );
MavenProject project = session.getCurrentProject();
Map<String, Object> pluginContext = session.getPluginContext( pluginDescriptor, project );
Xpp3Dom dom = mojoExecution.getConfiguration();
代码示例来源:origin: apache/maven
InvalidPluginDescriptorException, PluginVersionResolutionException
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
String forkedLifecycle = mojoDescriptor.getExecuteLifecycle();
lifecycleOverlay = pluginDescriptor.getLifecycleMapping( forkedLifecycle );
throw new PluginDescriptorParsingException( pluginDescriptor.getPlugin(), pluginDescriptor.getSource(), e );
new MojoExecution( forkedMojoDescriptor, mojoExecution.getExecutionId() );
forkedExecution.setConfiguration( forkedConfiguration );
Xpp3Dom forkedConfiguration = forkedExecution.getConfiguration();
forkedExecution.setConfiguration( forkedConfiguration );
代码示例来源:origin: apache/maven
private void debugMojoExecution( MojoExecution mojoExecution )
{
String mojoExecId =
mojoExecution.getGroupId() + ':' + mojoExecution.getArtifactId() + ':' + mojoExecution.getVersion() + ':'
+ mojoExecution.getGoal() + " (" + mojoExecution.getExecutionId() + ')';
Map<String, List<MojoExecution>> forkedExecutions = mojoExecution.getForkedExecutions();
if ( !forkedExecutions.isEmpty() )
{
for ( Map.Entry<String, List<MojoExecution>> fork : forkedExecutions.entrySet() )
{
logger.debug( "--- init fork of " + fork.getKey() + " for " + mojoExecId + " ---" );
debugDependencyRequirements( fork.getValue() );
for ( MojoExecution forkedExecution : fork.getValue() )
{
debugMojoExecution( forkedExecution );
}
logger.debug( "--- exit fork of " + fork.getKey() + " for " + mojoExecId + " ---" );
}
}
logger.debug( "-----------------------------------------------------------------------" );
logger.debug( "Goal: " + mojoExecId );
logger.debug(
"Style: " + ( mojoExecution.getMojoDescriptor().isAggregator() ? "Aggregating" : "Regular" ) );
logger.debug( "Configuration: " + mojoExecution.getConfiguration() );
}
代码示例来源:origin: apache/maven
@Override
public void configure( MavenProject project, MojoExecution mojoExecution, boolean allowPluginLevelConfig )
{
String g = mojoExecution.getGroupId();
String a = mojoExecution.getArtifactId();
Plugin plugin = findPlugin( g, a, project.getBuildPlugins() );
if ( plugin == null && project.getPluginManagement() != null )
{
plugin = findPlugin( g, a, project.getPluginManagement().getPlugins() );
}
if ( plugin != null )
{
PluginExecution pluginExecution =
findPluginExecution( mojoExecution.getExecutionId(), plugin.getExecutions() );
Xpp3Dom pomConfiguration = null;
if ( pluginExecution != null )
{
pomConfiguration = (Xpp3Dom) pluginExecution.getConfiguration();
}
else if ( allowPluginLevelConfig )
{
pomConfiguration = (Xpp3Dom) plugin.getConfiguration();
}
Xpp3Dom mojoConfiguration = ( pomConfiguration != null ) ? new Xpp3Dom( pomConfiguration ) : null;
mojoConfiguration = Xpp3Dom.mergeXpp3Dom( mojoExecution.getConfiguration(), mojoConfiguration );
mojoExecution.setConfiguration( mojoConfiguration );
}
}
代码示例来源:origin: jenkinsci/maven-plugin
private String mojoExec(ExecutionEvent event) {
MojoExecution me = event.getMojoExecution();
return String.format("%s:%s:%s(%s)", me.getGroupId(), me.getArtifactId(), me.getVersion(), me.getExecutionId());
}
}
代码示例来源:origin: io.takari/incrementalbuild
/**
* Returns conventional MojoExecution identifier used by incremental build tools.
*/
public String getExecutionId(MojoExecution execution) {
PluginDescriptor pluginDescriptor = execution.getMojoDescriptor().getPluginDescriptor();
StringBuilder builderId = new StringBuilder();
builderId.append(pluginDescriptor.getGroupId()).append('_')
.append(pluginDescriptor.getArtifactId());
builderId.append('_').append(execution.getGoal()).append('_')
.append(execution.getExecutionId());
return builderId.toString();
}
代码示例来源:origin: apache/maven
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
String forkedPhase = mojoDescriptor.getExecutePhase();
if ( forkedExecution.getMojoDescriptor() == null )
pluginManager.getMojoDescriptor( forkedExecution.getPlugin(), forkedExecution.getGoal(),
project.getRemotePluginRepositories(),
session.getRepositorySession() );
forkedExecution.setMojoDescriptor( forkedMojoDescriptor );
if ( !alreadyForkedExecutions.contains( forkedExecution.getMojoDescriptor() ) )
内容来源于网络,如有侵权,请联系作者删除!