use of org.apache.maven.execution.MavenExecutionRequest in project kie-wb-common by kiegroup.
the class AFSettingsXmlConfigurationProcessor method process.
@Override
public void process(AFCliRequest cliRequest) throws Exception {
CommandLine commandLine = cliRequest.getCommandLine();
String workingDirectory = cliRequest.getWorkingDirectory();
MavenExecutionRequest request = cliRequest.getRequest();
Path userSettingsFile;
if (commandLine.hasOption(CLIManager.ALTERNATE_USER_SETTINGS)) {
userSettingsFile = Paths.get(commandLine.getOptionValue(CLIManager.ALTERNATE_USER_SETTINGS));
userSettingsFile = resolvePath(userSettingsFile, workingDirectory);
if (!Files.isRegularFile(userSettingsFile)) {
throw new FileNotFoundException("The specified user settings file does not exist: " + userSettingsFile);
}
} else {
userSettingsFile = DEFAULT_USER_SETTINGS_FILE;
}
Path globalSettingsFile;
if (commandLine.hasOption(CLIManager.ALTERNATE_GLOBAL_SETTINGS)) {
globalSettingsFile = Paths.get(commandLine.getOptionValue(CLIManager.ALTERNATE_GLOBAL_SETTINGS));
globalSettingsFile = resolvePath(globalSettingsFile, workingDirectory);
if (!Files.isRegularFile(globalSettingsFile)) {
throw new FileNotFoundException("The specified global settings file does not exist: " + globalSettingsFile);
}
} else {
globalSettingsFile = DEFAULT_GLOBAL_SETTINGS_FILE;
}
request.setGlobalSettingsFile(globalSettingsFile.toFile());
request.setUserSettingsFile(userSettingsFile.toFile());
AFSettingsBuildingRequest settingsRequest = new AFSettingsBuildingRequest();
settingsRequest.setGlobalSettingsFile(globalSettingsFile.toFile());
settingsRequest.setUserSettingsFile(userSettingsFile.toFile());
settingsRequest.setSystemProperties(cliRequest.getSystemProperties());
settingsRequest.setUserProperties(cliRequest.getUserProperties());
if (request.getEventSpyDispatcher() != null) {
request.getEventSpyDispatcher().onEvent(settingsRequest);
}
logger.debug("Reading global settings from " + getLocation(settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsPath()));
logger.debug("Reading user settings from " + getLocation(settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsPath()));
SettingsBuildingResult settingsResult = settingsBuilder.build(settingsRequest);
if (request.getEventSpyDispatcher() != null) {
request.getEventSpyDispatcher().onEvent(settingsResult);
}
populateFromSettings(request, settingsResult.getEffectiveSettings());
if (!settingsResult.getProblems().isEmpty() && logger.isWarnEnabled()) {
logger.warn("");
logger.warn("Some problems were encountered while building the effective settings");
for (SettingsProblem problem : settingsResult.getProblems()) {
logger.warn(problem.getMessage() + " @ " + problem.getLocation());
}
logger.warn("");
}
}
use of org.apache.maven.execution.MavenExecutionRequest in project unleash-maven-plugin by shillner.
the class BuildProject method setupInvocationRequest.
private InvocationRequest setupInvocationRequest() throws MojoExecutionException {
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(this.project.getFile());
// installation and deployment are performed in a later step. We first need to ensure that there are no changes in
// the scm, ...
request.setGoals(this.goals);
request.setProperties(this.releaseArgs);
request.setProfiles(this.profiles);
request.setShellEnvironmentInherited(true);
for (String key : this.releaseEnvironmentVariables.keySet()) {
request.addShellEnvironment(key, this.releaseEnvironmentVariables.get(key));
}
request.addShellEnvironment("isUnleashBuild", "true");
request.setOffline(this.settings.isOffline());
request.setInteractive(this.settings.isInteractiveMode());
MavenExecutionRequest originalRequest = this.session.getRequest();
File globalSettingsFile = originalRequest.getGlobalSettingsFile();
if (globalSettingsFile != null && globalSettingsFile.exists() && globalSettingsFile.isFile()) {
request.setGlobalSettingsFile(globalSettingsFile);
}
File userSettingsFile = originalRequest.getUserSettingsFile();
if (userSettingsFile != null && userSettingsFile.exists() && userSettingsFile.isFile()) {
request.setUserSettingsFile(userSettingsFile);
}
File toolchainsFile = originalRequest.getUserToolchainsFile();
if (toolchainsFile.exists() && toolchainsFile.isFile()) {
request.setToolchainsFile(toolchainsFile);
}
return request;
}
use of org.apache.maven.execution.MavenExecutionRequest in project tycho by eclipse.
the class ArtifactDependencyWalkerTest method getTargetPlatform.
protected DependencyArtifacts getTargetPlatform() throws Exception {
LocalDependencyResolver resolver = (LocalDependencyResolver) lookup(DependencyResolver.class, LocalDependencyResolver.ROLE_HINT);
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setLocalRepository(new StubArtifactRepository(System.getProperty("java.io.tmpdir")));
MavenExecutionResult result = new DefaultMavenExecutionResult();
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
MavenSession session = new MavenSession(getContainer(), repositorySession, request, result);
session.setProjects(new ArrayList<MavenProject>());
lookup(LegacySupport.class).setSession(session);
MavenProject project = new MavenProject();
resolver.setLocation(new File("src/test/resources/targetplatforms/basic"));
DependencyArtifacts platform = resolver.resolveDependencies(session, project, null, DefaultReactorProject.adapt(session), null);
return platform;
}
use of org.apache.maven.execution.MavenExecutionRequest in project tycho by eclipse.
the class LocalDependencyResolverTest method getTargetPlatform.
protected DependencyArtifacts getTargetPlatform(File location) throws Exception, IOException {
LocalDependencyResolver resolver = (LocalDependencyResolver) lookup(DependencyResolver.class, LocalDependencyResolver.ROLE_HINT);
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setLocalRepository(new StubArtifactRepository(location.getAbsolutePath()));
MavenExecutionResult result = new DefaultMavenExecutionResult();
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
MavenSession session = new MavenSession(getContainer(), repositorySession, request, result);
session.setProjects(new ArrayList<MavenProject>());
lookup(LegacySupport.class).setSession(session);
MavenProject project = new MavenProject();
resolver.setLocation(location);
DependencyArtifacts platform = resolver.resolveDependencies(session, project, null, DefaultReactorProject.adapt(session), null);
return platform;
}
use of org.apache.maven.execution.MavenExecutionRequest in project tycho by eclipse.
the class AbstractTychoMojoTestCase method newMavenExecutionRequest.
protected MavenExecutionRequest newMavenExecutionRequest(File pom) throws Exception {
Properties systemProps = new Properties();
systemProps.putAll(System.getProperties());
Properties userProps = new Properties();
userProps.put("tycho-version", "0.0.0");
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setBaseDirectory(pom.getParentFile());
request.setPom(pom);
request.setSystemProperties(systemProps);
request.setUserProperties(userProps);
request.setLocalRepository(getLocalRepository());
request.setStartTime(new Date());
File settingsFile = getUserSettingsFile();
if (settingsFile.isFile()) {
request.setUserSettingsFile(settingsFile);
}
Settings settings = settingsBuilder.buildSettings(request);
requestPopulator.populateFromSettings(request, settings);
request.setGoals(Arrays.asList("validate"));
return request;
}
Aggregations