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


Java MavenSession.getProjects方法代碼示例

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


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

示例1: afterProjectsRead

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

		Set<String> goals = new HashSet<>(session.getGoals());

		if (goals.size() == 1 && goals.contains("clean")) {
			logger.info("Eccentric modularity not started (clean only session)! ");
			return;
		}

//		executionListener.setDelegate(session.getRequest().getExecutionListener());
//		session.getRequest().setExecutionListener(executionListener);
		logger.info("Eccentric modularity extension started!");
		
		
		List<MavenProject> allProjects = session.getProjects();
		for (MavenProject mavenProject : allProjects) {
			logger.info("Preparing " + mavenProject);
			executionListener.projectStarted(session.getProjectBuildingRequest(), mavenProject);
		}
		
	}
 
開發者ID:commsen,項目名稱:EM,代碼行數:23,代碼來源:EccentricModularityMavenLifecycleParticipant.java

示例2: detectUnmanagedModules

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
private void detectUnmanagedModules(EnforcerRuleHelper helper, MavenProject project) throws ExpressionEvaluationException, EnforcerRuleException {
    Log log = helper.getLog();
    MavenSession session = RuleHelper.getSession(helper);
    List<MavenProject> projects = session.getProjects();
    ImmutableListMultimap managedDependencies = RuleHelper.getManagedDependenciesAsMap(project);

    for (MavenProject mavenProject : projects) {
        if (ruleIsDefinedInProjectOrNotModuleParent(mavenProject, log)) {
            continue;
        }
        String projectIdentifier = RuleHelper.getProjectIdentifier(mavenProject);
        if (!managedDependencies.containsKey(projectIdentifier)) {
            logHeader(log, "manage all modules");
            log.warn("unmanaged project found: " + projectIdentifier);
            failureDetected = true;
        }
    }

    if (failureDetected) {
        throw new EnforcerRuleException("Failing because of unmanaged projects");
    }
}
 
開發者ID:1and1,項目名稱:ono-extra-enforcer-rules,代碼行數:23,代碼來源:ManageAllModulesRule.java

示例3: loadProject

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
private MavenProject loadProject ( File file, final MavenSession session ) throws Exception
{
    file = file.getCanonicalFile ();
    for ( final MavenProject project : session.getProjects () )
    {
        final File projectFile = project.getFile ().getCanonicalFile ();
        if ( projectFile.equals ( file ) )
        {
            return project;
        }
    }

    throw new MojoExecutionException ( file, "Unreferenced project found", String.format ( "Project at '%s' is not in the list of active projects. This plugin can only"
            + "work on projects there were loaded by maven. You need to include the project in your build.", file ) );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:16,代碼來源:DefaultPomHelper.java

示例4: afterProjectsRead

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Override
    public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
        try {
            for (MavenProject project : session.getProjects()) {
                if (!revisionGenerator.isDirty()) {
                    pluginMerger.merge(project, plugins.getEnforcerPlugin(project));
                }
//                pluginMerger.merge(project, plugins.getVersionFixPlugin());
            }
        } catch (Exception ex) {
            throw new MavenExecutionException("Unexpected Exception during Plugin Merging", ex);
        }
    }
 
開發者ID:IG-Group,項目名稱:cdversion-maven-extension,代碼行數:14,代碼來源:CDVersionLifecycleParticipant.java

示例5: 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

示例6: afterProjectsRead

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
    // Detect the OS and CPU architecture.
    Properties sessionProps = new Properties();
    sessionProps.putAll(session.getSystemProperties());
    sessionProps.putAll(session.getUserProperties());
    try {
        detector.detect(sessionProps, getClassifierWithLikes(session));
    } catch (DetectionException e) {
        throw new MavenExecutionException(e.getMessage(), session.getCurrentProject().getFile());
    }

    // Generate the dictionary.
    Map<String, String> dict = new LinkedHashMap<String, String>();
    dict.put(Detector.DETECTED_NAME, sessionProps.getProperty(Detector.DETECTED_NAME));
    dict.put(Detector.DETECTED_ARCH, sessionProps.getProperty(Detector.DETECTED_ARCH));
    dict.put(Detector.DETECTED_CLASSIFIER, sessionProps.getProperty(Detector.DETECTED_CLASSIFIER));
    for (Map.Entry<Object, Object> entry : sessionProps.entrySet()) {
        if (entry.getKey().toString().startsWith(Detector.DETECTED_RELEASE)) {
            dict.put(entry.getKey().toString(), entry.getValue().toString());
        }
    }

    // Inject the current session.
    injectSession(session, dict);

    /// Perform the interpolation for the properties of all dependencies.
    for (MavenProject p: session.getProjects()) {
        interpolate(dict, p);
    }
}
 
開發者ID:trustin,項目名稱:os-maven-plugin,代碼行數:32,代碼來源:DetectExtension.java

示例7: ReactorProjects

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Inject
public ReactorProjects(MavenSession session) {
  Map<String, MavenProject> projects = new HashMap<>();
  for (MavenProject project : session.getProjects()) {
    projects.put(key(project.getGroupId(), project.getArtifactId(), project.getVersion()), project);
  }
  this.projects = ImmutableMap.copyOf(projects);
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:9,代碼來源:ReactorProjects.java

示例8: testDeployAtEnd

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Test
public void testDeployAtEnd() throws Exception {
  File basedir = resources.getBasedir("install-deploy/deploy-at-end");

  File localrepo = new File(basedir, "target/localrepo");
  Assert.assertTrue(localrepo.mkdirs());

  File remoterepo = new File(basedir, "target/remoterepo");
  Assert.assertTrue(remoterepo.mkdirs());

  Properties properties = new Properties();
  properties.put("version", "1.0");
  properties.put("repopath", remoterepo.getCanonicalPath());
  MavenProject project = readMavenProject(basedir, properties);

  MavenSession session = newSession(project, localrepo, properties);

  DeployParticipant deployParticipant = mojos.getContainer().lookup(DeployParticipant.class);

  Assert.assertEquals(0, deployParticipant.getDeployAtEndRequests().size());

  for (MavenProject reactorProject : session.getProjects()) {
    session.setCurrentProject(reactorProject);
    if (!reactorProject.getPackaging().equals("pom")) {
      mojos.executeMojo(session, reactorProject, "compile");
      mojos.executeMojo(session, reactorProject, "jar");
    }
    mojos.executeMojo(session, reactorProject, "deploy");
  }

  Assert.assertFalse(new File(remoterepo, "io/takari/lifecycle/its/test/1.0/test-1.0.pom").canRead());
  Assert.assertFalse(new File(remoterepo, "io/takari/lifecycle/its/test-modulea/1.0/test-modulea-1.0.jar").canRead());
  Assert.assertFalse(new File(remoterepo, "io/takari/lifecycle/its/test-modulea/1.0/test-modulea-1.0.pom").canRead());
  Assert.assertFalse(new File(remoterepo, "io/takari/lifecycle/its/test-moduleb/1.0/test-moduleb-1.0.jar").canRead());
  Assert.assertFalse(new File(remoterepo, "io/takari/lifecycle/its/test-moduleb/1.0/test-moduleb-1.0.pom").canRead());

  Assert.assertEquals(3, deployParticipant.getDeployAtEndRequests().size());
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:39,代碼來源:InstallDeployTest.java

示例9: getProjects

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public static List<MavenProject> getProjects( MavenProject project, MavenSession session, boolean aggregator )
{
    if ( aggregator )
    {
        return session.getProjects();
    }
    else
    {
        return Collections.singletonList( project );
    }
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:12,代碼來源:LifecycleDependencyResolver.java

示例10: calculateProjectBuilds

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public ProjectBuildList calculateProjectBuilds( MavenSession session, List<TaskSegment> taskSegments )
{
    List<ProjectSegment> projectBuilds = new ArrayList<ProjectSegment>();

    MavenProject rootProject = session.getTopLevelProject();

    for ( TaskSegment taskSegment : taskSegments )
    {
        List<MavenProject> projects;

        if ( taskSegment.isAggregating() )
        {
            projects = Collections.singletonList( rootProject );
        }
        else
        {
            projects = session.getProjects();
        }
        for ( MavenProject project : projects )
        {
            BuilderCommon.attachToThread( project ); // Not totally sure if this is needed for anything
            MavenSession copiedSession = session.clone();
            copiedSession.setCurrentProject( project );
            projectBuilds.add( new ProjectSegment( project, taskSegment, copiedSession ) );
        }
    }
    return new ProjectBuildList( projectBuilds );
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:29,代碼來源:BuildListCalculator.java

示例11: logReactorSummary

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
private void logReactorSummary( MavenSession session )
{
    logger.info( chars( '-', LINE_LENGTH ) );

    logger.info( "Reactor Summary:" );

    logger.info( "" );

    MavenExecutionResult result = session.getResult();

    for ( MavenProject project : session.getProjects() )
    {
        StringBuilder buffer = new StringBuilder( 128 );

        buffer.append( project.getName() );

        buffer.append( ' ' );
        while ( buffer.length() < LINE_LENGTH - 21 )
        {
            buffer.append( '.' );
        }
        buffer.append( ' ' );

        BuildSummary buildSummary = result.getBuildSummary( project );

        if ( buildSummary == null )
        {
            buffer.append( "SKIPPED" );
        }
        else if ( buildSummary instanceof BuildSuccess )
        {
            buffer.append( "SUCCESS [" );
            buffer.append( getFormattedTime( buildSummary.getTime() ) );
            buffer.append( "]" );
        }
        else if ( buildSummary instanceof BuildFailure )
        {
            buffer.append( "FAILURE [" );
            buffer.append( getFormattedTime( buildSummary.getTime() ) );
            buffer.append( "]" );
        }

        logger.info( buffer.toString() );
    }
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:46,代碼來源:ExecutionEventLogger.java


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