本文整理汇总了Java中org.apache.maven.lifecycle.LifecycleExecutionException类的典型用法代码示例。如果您正苦于以下问题:Java LifecycleExecutionException类的具体用法?Java LifecycleExecutionException怎么用?Java LifecycleExecutionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LifecycleExecutionException类属于org.apache.maven.lifecycle包,在下文中一共展示了LifecycleExecutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildExecutionPlanItem
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
private void buildExecutionPlanItem( ExecutionPlanItem current, PhaseRecorder phaseRecorder, Schedule schedule,
ReactorContext reactorContext, ProjectSegment projectBuild,
DependencyContext dependencyContext )
throws LifecycleExecutionException
{
if ( schedule != null && schedule.isMojoSynchronized() )
{
synchronized ( current.getPlugin() )
{
buildExecutionPlanItem( reactorContext, current, projectBuild, dependencyContext, phaseRecorder );
}
}
else
{
buildExecutionPlanItem( reactorContext, current, projectBuild, dependencyContext, phaseRecorder );
}
}
示例2: assertNotSrcdeps
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
private static void assertNotSrcdeps(String group, String artifact, String version, String[] violation)
throws LifecycleExecutionException {
if (SrcVersion.isSrcVersion(version)) {
throw new LifecycleExecutionException(String.format(
"This build was configured to fail if there is a source dependency [%s:%s:%s] and %s [%s]", group,
artifact, version, violation[0], violation[1]));
}
}
示例3: getLifecycleForPhase
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
/**
* Gets the lifecycle for phase.
*
* @param lifecycles The list of lifecycles.
* @param phase the phase
* @return the lifecycle for phase
* @throws BuildFailureException the build failure exception
* @throws LifecycleExecutionException the lifecycle execution exception
*/
private Lifecycle getLifecycleForPhase( List lifecycles, String phase )
throws BuildFailureException, LifecycleExecutionException
{
Lifecycle lifecycle = (Lifecycle) getPhaseToLifecycleMap( lifecycles ).get( phase );
if ( lifecycle == null )
{
throw new BuildFailureException( "Unable to find lifecycle for phase '" + phase + "'" );
}
return lifecycle;
}
示例4: getPhaseToLifecycleMap
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
/**
* Gets the phase to lifecycle map.
*
* @param lifecycles The list of lifecycles.
* @return the phase to lifecycle map.
* @throws LifecycleExecutionException the lifecycle execution exception.
*/
public Map getPhaseToLifecycleMap( List<Lifecycle> lifecycles )
throws LifecycleExecutionException
{
Map<String, Lifecycle> phaseToLifecycleMap = new HashMap();
for ( Iterator<Lifecycle> i = lifecycles.iterator(); i.hasNext(); )
{
Lifecycle lifecycle = i.next();
for ( Iterator<String> p = lifecycle.getPhases().iterator(); p.hasNext(); )
{
String phase = p.next();
if ( phaseToLifecycleMap.containsKey( phase ) )
{
Lifecycle prevLifecycle = phaseToLifecycleMap.get( phase );
throw new LifecycleExecutionException( "Phase '" + phase
+ "' is defined in more than one lifecycle: '" + lifecycle.getId() + "' and '"
+ prevLifecycle.getId() + "'" );
}
else
{
phaseToLifecycleMap.put( phase, lifecycle );
}
}
}
return phaseToLifecycleMap;
}
示例5: getLifecycleForPhase
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
/**
* Gets the lifecycle for phase.
*
* @param lifecycles The list of lifecycles.
* @param phase the phase
* @return the lifecycle for phase
* @throws BuildFailureException the build failure exception
* @throws LifecycleExecutionException the lifecycle execution exception
*/
private Lifecycle getLifecycleForPhase( List lifecycles, String phase )
throws BuildFailureException, LifecycleExecutionException
{
Lifecycle lifecycle = (Lifecycle) getPhaseToLifecycleMap( lifecycles ).get( phase );
if ( lifecycle == null )
{
throw new BuildFailureException( "Unable to find lifecycle for phase '" + phase + "'" );
}
return lifecycle;
}
示例6: getPhaseToLifecycleMap
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
/**
* Gets the phase to lifecycle map.
*
* @param lifecycles The list of lifecycles.
* @return the phase to lifecycle map.
* @throws LifecycleExecutionException the lifecycle execution exception.
*/
public Map getPhaseToLifecycleMap( List lifecycles )
throws LifecycleExecutionException
{
Map phaseToLifecycleMap = new HashMap();
for ( Iterator i = lifecycles.iterator(); i.hasNext(); )
{
Lifecycle lifecycle = (Lifecycle) i.next();
for ( Iterator p = lifecycle.getPhases().iterator(); p.hasNext(); )
{
String phase = (String) p.next();
if ( phaseToLifecycleMap.containsKey( phase ) )
{
Lifecycle prevLifecycle = (Lifecycle) phaseToLifecycleMap.get( phase );
throw new LifecycleExecutionException(
"Phase '" + phase + "' is defined in more than one lifecycle: '" + lifecycle.getId() +
"' and '" + prevLifecycle.getId() + "'" );
}
else
{
phaseToLifecycleMap.put( phase, lifecycle );
}
}
}
return phaseToLifecycleMap;
}
示例7: execute
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的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 );
}
}
示例8: execute
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
@Override
public void execute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex,
DependencyContext dependencyContext, PhaseRecorder phaseRecorder )
throws LifecycleExecutionException
{
executions.add( mojoExecution );
}
示例9: afterProjectExecutionSuccess
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
@Override
public void afterProjectExecutionSuccess(ProjectExecutionEvent event) throws LifecycleExecutionException {
}
示例10: beforeProjectExecution
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
@Override
public void beforeProjectExecution(ProjectExecutionEvent event) throws LifecycleExecutionException {
}
示例11: beforeProjectLifecycleExecution
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
@Override
public void beforeProjectLifecycleExecution(ProjectExecutionEvent event) throws LifecycleExecutionException {
final MavenProject project = event.getProject();
log.info("srcdeps enforcer checks for violations in {}:{}", project.getGroupId(), project.getArtifactId());
final Maven maven = configurationProducer.getConfiguration().getMaven();
final List<MojoExecution> mojoExecutions = event.getExecutionPlan();
final List<String> goals = new ArrayList<>(mojoExecutions.size());
for (MojoExecution mojoExecution : mojoExecutions) {
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
goals.add(mojoDescriptor.getFullGoalName());
goals.add(mojoDescriptor.getGoal());
}
final List<String> profiles = new ArrayList<>();
final List<Profile> activeProfiles = project.getActiveProfiles();
for (Profile profile : activeProfiles) {
final String id = profile.getId();
profiles.add(id);
}
final Properties props = new Properties();
props.putAll(project.getProperties());
props.putAll(System.getProperties());
String[] firstViolation = assertFailWithout(maven.getFailWithout(), goals, profiles, props);
if (firstViolation == null) {
firstViolation = assertFailWith(maven.getFailWith(), goals, profiles, props);
}
if (firstViolation != null) {
/* check if there are srcdeps */
Artifact parent = project.getParentArtifact();
if (parent != null) {
assertNotSrcdeps(parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), firstViolation);
}
DependencyManagement dm;
List<Dependency> deps;
if ((dm = project.getDependencyManagement()) != null && (deps = dm.getDependencies()) != null) {
assertNotSrcdeps(deps, firstViolation);
}
if ((deps = project.getDependencies()) != null) {
assertNotSrcdeps(deps, firstViolation);
}
}
}
示例12: execute
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
private int execute( CliRequest cliRequest )
{
eventSpyDispatcher.onEvent( cliRequest.request );
MavenExecutionResult result = maven.execute( cliRequest.request );
eventSpyDispatcher.onEvent( result );
eventSpyDispatcher.close();
if ( result.hasExceptions() )
{
ExceptionHandler handler = new DefaultExceptionHandler();
Map<String, String> references = new LinkedHashMap<String, String>();
MavenProject project = null;
for ( Throwable exception : result.getExceptions() )
{
ExceptionSummary summary = handler.handleException( exception );
logSummary( summary, references, "", cliRequest.showErrors );
if ( project == null && exception instanceof LifecycleExecutionException )
{
project = ( (LifecycleExecutionException) exception ).getProject();
}
}
slf4jLogger.error( "" );
if ( !cliRequest.showErrors )
{
slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the -e switch." );
}
if ( !slf4jLogger.isDebugEnabled() )
{
slf4jLogger.error( "Re-run Maven using the -X switch to enable full debug logging." );
}
if ( !references.isEmpty() )
{
slf4jLogger.error( "" );
slf4jLogger.error( "For more information about the errors and possible solutions"
+ ", please read the following articles:" );
for ( Map.Entry<String, String> entry : references.entrySet() )
{
slf4jLogger.error( entry.getValue() + " " + entry.getKey() );
}
}
if ( project != null && !project.equals( result.getTopologicallySortedProjects().get( 0 ) ) )
{
slf4jLogger.error( "" );
slf4jLogger.error( "After correcting the problems, you can resume the build with the command" );
slf4jLogger.error( " mvn <goals> -rf :" + project.getArtifactId() );
}
if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( cliRequest.request.getReactorFailureBehavior() ) )
{
slf4jLogger.info( "Build failures were ignored." );
return 0;
}
else
{
return 1;
}
}
else
{
return 0;
}
}
示例13: getDependencies
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
private Set<Artifact> getDependencies( MavenProject project, Collection<String> scopesToCollect,
Collection<String> scopesToResolve, MavenSession session,
boolean aggregating, Set<Artifact> projectArtifacts )
throws LifecycleExecutionException
{
if ( scopesToCollect == null )
{
scopesToCollect = Collections.emptySet();
}
if ( scopesToResolve == null )
{
scopesToResolve = Collections.emptySet();
}
if ( scopesToCollect.isEmpty() && scopesToResolve.isEmpty() )
{
return new LinkedHashSet<Artifact>();
}
scopesToCollect = new HashSet<String>( scopesToCollect );
scopesToCollect.addAll( scopesToResolve );
DependencyFilter collectionFilter = new ScopeDependencyFilter( null, negate( scopesToCollect ) );
DependencyFilter resolutionFilter = new ScopeDependencyFilter( null, negate( scopesToResolve ) );
resolutionFilter = AndDependencyFilter.newInstance( collectionFilter, resolutionFilter );
resolutionFilter =
AndDependencyFilter.newInstance( resolutionFilter, new ReactorDependencyFilter( projectArtifacts ) );
DependencyResolutionResult result;
try
{
DefaultDependencyResolutionRequest request =
new DefaultDependencyResolutionRequest( project, session.getRepositorySession() );
request.setResolutionFilter( resolutionFilter );
eventSpyDispatcher.onEvent( request );
result = dependenciesResolver.resolve( request );
}
catch ( DependencyResolutionException e )
{
result = e.getResult();
/*
* MNG-2277, the check below compensates for our bad plugin support where we ended up with aggregator
* plugins that require dependency resolution although they usually run in phases of the build where project
* artifacts haven't been assembled yet. The prime example of this is "mvn release:prepare".
*/
if ( aggregating && areAllDependenciesInReactor( session.getProjects(), result.getUnresolvedDependencies() ) )
{
logger.warn( "The following dependencies could not be resolved at this point of the build"
+ " but seem to be part of the reactor:" );
for ( Dependency dependency : result.getUnresolvedDependencies() )
{
logger.warn( "o " + dependency );
}
logger.warn( "Try running the build up to the lifecycle phase \"package\"" );
}
else
{
throw new LifecycleExecutionException( null, project, e );
}
}
eventSpyDispatcher.onEvent( result );
Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
if ( result.getDependencyGraph() != null && !result.getDependencyGraph().getChildren().isEmpty() )
{
RepositoryUtils.toArtifacts( artifacts, result.getDependencyGraph().getChildren(),
Collections.singletonList( project.getArtifact().getId() ), collectionFilter );
}
return artifacts;
}
示例14: resolveBuildPlan
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
public MavenExecutionPlan resolveBuildPlan( MavenSession session, MavenProject project, TaskSegment taskSegment,
Set<Artifact> projectArtifacts )
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException,
LifecycleExecutionException
{
MavenExecutionPlan executionPlan =
lifeCycleExecutionPlanCalculator.calculateExecutionPlan( session, project, taskSegment.getTasks() );
lifecycleDebugLogger.debugProjectPlan( project, executionPlan );
if ( session.getRequest().isThreadConfigurationPresent() )
{
final Set<Plugin> unsafePlugins = executionPlan.getNonThreadSafePlugins();
if ( !unsafePlugins.isEmpty() )
{
logger.warn( "*****************************************************************" );
logger.warn( "* Your build is requesting parallel execution, but project *" );
logger.warn( "* contains the following plugin(s) that have goals not marked *" );
logger.warn( "* as @threadSafe to support parallel building. *" );
logger.warn( "* While this /may/ work fine, please look for plugin updates *" );
logger.warn( "* and/or request plugins be made thread-safe. *" );
logger.warn( "* If reporting an issue, report it against the plugin in *" );
logger.warn( "* question, not against maven-core *" );
logger.warn( "*****************************************************************" );
if ( logger.isDebugEnabled() )
{
final Set<MojoDescriptor> unsafeGoals = executionPlan.getNonThreadSafeMojos();
logger.warn( "The following goals are not marked @threadSafe in " + project.getName() + ":" );
for ( MojoDescriptor unsafeGoal : unsafeGoals )
{
logger.warn( unsafeGoal.getId() );
}
}
else
{
logger.warn( "The following plugins are not marked @threadSafe in " + project.getName() + ":" );
for ( Plugin unsafePlugin : unsafePlugins )
{
logger.warn( unsafePlugin.getId() );
}
logger.warn( "Enable debug to see more precisely which goals are not marked @threadSafe." );
}
logger.warn( "*****************************************************************" );
}
}
return executionPlan;
}
示例15: getReference
import org.apache.maven.lifecycle.LifecycleExecutionException; //导入依赖的package包/类
private String getReference( Throwable exception )
{
String reference = "";
if ( exception != null )
{
if ( exception instanceof MojoExecutionException )
{
reference = MojoExecutionException.class.getSimpleName();
Throwable cause = exception.getCause();
if ( cause instanceof IOException )
{
cause = cause.getCause();
if ( cause instanceof ConnectException )
{
reference = ConnectException.class.getSimpleName();
}
}
}
else if ( exception instanceof MojoFailureException )
{
reference = MojoFailureException.class.getSimpleName();
}
else if ( exception instanceof LinkageError )
{
reference = LinkageError.class.getSimpleName();
}
else if ( exception instanceof PluginExecutionException )
{
reference = getReference( exception.getCause() );
if ( StringUtils.isEmpty( reference ) )
{
reference = exception.getClass().getSimpleName();
}
}
else if ( exception instanceof LifecycleExecutionException )
{
reference = getReference( exception.getCause() );
}
else if ( isNoteworthyException( exception ) )
{
reference = exception.getClass().getSimpleName();
}
}
if ( StringUtils.isNotEmpty( reference ) && !reference.startsWith( "http:" ) )
{
reference = "http://cwiki.apache.org/confluence/display/MAVEN/" + reference;
}
return reference;
}