本文整理汇总了Java中org.apache.maven.MavenExecutionException类的典型用法代码示例。如果您正苦于以下问题:Java MavenExecutionException类的具体用法?Java MavenExecutionException怎么用?Java MavenExecutionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MavenExecutionException类属于org.apache.maven包,在下文中一共展示了MavenExecutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToPomForIndexingTmpBundles
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
public void addToPomForIndexingTmpBundles(MavenProject project) throws MavenExecutionException {
Path genertedModules;
try {
genertedModules = Constants.getGeneratedModulesFolder(project);
} catch (IOException e) {
throw new MavenExecutionException(e.getMessage(), e);
}
String configuration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" //
+ "<configuration>" //
+ " <inputDir>" //
+ genertedModules //
+ " </inputDir>" //
+ " <outputFile>${project.build.directory}/index/index.xml</outputFile>" //
+ "</configuration>"; //
Plugin plugin = createPlugin("biz.aQute.bnd", "bnd-indexer-maven-plugin", VAL_BND_VERSION, configuration,
"index", "local-index", null);
project.getBuild().getPlugins().add(0, plugin);
logger.info("Added `bnd-indexer-maven-plugin` to genrate an index of detected modules!");
}
示例2: afterProjectsRead
import org.apache.maven.MavenExecutionException; //导入依赖的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);
}
}
示例3: configureJarPlugin
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
private void configureJarPlugin(MavenProject project) throws MavenExecutionException {
Plugin jarPlugin = getPlugin(project, "org.apache.maven.plugins:maven-jar-plugin");
if (jarPlugin != null) {
StringBuilder jarConfig = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") //
.append("<configuration>") //
.append(" <archive>\n") //
.append(" <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>\n") //
.append(" </archive>") //
.append(" <annotationProcessorPaths>") //
.append(" <annotationProcessorPath>") //
.append(" <groupId>com.commsen.em</groupId>") //
.append(" <artifactId>em.annotation.processors</artifactId>") //
.append(" <version>").append(Constants.VAL_EXTENSION_VERSION).append("</version>") //
.append(" </annotationProcessorPath>") //
.append(" </annotationProcessorPaths>") //
.append("</configuration>");
configurePlugin(jarPlugin, "default-jar", jarConfig.toString());
}
}
示例4: createPlugin
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
protected Plugin createPlugin(String groupId, String artifactId, String version, String configuration,
String executionId, String goal, String phase) throws MavenExecutionException {
Plugin plugin = new Plugin();
plugin.setGroupId(groupId);
plugin.setArtifactId(artifactId);
plugin.setVersion(version);
PluginExecution execution = new PluginExecution();
execution.setId(executionId);
execution.addGoal(goal);
if (phase != null) {
execution.setPhase(phase);
}
if (configuration != null) {
execution.setConfiguration(mavenConfig.asXpp3Dom(configuration));
}
plugin.addExecution(execution);
return plugin;
}
示例5: asArtifact
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public Artifact asArtifact (ProjectBuildingRequest projectBuildingRequest, Dependency dependency) throws MavenExecutionException {
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(dependency.getGroupId());
coordinate.setArtifactId(dependency.getArtifactId());
coordinate.setVersion(dependency.getVersion());
coordinate.setExtension(dependency.getType());
coordinate.setClassifier(dependency.getClassifier());
ArtifactResult ar;
try {
ar = artifactResolver.resolveArtifact(projectBuildingRequest, coordinate);
} catch (ArtifactResolverException e) {
throw new MavenExecutionException("Failed to resolve artifact " + coordinate, e);
}
return ar.getArtifact();
}
示例6: afterProjectsRead
import org.apache.maven.MavenExecutionException; //导入依赖的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)));
}
示例7: getEnforcerPlugin
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
public Plugin getEnforcerPlugin(MavenProject project)
throws MavenExecutionException {
StringBuilder configString = new StringBuilder()
.append("<configuration><rules>")
.append("<requireReleaseDeps><message>No Snapshots Allowed!</message><excludes><exclude>"+project.getGroupId()+":*</exclude></excludes></requireReleaseDeps>")
.append("</rules></configuration>");
Xpp3Dom config = null;
try {
config = Xpp3DomBuilder.build(new StringReader(configString.toString()));
} catch (XmlPullParserException | IOException ex) {
throw new MavenExecutionException("Issue creating cofig for enforcer plugin", ex);
}
PluginExecution execution = new PluginExecution();
execution.setId("no-snapshot-deps");
execution.addGoal("enforce");
execution.setConfiguration(config);
Plugin result = new Plugin();
result.setArtifactId("maven-enforcer-plugin");
result.setVersion("1.4.1");
result.addExecution(execution);
return result;
}
示例8: testAfterSessionStart_nullRevision
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
@Test
public void testAfterSessionStart_nullRevision()
throws MavenExecutionException,
RevisionGeneratorException {
String revision = null;
exceptions.expect(MavenExecutionException.class);
exceptions.expectMessage("RevisionGenerator returned a null revision value");
exceptions.expectCause(IsInstanceOf.any(RevisionGeneratorException.class));
when(revisionGenerator.getRevision()).thenReturn(revision);
try {
item.afterSessionStart(session);
} finally {
verify(revisionGenerator).init(eq(session), any(Logger.class));
verify(revisionGenerator).getRevision();
verifyNoMoreInteractions(revisionGenerator);
verifyZeroInteractions(session);
verifyZeroInteractions(pluginMerger);
verifyZeroInteractions(plugins);
}
}
示例9: afterSessionStart_initThrowsRevisionGeneratorException
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
@Test
public void afterSessionStart_initThrowsRevisionGeneratorException()
throws MavenExecutionException,
RevisionGeneratorException {
RevisionGeneratorException exception = new RevisionGeneratorException("msg", new RuntimeException("dummy sub cause"));
exceptions.expect(MavenExecutionException.class);
exceptions.expectMessage(exception.getMessage());
exceptions.expectCause(IsEqual.equalTo(exception));
doThrow(exception).when(revisionGenerator).init(eq(session), any(Logger.class));
try {
item.afterSessionStart(session);
} finally {
verify(revisionGenerator).init(eq(session), any(Logger.class));
}
}
示例10: afterSessionStart_initThrowsRuntimeException
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
@Test
public void afterSessionStart_initThrowsRuntimeException()
throws MavenExecutionException,
RevisionGeneratorException {
RuntimeException exception = new RuntimeException("random exception");
exceptions.expect(MavenExecutionException.class);
exceptions.expectMessage("Unexpected Exception during RevisionGenerator Initialisation");
exceptions.expectCause(IsEqual.equalTo(exception));
doThrow(exception).when(revisionGenerator).init(eq(session), any(Logger.class));
try {
item.afterSessionStart(session);
} finally {
verify(revisionGenerator).init(eq(session), any(Logger.class));
}
}
示例11: testGetEnforcerPlugin
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
@Test
public void testGetEnforcerPlugin()
throws MavenExecutionException,
XmlPullParserException,
IOException {
Plugin result = item.getEnforcerPlugin();
Assert.assertEquals("GroupId", "org.apache.maven.plugins", result.getGroupId());
Assert.assertEquals("ArtifactId", "maven-enforcer-plugin", result.getArtifactId());
Assert.assertEquals("Version", "1.4.1", result.getVersion());
Assert.assertEquals("Executions.Size", 1, result.getExecutions().size());
PluginExecution execution = result.getExecutions().get(0);
Assert.assertEquals("Executions[0].Id", "no-snapshot-deps", execution.getId());
Assert.assertEquals("Executions[0].Goals.Size", 1, execution.getGoals().size());
Assert.assertEquals("Executions[0].Goals[0]", "enforce", execution.getGoals().get(0));
Assert.assertEquals("Executions[0].Configuration",
Xpp3DomBuilder.build(new StringReader("<configuration><rules><requireReleaseDeps><message>No Snapshots Allowed!</message></requireReleaseDeps></rules></configuration>")),
execution.getConfiguration());
}
示例12: testGetVersionFixPlugin
import org.apache.maven.MavenExecutionException; //导入依赖的package包/类
@Test
public void testGetVersionFixPlugin()
throws MavenExecutionException,
XmlPullParserException,
IOException {
Plugin result = item.getVersionFixPlugin();
Assert.assertEquals("GroupId", "com.iggroup.maven.cdversion", result.getGroupId());
Assert.assertEquals("ArtifactId", "versionfix-maven-plugin", result.getArtifactId());
Assert.assertEquals("Version", "1.0.0-SNAPSHOT", result.getVersion());
Assert.assertEquals("Executions.Size", 1, result.getExecutions().size());
PluginExecution execution = result.getExecutions().get(0);
Assert.assertEquals("Executions[0].Id", "versionfix", execution.getId());
Assert.assertEquals("Executions[0].Goals.Size", 1, execution.getGoals().size());
Assert.assertEquals("Executions[0].Goals[0]", "versionfix", execution.getGoals().get(0));
}
示例13: afterSessionStart
import org.apache.maven.MavenExecutionException; //导入依赖的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 );
}
示例14: loadExtensions
import org.apache.maven.MavenExecutionException; //导入依赖的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);
}
}
}
}
示例15: runMavenRequest
import org.apache.maven.MavenExecutionException; //导入依赖的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);
}
}