List of usage examples for org.apache.maven.execution MavenExecutionRequest getGlobalSettingsFile
File getGlobalSettingsFile();
From source file:io.takari.maven.testing.Maven30xRuntime.java
License:Open Source License
@SuppressWarnings("deprecation") protected MavenExecutionRequest newExecutionRequest() throws Exception { // system properties Properties buildProperties = getMavenBuildProperties(); String mavenVersion = buildProperties.getProperty("version"); Properties systemProperties = new Properties(); systemProperties.putAll(System.getProperties()); // TODO not thread safe systemProperties.setProperty("maven.version", mavenVersion); systemProperties.setProperty("maven.build.version", mavenVersion); // request with initial configuration MavenExecutionRequest request = new DefaultMavenExecutionRequest(); request.setLocalRepositoryPath(properties.getLocalRepository()); request.setUserSettingsFile(properties.getUserSettings()); request.setGlobalSettingsFile(properties.getGlobalSettings()); request.setOffline(properties.getOffline()); request.setUpdateSnapshots(properties.getUpdateSnapshots()); request.setSystemProperties(systemProperties); // read settings SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest(); settingsRequest.setGlobalSettingsFile(request.getGlobalSettingsFile()); settingsRequest.setUserSettingsFile(request.getUserSettingsFile()); settingsRequest.setSystemProperties(request.getSystemProperties()); settingsRequest.setUserProperties(request.getUserProperties()); Settings settings = lookup(SettingsBuilder.class).build(settingsRequest).getEffectiveSettings(); MavenExecutionRequestPopulator populator = container.lookup(MavenExecutionRequestPopulator.class); request = populator.populateFromSettings(request, settings); return populator.populateDefaults(request); }
From source file:org.jboss.shrinkwrap.resolver.plugin.PropagateExecutionContextMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException { MavenExecutionRequest request = session.getRequest(); Properties properties = request.getUserProperties(); // set pom file File pom = session.getCurrentProject().getFile(); if (pom != null) { updateUserProperty(properties, "pom-file", pom.getAbsolutePath()); }/* w w w. j a v a 2 s .co m*/ // set offline flag updateUserProperty(properties, "offline", String.valueOf(session.isOffline())); // set settings.xml files File userSettings = request.getUserSettingsFile(); if (userSettings != null) { updateUserProperty(properties, "user-settings", userSettings.getAbsolutePath()); } File globalSettings = request.getGlobalSettingsFile(); if (globalSettings != null) { updateUserProperty(properties, "global-settings", globalSettings.getAbsolutePath()); } // set active profiles List<Profile> profiles = session.getCurrentProject().getActiveProfiles(); StringBuilder sb = new StringBuilder(); for (Profile p : profiles) { sb.append(p.getId()).append(","); } if (sb.length() > 0) { updateUserProperty(properties, "active-profiles", sb.substring(0, sb.length() - 1).toString()); } request.setUserProperties(properties); }
From source file:org.jenkinsci.plugins.pipeline.maven.eventspy.handler.MavenExecutionRequestHandler.java
License:Open Source License
@Override protected boolean _handle(MavenExecutionRequest request) { Xpp3Dom root = new Xpp3Dom("MavenExecutionRequest"); root.setAttribute("class", request.getClass().getName()); root.addChild(newElement("pom", request.getPom())); root.addChild(newElement("globalSettingsFile", request.getGlobalSettingsFile())); root.addChild(newElement("userSettingsFile", request.getUserSettingsFile())); root.addChild(newElement("baseDirectory", request.getBaseDirectory())); reporter.print(root);//from w w w. j a v a 2 s . c om return true; }