use of org.apache.maven.execution.ReactorManager in project intellij-community by JetBrains.
the class MavenEmbedder method execute.
@NotNull
public MavenExecutionResult execute(@NotNull final File file, @NotNull final List<String> activeProfiles, @NotNull final List<String> inactiveProfiles, @NotNull final List<String> goals, @NotNull final List<String> selectedProjects, boolean alsoMake, boolean alsoMakeDependents) {
try {
MavenExecutionRequest request = createRequest(file, activeProfiles, inactiveProfiles, goals);
if (!selectedProjects.isEmpty()) {
request.setRecursive(true);
request.setSelectedProjects(selectedProjects);
if (alsoMake && alsoMakeDependents) {
request.setMakeBehavior(ReactorManager.MAKE_BOTH_MODE);
} else if (alsoMake) {
request.setMakeBehavior(ReactorManager.MAKE_MODE);
} else if (alsoMakeDependents) {
request.setMakeBehavior(ReactorManager.MAKE_DEPENDENTS_MODE);
}
}
Maven maven = getComponent(Maven.class);
Method method = maven.getClass().getDeclaredMethod("doExecute", MavenExecutionRequest.class, EventDispatcher.class);
method.setAccessible(true);
ReactorManager reactor = (ReactorManager) method.invoke(maven, request, request.getEventDispatcher());
return new MavenExecutionResult(reactor.getTopLevelProject(), Collections.<Exception>emptyList());
} catch (InvocationTargetException e) {
return handleException(e.getTargetException());
} catch (NoSuchMethodException e) {
// should never happen
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
// should never happen
throw new RuntimeException(e);
}
}
use of org.apache.maven.execution.ReactorManager in project maven-plugins by apache.
the class RemoteResourcesMojoTest method lookupProcessMojoWithSettings.
protected ProcessRemoteResourcesMojo lookupProcessMojoWithSettings(final MavenProject project, ArrayList<String> bundles) throws Exception {
final ProcessRemoteResourcesMojo mojo = lookupProcessMojo();
MavenSession session = new MavenSession(getContainer(), // Settings settings,
null, // ArtifactRepository localRepository,
null, // EventDispatcher eventDispatcher,
null, new ReactorManager(new ArrayList<MavenProject>()), Arrays.asList("install"), project.getBasedir().toString(), new Properties(), Calendar.getInstance().getTime());
setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
setVariableValueToObject(mojo, "resourceBundles", bundles);
setVariableValueToObject(mojo, "mavenSession", session);
setVariableValueToObject(mojo, "remoteArtifactRepositories", project.getRemoteArtifactRepositories());
setVariableValueToObject(mojo, "resources", project.getResources());
return mojo;
}
Aggregations