use of org.apache.maven.execution.MavenExecutionRequest in project pom-manipulation-ext by release-engineering.
the class DistributionEnforcingManipulatorTest method setMavenSession.
private void setMavenSession() throws Exception {
final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties(userCliProperties).setRemoteRepositories(Collections.<ArtifactRepository>emptyList());
final PlexusContainer container = new DefaultPlexusContainer();
final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult());
session.setMavenSession(mavenSession);
}
use of org.apache.maven.execution.MavenExecutionRequest in project pom-manipulation-ext by release-engineering.
the class PropertiesUtilsTest method createUpdateSession.
private ManipulationSession createUpdateSession() throws Exception {
ManipulationSession session = new ManipulationSession();
session.setState(new DependencyState(p));
session.setState(new VersioningState(p));
session.setState(new CommonState(p));
final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties(p).setRemoteRepositories(Collections.<ArtifactRepository>emptyList());
final PlexusContainer container = new DefaultPlexusContainer();
final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult());
session.setMavenSession(mavenSession);
return session;
}
use of org.apache.maven.execution.MavenExecutionRequest in project maven-resources-plugin by apache.
the class ResourcesMojoTest method testResourceSystemProperties_Filtering.
/**
* @throws Exception
*/
public void testResourceSystemProperties_Filtering() throws Exception {
File testPom = new File(getBasedir(), defaultPomFilePath);
ResourcesMojo mojo = (ResourcesMojo) lookupMojo("resources", testPom);
MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourceSystemProperties_Filtering");
List<Resource> resources = project.getBuild().getResources();
assertNotNull(mojo);
project.addFile("file4.txt", "current-working-directory = ${user.dir}");
project.setResourceFiltering(0, true);
project.setupBuildEnvironment();
// setVariableValueToObject(mojo,"encoding","UTF-8");
setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(mojo, "resources", resources);
setVariableValueToObject(mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
setVariableValueToObject(mojo, "escapeWindowsPaths", Boolean.TRUE);
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setSystemProperties(System.getProperties());
MavenSession mavenSession = new MavenSession((PlexusContainer) null, (RepositorySystemSession) null, request, null);
setVariableValueToObject(mojo, "session", mavenSession);
mojo.execute();
String resourcesDir = project.getOutputDirectory();
File userDir = new File(System.getProperty("user.dir"));
assertTrue(userDir.exists());
Properties props = new Properties();
final FileInputStream inStream = new FileInputStream(new File(resourcesDir, "file4.txt"));
try {
props.load(inStream);
} finally {
inStream.close();
}
File fileFromFiltering = new File(props.getProperty("current-working-directory"));
assertTrue(fileFromFiltering.getAbsolutePath() + " does not exist.", fileFromFiltering.exists());
assertEquals(userDir.getAbsolutePath(), fileFromFiltering.getAbsolutePath());
}
use of org.apache.maven.execution.MavenExecutionRequest in project kie-wb-common by kiegroup.
the class ReusableAFMavenCli method loadCoreExtensions.
protected List<CoreExtensionEntry> loadCoreExtensions(AFCliRequest cliRequest, ClassRealm containerRealm, Set<String> providedArtifacts) {
if (cliRequest.getMultiModuleProjectDirectory() == null) {
return Collections.emptyList();
}
Path extensionsFile = Paths.get(cliRequest.getMultiModuleProjectDirectory().toString(), EXTENSIONS_FILENAME);
if (!java.nio.file.Files.isRegularFile(extensionsFile)) {
return Collections.emptyList();
}
try {
List<CoreExtension> extensions = readCoreExtensionsDescriptor(extensionsFile);
if (extensions.isEmpty()) {
return Collections.emptyList();
}
ContainerConfiguration cc = //
new DefaultContainerConfiguration().setClassWorld(//
cliRequest.getClassWorld()).setRealm(//
containerRealm).setClassPathScanning(//
PlexusConstants.SCANNING_INDEX).setAutoWiring(//
true).setName("maven");
if (reusableContainerCoreExtensions == null) {
reusableContainerCoreExtensions = new DefaultPlexusContainer(cc, new AbstractModule() {
@Override
protected void configure() {
bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory);
}
});
}
try {
reusableContainerCoreExtensions.setLookupRealm(null);
((DefaultPlexusContainer) reusableContainerCoreExtensions).setLoggerManager(plexusLoggerManager);
((DefaultPlexusContainer) reusableContainerCoreExtensions).getLoggerManager().setThresholds(cliRequest.getRequest().getLoggingLevel());
Thread.currentThread().setContextClassLoader(reusableContainerCoreExtensions.getContainerRealm());
reusableExecutionRequestPopulator = reusableContainerCoreExtensions.lookup(MavenExecutionRequestPopulator.class);
reusableConfigurationProcessors = reusableContainerCoreExtensions.lookupMap(AFConfigurationProcessor.class);
configure(cliRequest);
MavenExecutionRequest request = DefaultMavenExecutionRequest.copy(cliRequest.getRequest());
request = populateRequest(cliRequest, request);
request = reusableExecutionRequestPopulator.populateDefaults(request);
BootstrapCoreExtensionManager resolver = reusableContainerCoreExtensions.lookup(BootstrapCoreExtensionManager.class);
reusableExtensions = resolver.loadCoreExtensions(request, providedArtifacts, extensions);
return reusableExtensions;
} finally {
reusableExecutionRequestPopulator = null;
}
} catch (RuntimeException e) {
// runtime exceptions are most likely bugs in maven, let them bubble up to the user
throw e;
} catch (Exception e) {
reusableSlf4jLogger.warn("Failed to read extensions descriptor " + extensionsFile + ": " + e.getMessage());
}
return Collections.emptyList();
}
use of org.apache.maven.execution.MavenExecutionRequest in project tycho by eclipse.
the class DependencyComputerTest method testTYCHO0378unwantedSelfDependency.
@Test
public void testTYCHO0378unwantedSelfDependency() throws Exception {
File basedir = getBasedir("projects/TYCHO0378unwantedSelfDependency");
File pom = new File(basedir, "pom.xml");
MavenExecutionRequest request = newMavenExecutionRequest(pom);
request.getProjectBuildingRequest().setProcessPlugins(false);
MavenExecutionResult result = maven.execute(request);
Assert.assertEquals(0, result.getProject().getDependencies().size());
}
Aggregations