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


Java MavenSession类代码示例

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


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

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
@Test
public void doExecute() throws Exception {
    final PackageMojo mojo = getMojoFromPom();
    final PackageMojo mojoSpy = spy(mojo);
    ReflectionUtils.setVariableValueInObject(mojoSpy, "finalName", "artifact-0.1.0");
    doReturn(mock(AnnotationHandler.class)).when(mojoSpy).getAnnotationHandler();
    doReturn(ClasspathHelper.forPackage("com.microsoft.azure.maven.function.handlers").toArray()[0])
            .when(mojoSpy)
            .getTargetClassUrl();
    doReturn("target/azure-functions").when(mojoSpy).getDeploymentStageDirectory();
    doReturn("target").when(mojoSpy).getBuildDirectoryAbsolutePath();
    doReturn(mock(MavenProject.class)).when(mojoSpy).getProject();
    doReturn(mock(MavenSession.class)).when(mojoSpy).getSession();
    doReturn(mock(MavenResourcesFiltering.class)).when(mojoSpy).getMavenResourcesFiltering();

    mojoSpy.doExecute();
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:18,代码来源:PackageMojoTest.java

示例3: afterProjectsRead

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
    Log.setLoggerFactory(new MavenExtensionLoggerFactory(mavenLogger));

    loadConfigAndCheckIfInstallationShouldBeSkipped(session);
    if (skipExtensionInstallation) {
        return;
    }

    logger.debug("Version: %s", ExtensionVersion.version().toString());
    logger.debug("Applied user properties: %s", session.getUserProperties());

    File projectDirectory = session.getTopLevelProject().getModel().getProjectDirectory();
    logger.info("Enabling extension.");
    configureExtension(session, configuration);
    calculateChanges(projectDirectory, configuration);
    Runtime.getRuntime().addShutdownHook(new Thread(() -> purgeLocalStorageAndExportPom(session)));
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:19,代码来源:SmartTestingMavenConfigurer.java

示例4: loadConfigAndCheckIfInstallationShouldBeSkipped

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
private void loadConfigAndCheckIfInstallationShouldBeSkipped(MavenSession session) {
    SkipInstallationChecker skipInstallationChecker = new SkipInstallationChecker(session);
    skipExtensionInstallation = skipInstallationChecker.shouldSkip();
    if (skipExtensionInstallation) {
        logExtensionDisableReason(Log.getLogger(), skipInstallationChecker.getReason());
        return;
    }

    File executionRootDirectory = new File(session.getExecutionRootDirectory());
    configuration = ConfigurationLoader.load(executionRootDirectory, this::isProjectRootDirectory);
    Log.setLoggerFactory(new MavenExtensionLoggerFactory(mavenLogger, configuration));
    logger = Log.getLogger();
    if (skipInstallationChecker.shouldSkipForConfiguration(configuration)) {
        skipExtensionInstallation = true;
        logExtensionDisableReason(logger, skipInstallationChecker.getReason());
    }
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:18,代码来源:SmartTestingMavenConfigurer.java

示例5: should_purge_reports_directory

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
@Test
public void should_purge_reports_directory() throws IOException {
    // given
    copySurefireReports(project);
    MavenSession mavenSession = mock(MavenSession.class);
    MavenProject mavenProject = mock(MavenProject.class);
    when(mavenProject.getModel()).thenReturn(project);
    when(mavenSession.getAllProjects()).thenReturn(singletonList(mavenProject));
    File reportsDir = TemporaryInternalFiles.createTestReportDirAction(projectDir).getFile();

    // when
    new LocalStorage(projectDir).duringExecution().purge(null);

    // then
    softly.assertThat(reportsDir).doesNotExist();
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:17,代码来源:SurefireReportStorageTest.java

示例6: retrieveDependencyProjectsRecursively

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
private static void retrieveDependencyProjectsRecursively(List<MavenProject> result, MavenProject parent, ProjectBuilder projectBuilder, MavenSession session) {
    result.add(parent);
    List<Dependency> children = parent.getDependencies();
    if (children != null) {
        for (Dependency child : children) {
            if (COMPILE_SCOPE.equals(child.getScope())) {
                ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
                buildingRequest.setProject(null);
                Artifact artifact = convertDependencyToJarArtifact(child);
                try {
                    MavenProject dependencyProject = projectBuilder.build(artifact, buildingRequest).getProject();
                    retrieveDependencyProjectsRecursively(result, dependencyProject, projectBuilder, session);
                } catch (ProjectBuildingException skip) {
                    // no op
                }
            }
        }
    }
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:20,代码来源:MavenUtil.java

示例7: havingScmDeveloperConnection

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
private boolean havingScmDeveloperConnection( MavenSession session )
{
    if ( session.getTopLevelProject().getScm() == null )
    {
        LOGGER.error( "The incremental module builder needs a correct scm configuration." );
        return false;
    }

    if ( StringUtils.isEmpty( session.getTopLevelProject().getScm().getDeveloperConnection() ) )
    {
        LOGGER.error( "The incremental module builder needs the scm developerConnection to work properly." );
        return false;
    }

    return true;
}
 
开发者ID:khmarbaise,项目名称:incremental-module-builder,代码行数:17,代码来源:IncrementalModuleBuilder.java

示例8: MavenEnvironment

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
public MavenEnvironment(MavenSession aMavenSession, BuildPluginManager aBuildPluginManager, Log aLog,
        DependencyTreeBuilder aDependencyTreeBuilder, ArtifactRepository aLocalRepository,
        SecDispatcher aSecurityDispatcher, MavenProjectBuilder aProjectBuilder,
        LifecycleExecutor aLifecycleExecutor, ArtifactFactory aArtifactFactory,
        ArtifactMetadataSource aArtifactMetadataSource, ArtifactCollector aArtifactCollector, RuntimeInformation aRuntimeInformation,
        MojoExecution aExecution) {
    mavenSession = aMavenSession;
    buildPluginManager = aBuildPluginManager;
    log = aLog;
    dependencyTreeBuilder = aDependencyTreeBuilder;
    localRepository = aLocalRepository;
    securityDispatcher = aSecurityDispatcher;
    projectBuilder = aProjectBuilder;
    lifecycleExecutor = aLifecycleExecutor;
    artifactFactory = aArtifactFactory;
    artifactMetadataSource = aArtifactMetadataSource;
    artifactCollector = aArtifactCollector;
    runtimeInformation = aRuntimeInformation;
    mojoExecution = aExecution;
}
 
开发者ID:mirkosertic,项目名称:mavensonarsputnik,代码行数:21,代码来源:MavenEnvironment.java

示例9: setUp

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
@Before
public void setUp() {
  logOutput = mock(LogOutput.class);
  runtimeInformation = mock(RuntimeInformation.class, Mockito.RETURNS_DEEP_STUBS);
  mavenSession = mock(MavenSession.class);
  rootProject = mock(MavenProject.class);
  mojoExecution = mock(MojoExecution.class);
  envProps = new Properties();

  Properties system = new Properties();
  system.put("system", "value");
  system.put("user", "value");
  Properties root = new Properties();
  root.put("root", "value");
  envProps.put("env", "value");

  when(mojoExecution.getVersion()).thenReturn("2.0");
  when(runtimeInformation.getMavenVersion()).thenReturn("1.0");
  when(mavenSession.getSystemProperties()).thenReturn(system);
  when(mavenSession.getUserProperties()).thenReturn(new Properties());
  when(mavenSession.getSettings()).thenReturn(new Settings());
  when(rootProject.getProperties()).thenReturn(root);
  when(mavenSession.getCurrentProject()).thenReturn(rootProject);
  propertyDecryptor = new PropertyDecryptor(mock(Log.class), mock(SecDispatcher.class));
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:26,代码来源:ScannerFactoryTest.java

示例10: SetupsMojoTestHelper

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
public SetupsMojoTestHelper( AbstractSetupsMojo mojo ) throws IOException {
   this.workingDir = new File( System.getProperty( "java.io.tmpdir" ), "unit_test_working" );

   this.mojo = mojo;

   this.mojo.workingDir = this.workingDir.getCanonicalPath();
   this.mojo.root = FitNesseHelper.DEFAULT_ROOT;
   this.mojo.project = new MavenProject();
   this.mojo.project.setFile( new File( getClass().getResource( "pom.xml" ).getPath() ) );
   this.mojo.pluginDescriptor = new PluginDescriptor();
   this.mojo.pluginManager = mock( BuildPluginManager.class );
   this.mojo.session = mock( MavenSession.class );

   this.logStream = new ByteArrayOutputStream();
   this.mojo.setLog( new DefaultLog( new PrintStreamLogger( Logger.LEVEL_INFO, "test", new PrintStream( this.logStream ) ) ) );
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:17,代码来源:SetupsMojoTestHelper.java

示例11: afterSessionStart

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
@Override
public void afterSessionStart( MavenSession session )
    throws MavenExecutionException
{
    MavenExecutionRequest request = session.getRequest();

    DependencyVersionReportGenerator reportGenerator = new DependencyVersionReportGenerator( logger );

    if ( workspaceReader != null )
    {
        workspaceReader.addResolutionListener( mojoExecutionListener );
        workspaceReader.addResolutionListener( reportGenerator );
    }

    ChainedExecutionListener chainedListener = new ChainedExecutionListener();
    chainedListener.addExecutionListener( request.getExecutionListener() );
    chainedListener.addExecutionListener( reportGenerator );
    request.setExecutionListener( chainedListener );
}
 
开发者ID:fedora-java,项目名称:xmvn,代码行数:20,代码来源:XMvnMavenLifecycleParticipant.java

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

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

示例14: runMavenRequest

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
public void runMavenRequest(MavenExecutionRequest request, Runnable runnable) {
  DefaultMaven maven = (DefaultMaven) getMavenComponent(Maven.class);
  RepositorySystemSession repositorySystemSession = maven.newRepositorySession(request);
  request.getProjectBuildingRequest().setRepositorySession(repositorySystemSession);
  MavenSession mavenSession =
      new MavenSession(
          container, repositorySystemSession, request, new DefaultMavenExecutionResult());
  LegacySupport legacySupport = getMavenComponent(LegacySupport.class);
  MavenSession previousSession = legacySupport.getSession();
  legacySupport.setSession(mavenSession);
  try {
    for (AbstractMavenLifecycleParticipant participant :
        getLifecycleParticipants(Collections.emptyList())) {
      participant.afterSessionStart(mavenSession);
    }
    runnable.run();
  } catch (MavenExecutionException e) {
    throw new RuntimeException(e);
  } finally {
    legacySupport.setSession(previousSession);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:MavenServerImpl.java

示例15: createHelper

import org.apache.maven.execution.MavenSession; //导入依赖的package包/类
private DefaultVersionsHelper createHelper( String rulesUri, ArtifactMetadataSource metadataSource )
    throws MojoExecutionException
{
    final DefaultWagonManager wagonManager = new DefaultWagonManager()
    {
        public Wagon getWagon( Repository repository )
            throws UnsupportedProtocolException, WagonConfigurationException
        {
            return new FileWagon();
        }
    };

    DefaultVersionsHelper helper =
        new DefaultVersionsHelper( new DefaultArtifactFactory(), new DefaultArtifactResolver(), metadataSource, new ArrayList(),
                                   new ArrayList(),
                                   new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ),
                                   wagonManager, new Settings(), "", rulesUri, mock( Log.class ), mock( MavenSession.class ),
                                   new DefaultPathTranslator());
    return helper;
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:21,代码来源:DefaultVersionsHelperTest.java


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