當前位置: 首頁>>代碼示例>>Java>>正文


Java MavenSession.setProjects方法代碼示例

本文整理匯總了Java中org.apache.maven.execution.MavenSession.setProjects方法的典型用法代碼示例。如果您正苦於以下問題:Java MavenSession.setProjects方法的具體用法?Java MavenSession.setProjects怎麽用?Java MavenSession.setProjects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.maven.execution.MavenSession的用法示例。


在下文中一共展示了MavenSession.setProjects方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadExtensions

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
private void loadExtensions(MavenProject project, List<Exception> exceptions) {
  ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
  Collection<AbstractMavenLifecycleParticipant> participants =
      getLifecycleParticipants(Collections.singletonList(project));
  if (!participants.isEmpty()) {
    LegacySupport legacySupport = getMavenComponent(LegacySupport.class);
    MavenSession session = legacySupport.getSession();
    session.setCurrentProject(project);
    session.setProjects(Collections.singletonList(project));

    for (AbstractMavenLifecycleParticipant participant : participants) {
      Thread.currentThread().setContextClassLoader(participant.getClass().getClassLoader());
      try {
        participant.afterProjectsRead(session);
      } catch (MavenExecutionException e) {
        exceptions.add(e);
      } finally {
        Thread.currentThread().setContextClassLoader(currentClassLoader);
      }
    }
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:23,代碼來源:MavenServerImpl.java

示例2: newMavenSession

import org.apache.maven.execution.MavenSession; //導入方法依賴的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

示例3: newSession

import org.apache.maven.execution.MavenSession; //導入方法依賴的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

示例4: testSourcepathDependency

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Test
public void testSourcepathDependency() throws Exception {
  // assert that MojoAnnotationProcessorMojo honours sourcepath=reactorDependencies

  File basedir = resources.getBasedir("plugin-descriptor/sourcepath-dependency");
  File dependency = new File(basedir, "dependency");
  File plugin = new File(basedir, "plugin");

  MavenProject dependencyProject = mojos.readMavenProject(dependency);
  MavenProject pluginProject = mojos.readMavenProject(plugin);
  addDependencies(pluginProject, "apache-plugin-annotations-jar", "maven-plugin-api-jar");
  mojos.newDependency(new File(dependencyProject.getBuild().getOutputDirectory())) //
      .setGroupId(dependencyProject.getGroupId()) //
      .setArtifactId(dependencyProject.getArtifactId()) //
      .setVersion(dependencyProject.getVersion()) //
      .addTo(pluginProject);
  Artifact dependencyArtifact = dependencyProject.getArtifact();
  dependencyArtifact.setScope(Artifact.SCOPE_COMPILE);
  pluginProject.getArtifacts().add(dependencyArtifact);
  MavenSession session = mojos.newMavenSession(pluginProject);
  session.setProjects(ImmutableList.of(dependencyProject, pluginProject));
  session.setCurrentProject(pluginProject);
  mojos.executeMojo(session, pluginProject, "mojo-annotation-processor", newParameter("sourcepath", "reactorDependencies"));
  mojos.executeMojo(session, pluginProject, "plugin-descriptor");
  mojos.assertBuildOutputs(plugin, "target/classes/META-INF/maven/plugin.xml", "target/classes/META-INF/m2e/lifecycle-mapping-metadata.xml");
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:27,代碼來源:PluginDescriptorMojoTest.java

示例5: testSourcepathSecondatytype

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Test
@Ignore("Neither javac nor jdt support secondary types on sourcepath")
public void testSourcepathSecondatytype() throws Exception {
  File processor = compileAnnotationProcessor();
  File basedir = resources.getBasedir("compile-proc/proc-sourcepath-secondarytype");

  File dependencyBasedir = new File(basedir, "dependency");
  File projectBasedir = new File(basedir, "project");

  Xpp3Dom processors = newProcessors("processor.Processor");
  Xpp3Dom sourcepath = newParameter("sourcepath", "reactorDependencies");

  MavenProject dependency = mojos.readMavenProject(dependencyBasedir);
  MavenProject project = mojos.readMavenProject(projectBasedir);

  mojos.newDependency(new File(dependencyBasedir, "target/classes")) //
      .setGroupId(dependency.getGroupId()) //
      .setArtifactId(dependency.getArtifactId()) //
      .setVersion(dependency.getVersion()) //
      .addTo(project);

  MavenSession session = mojos.newMavenSession(project);
  session.setProjects(Arrays.asList(project, dependency));

  processAnnotations(session, project, "compile", processor, Proc.only, processors, sourcepath);
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:27,代碼來源:AnnotationProcessingTest.java

示例6: afterProjectsRead

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Override
public void afterProjectsRead(MavenSession session)	throws MavenExecutionException {
	logger.debug("BW lifecycle participant");

	propertiesManager = AbstractBWMojo.propertiesManager(session, session.getCurrentProject());

	List<MavenProject> projects = prepareProjects(session.getProjects(), session);
	session.setProjects(projects);
}
 
開發者ID:fastconnect,項目名稱:tibco-bwmaven,代碼行數:10,代碼來源:BWLifecycleParticipant.java

示例7: build

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
private void build(MavenSession session, MavenProject project, List<MavenProject> allProjects, GoalSet goals) throws MojoExecutionException {
    session.setProjects(allProjects);
    ProjectIndex projectIndex = new ProjectIndex(session.getProjects());
    try {
        ReactorBuildStatus reactorBuildStatus = new ReactorBuildStatus(new BomDependencyGraph(session.getProjects()));
        ReactorContext reactorContext = new ReactorContextFactory(new MavenVersion(mavenVersion)).create(session.getResult(), projectIndex, Thread.currentThread().getContextClassLoader(),
                reactorBuildStatus, builder);
        List<TaskSegment> segments = segmentCalculator.calculateTaskSegments(session);
        for (TaskSegment segment : segments) {
            builder.buildProject(session, reactorContext, project, filterSegment(segment, goals));
        }
    } catch (Throwable t) {
        throw new MojoExecutionException("Error building generated bom:" + project.getArtifactId(), t);
    }
}
 
開發者ID:sundrio,項目名稱:sundrio,代碼行數:16,代碼來源:GenerateBomMojo.java

示例8: newMavenSession

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
/** Extends the super to use the new {@link #newMavenSession()} introduced here 
 * which sets the defaults one expects from maven; the standard test case leaves a lot of things blank */
@Override
protected MavenSession newMavenSession(MavenProject project) {
    MavenSession session = newMavenSession();
    session.setCurrentProject( project );
    session.setProjects( Arrays.asList( project ) );
    return session;        
}
 
開發者ID:ahgittin,項目名稱:license-audit-maven-plugin,代碼行數:10,代碼來源:BetterAbstractMojoTestCase.java

示例9: testRequireProc_processorpath

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Test
public void testRequireProc_processorpath() throws Exception {
  MavenProject annotations = mojos.readMavenProject(resources.getBasedir("compile-proc/processorpath-annotation"));
  mojos.compile(annotations);

  MavenProject processor = mojos.readMavenProject(resources.getBasedir("compile-proc/processorpath-processor"));
  mojos.newDependency(new File(annotations.getBasedir(), "target/classes")).setArtifactId("annotations").addTo(processor);
  mojos.compile(processor);
  cp(processor.getBasedir(), "src/main/resources/META-INF/services/javax.annotation.processing.Processor", "target/classes/META-INF/services/javax.annotation.processing.Processor");

  File basedir = resources.getBasedir("compile-proc/proc");
  MavenProject project = mojos.readMavenProject(basedir);
  mojos.newDependency(new File(annotations.getBasedir(), "target/classes")).setArtifactId("annotations").addTo(project);

  MavenSession session = mojos.newMavenSession(project);
  SimpleReactorReader.builder() //
      .addProjects(annotations, processor, project) //
      .toSession(session.getRepositorySession());

  session.setProjects(Arrays.asList(annotations, processor, project));
  session.setCurrentProject(project);
  Xpp3Dom processorpath = new Xpp3Dom("processorpath");
  processorpath.addChild(newProcessorpathEntry(processor));
  try {
    mojos.compile(session, project, processorpath);
    fail();
  } catch (IllegalArgumentException expected) {
    // TODO assert message
  }
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:31,代碼來源:AnnotationProcessingTest.java

示例10: testProc_processorpath

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Test
public void testProc_processorpath() throws Exception {
  MavenProject annotations = mojos.readMavenProject(resources.getBasedir("compile-proc/processorpath-annotation"));
  mojos.compile(annotations);

  MavenProject processor = mojos.readMavenProject(resources.getBasedir("compile-proc/processorpath-processor"));
  mojos.newDependency(new File(annotations.getBasedir(), "target/classes")).setArtifactId("annotations").addTo(processor);
  mojos.compile(processor);
  cp(processor.getBasedir(), "src/main/resources/META-INF/services/javax.annotation.processing.Processor", "target/classes/META-INF/services/javax.annotation.processing.Processor");

  File basedir = resources.getBasedir("compile-proc/proc");
  MavenProject project = mojos.readMavenProject(basedir);
  mojos.newDependency(new File(annotations.getBasedir(), "target/classes")).setArtifactId("annotations").addTo(project);

  MavenSession session = mojos.newMavenSession(project);
  SimpleReactorReader.builder() //
      .addProjects(annotations, processor, project) //
      .toSession(session.getRepositorySession());

  session.setProjects(Arrays.asList(annotations, processor, project));
  session.setCurrentProject(project);
  Xpp3Dom processorpath = new Xpp3Dom("processorpath");
  processorpath.addChild(newProcessorpathEntry(processor));
  mojos.compile(session, project, newParameter("proc", "proc"), processorpath);
  mojos.assertBuildOutputs(new File(basedir, "target"), //
      "classes/proc/Source.class", //
      "generated-sources/annotations/proc/GeneratedSource.java", //
      "classes/proc/GeneratedSource.class");
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:30,代碼來源:AnnotationProcessingTest.java

示例11: testSourcepathDependency

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Test
public void testSourcepathDependency() throws Exception {
  File processor = compileAnnotationProcessor();
  File basedir = resources.getBasedir("compile-proc/proc-sourcepath");

  File dependencyBasedir = new File(basedir, "dependency");
  File projectBasedir = new File(basedir, "project");

  Xpp3Dom processors = newProcessors("processor.Processor");
  Xpp3Dom sourcepath = newParameter("sourcepath", "reactorDependencies");

  MavenProject dependency = mojos.readMavenProject(dependencyBasedir);
  MavenProject project = mojos.readMavenProject(projectBasedir);

  mojos.newDependency(new File(dependencyBasedir, "target/classes")) //
      .setGroupId(dependency.getGroupId()) //
      .setArtifactId(dependency.getArtifactId()) //
      .setVersion(dependency.getVersion()) //
      .addTo(project);

  MavenSession session = mojos.newMavenSession(project);
  session.setProjects(Arrays.asList(project, dependency));

  processAnnotations(session, project, "compile", processor, Proc.only, processors, sourcepath);
  mojos.assertBuildOutputs(new File(projectBasedir, "target"), //
      "generated-sources/annotations/sourcepath/project/GeneratedSource.java" //
  );
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:29,代碼來源:AnnotationProcessingTest.java

示例12: testSourcepathDependency_classifiedDependency

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Test
public void testSourcepathDependency_classifiedDependency() throws Exception {
  File processor = compileAnnotationProcessor();
  File basedir = resources.getBasedir("compile-proc/proc-sourcepath");

  File dependencyBasedir = new File(basedir, "dependency");
  File projectBasedir = new File(basedir, "project");

  Xpp3Dom processors = newProcessors("processor.Processor");
  Xpp3Dom sourcepath = newParameter("sourcepath", "reactorDependencies");

  MavenProject dependency = mojos.readMavenProject(dependencyBasedir);
  MavenProject project = mojos.readMavenProject(projectBasedir);

  mojos.newDependency(new File(dependencyBasedir, "target/classes")) //
      .setGroupId(dependency.getGroupId()) //
      .setArtifactId(dependency.getArtifactId()) //
      .setVersion(dependency.getVersion()) //
      .setClassifier("classifier") //
      .addTo(project);

  MavenSession session = mojos.newMavenSession(project);
  session.setProjects(Arrays.asList(project, dependency));

  try {
    processAnnotations(session, project, "compile", processor, Proc.only, processors, sourcepath);
    Assert.fail();
  } catch (MojoExecutionException expected) {
    Assert.assertTrue(expected.getMessage().contains(dependency.getGroupId() + ":" + dependency.getArtifactId()));
  }
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:32,代碼來源:AnnotationProcessingTest.java

示例13: testSourcepathDependency_testCompile

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Test
public void testSourcepathDependency_testCompile() throws Exception {
  File processor = compileAnnotationProcessor();
  File basedir = resources.getBasedir("compile-proc/proc-sourcepath");

  File dependencyBasedir = new File(basedir, "dependency");
  File projectBasedir = new File(basedir, "project");

  Xpp3Dom processors = newProcessors("processor.Processor");
  Xpp3Dom sourcepath = newParameter("sourcepath", "reactorDependencies");

  MavenProject dependency = mojos.readMavenProject(dependencyBasedir);
  MavenProject project = mojos.readMavenProject(projectBasedir);

  mojos.newDependency(new File(dependencyBasedir, "target/classes")) //
      .setGroupId(dependency.getGroupId()) //
      .setArtifactId(dependency.getArtifactId()) //
      .setVersion(dependency.getVersion()) //
      .addTo(project);

  mojos.newDependency(new File(dependencyBasedir, "target/test-classes")) //
      .setGroupId(dependency.getGroupId()) //
      .setArtifactId(dependency.getArtifactId()) //
      .setType("test-jar") //
      .setVersion(dependency.getVersion()) //
      .addTo(project);

  MavenSession session = mojos.newMavenSession(project);
  session.setProjects(Arrays.asList(project, dependency));

  processAnnotations(session, project, "testCompile", processor, Proc.only, processors, sourcepath);
  mojos.assertBuildOutputs(new File(projectBasedir, "target"), //
      "generated-test-sources/test-annotations/sourcepath/project/test/GeneratedSourceTest.java" //
  );
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:36,代碼來源:AnnotationProcessingTest.java

示例14: getMavenSession

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public static MavenSession getMavenSession()
{
    final DefaultMavenExecutionResult defaultMavenExecutionResult = new DefaultMavenExecutionResult();
    MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest();
    mavenExecutionRequest.setExecutionListener( new AbstractExecutionListener() );
    mavenExecutionRequest.setGoals( Arrays.asList( "clean", "aggr", "install" ) );
    final MavenSession session = new MavenSession( null, null, mavenExecutionRequest, defaultMavenExecutionResult );
    final ProjectDependencyGraphStub dependencyGraphStub = new ProjectDependencyGraphStub();
    session.setProjectDependencyGraph( dependencyGraphStub );
    session.setProjects( dependencyGraphStub.getSortedProjects() );
    return session;
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:13,代碼來源:ProjectDependencyGraphStub.java

示例15: createMavenSession

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
protected MavenSession createMavenSession( File pom, Properties executionProperties )
    throws Exception
{
    MavenExecutionRequest request = createMavenExecutionRequest( pom );
    
    ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest()
        .setLocalRepository( request.getLocalRepository() )
        .setRemoteRepositories( request.getRemoteRepositories() )
        .setPluginArtifactRepositories( request.getPluginArtifactRepositories() )
        .setSystemProperties( executionProperties );

    MavenProject project = null;

    if ( pom != null )
    {
        project = projectBuilder.build( pom, configuration ).getProject();
    }
    else
    {
        project = createStubMavenProject();
        project.setRemoteArtifactRepositories( request.getRemoteRepositories() );
        project.setPluginArtifactRepositories( request.getPluginArtifactRepositories() );
    }

    initRepoSession( configuration );

    MavenSession session =
        new MavenSession( getContainer(), configuration.getRepositorySession(), request,
                          new DefaultMavenExecutionResult() );
    session.setProjects( Arrays.asList( project ) );

    return session;
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:34,代碼來源:AbstractCoreMavenComponentTestCase.java


注:本文中的org.apache.maven.execution.MavenSession.setProjects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。