本文整理汇总了Java中org.apache.maven.execution.MavenExecutionResult.getExceptions方法的典型用法代码示例。如果您正苦于以下问题:Java MavenExecutionResult.getExceptions方法的具体用法?Java MavenExecutionResult.getExceptions怎么用?Java MavenExecutionResult.getExceptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.execution.MavenExecutionResult
的用法示例。
在下文中一共展示了MavenExecutionResult.getExceptions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _handle
import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的package包/类
@Override
protected boolean _handle(MavenExecutionResult result) {
Xpp3Dom root = new Xpp3Dom("MavenExecutionResult");
root.setAttribute("class", result.getClass().getName());
for (MavenProject project : result.getTopologicallySortedProjects()) {
BuildSummary summary = result.getBuildSummary(project);
if (summary == null) {
Xpp3Dom comment = new Xpp3Dom("comment");
comment.setValue("No build summary found for maven project: " + project);
root.addChild(comment);
} else {
Xpp3Dom buildSummary = newElement("buildSummary", project);
root.addChild(buildSummary);
buildSummary.setAttribute("class", summary.getClass().getName());
buildSummary.setAttribute("time", Long.toString(summary.getTime()));
}
}
for(Throwable throwable: result.getExceptions()) {
root.addChild(newElement("exception", throwable));
}
reporter.print(root);
return true;
}
示例2: reportExceptions
import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的package包/类
@NbBundle.Messages({
"TXT_Artifact_Resolution_problem=Artifact Resolution problem",
"TXT_Artifact_Not_Found=Artifact Not Found",
"TXT_Cannot_Load_Project=Unable to properly load project",
"TXT_Cannot_read_model=Error reading project model",
"TXT_NoMsg=Exception thrown while loading maven project at {0}. See messages.log for more information."
})
private Collection<ProjectProblem> reportExceptions(MavenExecutionResult res) {
List<ProjectProblem> toRet = new ArrayList<ProjectProblem>();
for (Throwable e : res.getExceptions()) {
LOG.log(Level.FINE, "Error on loading project " + project.getProjectDirectory(), e);
if (e instanceof ArtifactResolutionException) { // XXX when does this occur?
toRet.add(ProjectProblem.createError(TXT_Artifact_Resolution_problem(), getDescriptionText(e)));
problemReporter.addMissingArtifact(((ArtifactResolutionException) e).getArtifact());
} else if (e instanceof ArtifactNotFoundException) { // XXX when does this occur?
toRet.add(ProjectProblem.createError(TXT_Artifact_Not_Found(), getDescriptionText(e)));
problemReporter.addMissingArtifact(((ArtifactNotFoundException) e).getArtifact());
} else if (e instanceof ProjectBuildingException) {
toRet.add(ProjectProblem.createError(TXT_Cannot_Load_Project(), getDescriptionText(e), new SanityBuildAction(project)));
if (e.getCause() instanceof ModelBuildingException) {
ModelBuildingException mbe = (ModelBuildingException) e.getCause();
for (ModelProblem mp : mbe.getProblems()) {
LOG.log(Level.FINE, mp.toString(), mp.getException());
if (mp.getException() instanceof UnresolvableModelException) {
// Probably obsoleted by ProblemReporterImpl.checkParent, but just in case:
UnresolvableModelException ume = (UnresolvableModelException) mp.getException();
problemReporter.addMissingArtifact(EmbedderFactory.getProjectEmbedder().createProjectArtifact(ume.getGroupId(), ume.getArtifactId(), ume.getVersion()));
} else if (mp.getException() instanceof PluginResolutionException) {
Plugin plugin = ((PluginResolutionException) mp.getException()).getPlugin();
// XXX this is not actually accurate; should rather pick out the ArtifactResolutionException & ArtifactNotFoundException inside
problemReporter.addMissingArtifact(EmbedderFactory.getProjectEmbedder().createArtifact(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), "jar"));
} else if (mp.getException() instanceof PluginManagerException) {
PluginManagerException ex = (PluginManagerException) mp.getException();
problemReporter.addMissingArtifact(EmbedderFactory.getProjectEmbedder().createArtifact(ex.getPluginGroupId(), ex.getPluginArtifactId(), ex.getPluginVersion(), "jar"));
}
}
}
} else {
String msg = e.getMessage();
if(msg != null) {
LOG.log(Level.INFO, "Exception thrown while loading maven project at " + project.getProjectDirectory(), e); //NOI18N
toRet.add(ProjectProblem.createError(TXT_Cannot_read_model(), msg));
} else {
String path = project.getProjectDirectory().getPath();
toRet.add(ProjectProblem.createError(TXT_Cannot_read_model(), TXT_NoMsg(path)));
LOG.log(Level.WARNING, "Exception thrown while loading maven project at " + path, e); //NOI18N
}
}
}
return toRet;
}
示例3: execute
import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的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;
}
}
示例4: execute
import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的package包/类
protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException {
MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.getRequest());
eventSpyDispatcher.onEvent(request);
MavenExecutionResult result = maven.execute(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.isShowErrors());
if (project == null && exception instanceof LifecycleExecutionException) {
project = ((LifecycleExecutionException) exception).getProject();
}
}
slf4jLogger.error("");
if (!cliRequest.isShowErrors()) {
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 (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.getRequest().getReactorFailureBehavior())) {
slf4jLogger.info("Build failures were ignored.");
return 0;
} else {
return 1;
}
} else {
return 0;
}
}
示例5: executeMaven
import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的package包/类
public static void executeMaven(final File pom,
final PrintStream stdout,
final PrintStream stderr,
final Properties properties,
final String... goals) {
final PrintStream oldout = System.out;
final PrintStream olderr = System.err;
final Properties oldProperties = System.getProperties();
if (properties != null) {
properties.keySet().forEach((o) -> {
if (properties.getProperty((String) o) != null) {
System.setProperty((String) o,
properties.getProperty((String) o));
}
});
}
final MavenEmbedder mavenEmbedder = newMavenEmbedder();
try {
if (stdout != null) {
System.setOut(stdout);
}
if (stderr != null) {
System.setErr(stderr);
}
final MavenRequest mavenRequest = MavenProjectLoader.createMavenRequest(false);
mavenRequest.setGoals(Arrays.asList(goals));
mavenRequest.setPom(pom.getAbsolutePath());
final MavenExecutionResult result = mavenEmbedder.execute(mavenRequest);
if (result.hasExceptions()) {
for (Throwable t : result.getExceptions()) {
LOG.error("Error Running Maven",
t);
}
throw new BuildException("Maven found issues trying to build the pom file: "
+ pom.getAbsolutePath() + ". Look at the Error Logs for more information");
}
} catch (final MavenEmbedderException ex) {
throw new BuildException("Maven coudn't build the project for pom file: " + pom.getAbsolutePath(),
ex);
} finally {
System.setProperties(oldProperties);
mavenEmbedder.dispose();
System.setOut(oldout);
System.setErr(olderr);
}
}