当前位置: 首页>>代码示例>>Java>>正文


Java MavenExecutionResult类代码示例

本文整理汇总了Java中org.apache.maven.execution.MavenExecutionResult的典型用法代码示例。如果您正苦于以下问题:Java MavenExecutionResult类的具体用法?Java MavenExecutionResult怎么用?Java MavenExecutionResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MavenExecutionResult类属于org.apache.maven.execution包,在下文中一共展示了MavenExecutionResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readProjectWithDependencies

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
public MavenExecutionResult readProjectWithDependencies(MavenExecutionRequest req, boolean useWorkspaceResolution) {
    if (useWorkspaceResolution) {
        req.setWorkspaceReader(new NbWorkspaceReader());
    }
    File pomFile = req.getPom();
    MavenExecutionResult result = new DefaultMavenExecutionResult();
    try {
        ProjectBuildingRequest configuration = req.getProjectBuildingRequest();
        configuration.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
        configuration.setResolveDependencies(true);
        configuration.setRepositorySession(maven.newRepositorySession(req));
        ProjectBuildingResult projectBuildingResult = projectBuilder.build(pomFile, configuration);
        result.setProject(projectBuildingResult.getProject());
        result.setDependencyResolutionResult(projectBuildingResult.getDependencyResolutionResult());
    } catch (ProjectBuildingException ex) {
        //don't add the exception here. this should come out as a build marker, not fill
        //the error logs with msgs
        return result.addException(ex);
    }
    normalizePaths(result.getProject());
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MavenEmbedder.java

示例2: _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;
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:25,代码来源:MavenExecutionResultHandler.java

示例3: newMavenSession

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
@Override
protected MavenSession newMavenSession(MavenProject project) {
	MavenExecutionResult result = new DefaultMavenExecutionResult();

	MavenSession session = new MavenSession(getContainer(),
			project.getProjectBuildingRequest().getRepositorySession(), currentMavenExecutionRequest, result);
	session.setCurrentProject(project);
	session.setProjects(Arrays.asList(project));

	try {
		LegacySupport legacySupport = this.lookup(LegacySupport.class);
		legacySupport.setSession(session);
	} catch (Exception e) {
		e.printStackTrace();
	}

	return session;
}
 
开发者ID:coastland,项目名称:gsp-dba-maven-plugin,代码行数:19,代码来源:AbstractDdlMojoTest.java

示例4: newSession

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
private MavenSession newSession(MavenProject project, File localrepo, Properties properties) throws Exception {
  MavenExecutionRequest request = new DefaultMavenExecutionRequest();
  MavenExecutionResult result = new DefaultMavenExecutionResult();
  DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession();
  LocalRepository localRepo = new LocalRepository(localrepo);
  repoSession.setLocalRepositoryManager(mojos.getContainer().lookup(LocalRepositoryManagerFactory.class, "simple").newInstance(repoSession, localRepo));
  MavenSession session = new MavenSession(mojos.getContainer(), repoSession, request, result);
  List<MavenProject> projects = new ArrayList<>();
  projects.add(project);
  for (String module : project.getModules()) {
    MavenProject moduleProject = readMavenProject(new File(project.getBasedir(), module), properties);
    moduleProject.setParent(project);
    projects.add(moduleProject);
  }

  session.setProjects(projects);
  return session;
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:19,代码来源:InstallDeployTest.java

示例5: getProjectClassPaths

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
public static List<String> getProjectClassPaths(String localPathRevision) throws Exception {
        MavenExecutionResult result = getResult(localPathRevision, Arrays.asList("dependency:resolve"), null);

//        List<Throwable> exceptions = result.getExceptions();
//        for (Throwable throwable : exceptions) {
//            throwable.printStackTrace();
//        }
        if (result.hasExceptions()) {
            throw new MavenException(result.getExceptions().toString());
        }

        Map<String, Artifact> artifactMap = result.getProject().getArtifactMap();
        List<String> classpath = new ArrayList<String>(artifactMap.size());
        for (String artifact : artifactMap.keySet()) {
            String path = artifactMap.get(artifact).getFile().getAbsolutePath();
//            System.out.println("artifact = " + path);
            classpath.add(path);
//            for (String string : artifact.getDependencyTrail()) {
//                System.out.println("                 " + string);
//            }
        }
        Collections.sort(classpath);
        return classpath;
    }
 
开发者ID:gems-uff,项目名称:oceano,代码行数:25,代码来源:MavenUtil.java

示例6: setResult

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
private void setResult(ProjectBuildingResult pbr, Map<File, MavenExecutionResult> results) {
    DefaultMavenExecutionResult r = new DefaultMavenExecutionResult();
    normalizePaths(pbr.getProject());
    r.setProject(pbr.getProject());
        r.setDependencyResolutionResult(pbr.getDependencyResolutionResult());
    results.put(pbr.getPomFile(), r);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:MavenEmbedder.java

示例7: testArtifactFixer

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
public void testArtifactFixer() throws Exception { // #197669
    File main = TestFileUtils.writeFile(new File(getWorkDir(), "main/pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" +
        "<parent><groupId>g</groupId><artifactId>p</artifactId><version>0</version></parent>" +
        "<artifactId>m</artifactId>" +
        "<dependencies><dependency><groupId>g</groupId><artifactId>s</artifactId><version>0</version></dependency></dependencies>" +
        "</project>");
    final File parent = TestFileUtils.writeFile(new File(getWorkDir(), "parent/pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" +
        "<groupId>g</groupId><artifactId>p</artifactId><version>0</version>" +
        "<packaging>pom</packaging>" +
        "<properties><k>v</k></properties>" +
        "</project>");
    final File sibling = TestFileUtils.writeFile(new File(getWorkDir(), "sib/pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" +
        "<groupId>g</groupId><artifactId>s</artifactId><version>0</version>" +
        "<dependencies><dependency><groupId>g</groupId><artifactId>b</artifactId><version>0</version></dependency></dependencies>" +
        "</project>");
    final File binary = TestFileUtils.writeZipFile(new File(getWorkDir(), "b.jar"), "g/r:stuff");
    MockLookup.setInstances(new ArtifactFixer() {
        @Override public File resolve(org.eclipse.aether.artifact.Artifact artifact) {
            String id = artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getExtension() + ':' + artifact.getVersion();
            if (id.equals("g:p:pom:0")) {
                return parent;
            } else if (id.equals("g:s:pom:0")) {
                return sibling;
            } else if (id.equals("g:b:jar:0")) {
                return binary;
            } else {
                return null;
            }
        }
    });
    MavenEmbedder e = EmbedderFactory.getProjectEmbedder();
    MavenExecutionRequest req = e.createMavenExecutionRequest();
    req.setPom(main);
    req.setOffline(true);
    MavenExecutionResult res = e.readProjectWithDependencies(req, true);
    assertEquals(Collections.emptyList(), res.getExceptions());
    MavenProject prj = res.getProject();
    assertEquals("v", prj.getProperties().getProperty("k"));
    assertEquals("[g:b:jar:0:compile, g:s:jar:0:compile]", new TreeSet<Artifact>(prj.getArtifacts()).toString());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:EmbedderFactoryTest.java

示例8: create

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
public ReactorContext create(MavenExecutionResult result, ProjectIndex index, ClassLoader classLoader, ReactorBuildStatus status, LifecycleModuleBuilder builder) {
    ReactorContext context;
    if (VERSION_3_0_0.compareTo(version) < 0) {
        throw new UnsupportedOperationException("ReactorContext is not supported in maven version:" + version);
    } else if (VERSION_3_3_0.compareTo(version) < 0) {
        context = create_3_2_x(result, index, classLoader, status);
    } else {
        context = create_3_3_x(result, index, classLoader, status, builder);
    }

    if (context == null) {
        throw new IllegalStateException("Unable to create ReactorContext");
    }
    return context;
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:16,代码来源:ReactorContextFactory.java

示例9: create_3_2_x

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
private static ReactorContext create_3_2_x(MavenExecutionResult result, ProjectIndex index, ClassLoader classLoader, ReactorBuildStatus status) {
    try {
        Constructor<ReactorContext> constructor = ReactorContext.class.getDeclaredConstructor(MavenExecutionResult.class, ProjectIndex.class, ClassLoader.class, ReactorBuildStatus.class);
        return constructor.newInstance(result, index, classLoader, status);
    } catch (NoSuchMethodException e) {
        return null;
    } catch (Throwable t) {
        throw new RuntimeException("Could not create ReactorContext.", t);
    }
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:11,代码来源:ReactorContextFactory.java

示例10: create_3_3_x

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
private static ReactorContext create_3_3_x(MavenExecutionResult result, ProjectIndex index, ClassLoader classLoader, ReactorBuildStatus status, LifecycleModuleBuilder builder) {
    try {
        Constructor<ReactorContext> constructor = (Constructor<ReactorContext>) ReactorContext.class.getDeclaredConstructors()[0];
        return constructor.newInstance(result, index, classLoader, status, Reflections.getMemento(builder));
    } catch (Throwable t) {
        throw new RuntimeException("Could not create ReactorContext.", t);
    }
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:9,代码来源:ReactorContextFactory.java

示例11: newMavenSession

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
protected MavenSession newMavenSession() {
    try {
        MavenExecutionRequest request = new DefaultMavenExecutionRequest();
        MavenExecutionResult result = new DefaultMavenExecutionResult();

        // populate sensible defaults, including repository basedir and remote repos
        MavenExecutionRequestPopulator populator;
        populator = getContainer().lookup( MavenExecutionRequestPopulator.class );
        populator.populateDefaults( request );

        // this is needed to allow java profiles to get resolved; i.e. avoid during project builds:
        // [ERROR] Failed to determine Java version for profile java-1.5-detected @ org.apache.commons:commons-parent:22, /Users/alex/.m2/repository/org/apache/commons/commons-parent/22/commons-parent-22.pom, line 909, column 14
        request.setSystemProperties( System.getProperties() );
        
        // and this is needed so that the repo session in the maven session 
        // has a repo manager, and it points at the local repo
        // (cf MavenRepositorySystemUtils.newSession() which is what is otherwise done)
        DefaultMaven maven = (DefaultMaven) getContainer().lookup( Maven.class );
        DefaultRepositorySystemSession repoSession =
            (DefaultRepositorySystemSession) maven.newRepositorySession( request );
        repoSession.setLocalRepositoryManager(
            new SimpleLocalRepositoryManagerFactory().newInstance(repoSession, 
                new LocalRepository( request.getLocalRepository().getBasedir() ) ));

        @SuppressWarnings("deprecation")
        MavenSession session = new MavenSession( getContainer(), 
            repoSession,
            request, result );
        return session;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:ahgittin,项目名称:license-audit-maven-plugin,代码行数:34,代码来源:BetterAbstractMojoTestCase.java

示例12: translatePom

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
private void translatePom(IFile input, IProgressMonitor monitor) throws CoreException {
  markerManager.deleteMarkers(input, TRANSLATION_PROBLEM_TYPE);

  IProject project = input.getProject();
  IFile pomXml = project.getFile(IMavenConstants.POM_FILE_NAME);
  IPath buildFolder;
  if (pomXml.exists()) {
   	IMavenProjectFacade facade = projectManager.create(pomXml, true, monitor);
   	MavenProject mavenProject = facade.getMavenProject(monitor);
   	buildFolder = facade.getProjectRelativePath(mavenProject.getBuild().getDirectory());
  } else {
  		//In case where pom.xml doesn't exist, fall back to default target folder
  		buildFolder = project.getFolder("target").getProjectRelativePath();
  }

  IPath polyglotFolder = buildFolder.append("polyglot");
  IFile output = project.getFolder(polyglotFolder).getFile(IMavenConstants.POM_FILE_NAME);
  MavenExecutionResult result = translate(pomXml, input, output, monitor);
  if (result.hasExceptions()) {
    addErrorMarkers(input, result.getExceptions());
    return;
  } 
  
  if (output.exists()) {
  	  try (InputStream content = output.getContents()) {
  		  if (pomXml.exists()) {
  			  pomXml.setContents(content, true, true, monitor);
  		  } else {
  			  pomXml.create(content, true, monitor);
  		  }
  		  if (!pomXml.isDerived()) {
  			  pomXml.setDerived(true, monitor);
  		  }
  	  } catch (IOException e) {
  		  throw new CoreException(new Status(IStatus.ERROR, PolyglotSupportActivator.PLUGIN_ID, "Unable to write to pom.xml", e));
 }
  }
}
 
开发者ID:jbosstools,项目名称:m2e-polyglot-poc,代码行数:39,代码来源:PomTranslatorJob.java

示例13: addExceptionToResult

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
private MavenExecutionResult addExceptionToResult( MavenExecutionResult result, Throwable e )
{
    if ( !result.getExceptions().contains( e ) )
    {
        result.addException( e );
    }

    return result;
}
 
开发者ID:rvs-fluid-it,项目名称:mvn-fluid-cd,代码行数:10,代码来源:JenkinsDefaultMaven.java

示例14: ReactorContext

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
public ReactorContext( MavenExecutionResult result, ProjectIndex projectIndex,
                       ClassLoader originalContextClassLoader, ReactorBuildStatus reactorBuildStatus )
{
    this.result = result;
    this.projectIndex = projectIndex;
    this.originalContextClassLoader = originalContextClassLoader;
    this.reactorBuildStatus = reactorBuildStatus;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:9,代码来源:ReactorContext.java

示例15: processResult

import org.apache.maven.execution.MavenExecutionResult; //导入依赖的package包/类
private MavenExecutionResult processResult( MavenExecutionResult result, Throwable e )
{
    if ( !result.getExceptions().contains( e ) )
    {
        result.addException( e );
    }

    return result;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:10,代码来源:DefaultMaven.java


注:本文中的org.apache.maven.execution.MavenExecutionResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。