本文整理匯總了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);
}
}
示例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();
}
示例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)));
}
示例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());
}
}
示例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();
}
示例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
}
}
}
}
}
示例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;
}
示例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;
}
示例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));
}
示例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 ) ) ) );
}
示例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 );
}
示例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");
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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;
}