List of usage examples for org.apache.maven.execution MavenExecutionRequest getUserSettingsFile
File getUserSettingsFile();
From source file:hudson.maven.MavenEmbedder.java
License:Apache License
protected MavenExecutionRequest buildMavenExecutionRequest(MavenRequest mavenRequest) throws MavenEmbedderException, ComponentLookupException { MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest(); if (mavenRequest.getGlobalSettingsFile() != null) { mavenExecutionRequest.setGlobalSettingsFile(new File(mavenRequest.getGlobalSettingsFile())); }//from w w w . ja v a 2 s . c o m if (mavenExecutionRequest.getUserSettingsFile() != null) { mavenExecutionRequest.setUserSettingsFile(new File(mavenRequest.getUserSettingsFile())); } try { lookup(MavenExecutionRequestPopulator.class).populateFromSettings(mavenExecutionRequest, getSettings()); lookup(MavenExecutionRequestPopulator.class).populateDefaults(mavenExecutionRequest); } catch (MavenExecutionRequestPopulationException e) { throw new MavenEmbedderException(e.getMessage(), e); } ArtifactRepository localRepository = getLocalRepository(); mavenExecutionRequest.setLocalRepository(localRepository); mavenExecutionRequest.setLocalRepositoryPath(localRepository.getBasedir()); mavenExecutionRequest.setOffline(mavenRequest.isOffline()); mavenExecutionRequest.setUpdateSnapshots(mavenRequest.isUpdateSnapshots()); // TODO check null and create a console one ? mavenExecutionRequest.setTransferListener(mavenRequest.getTransferListener()); mavenExecutionRequest.setCacheNotFound(mavenRequest.isCacheNotFound()); mavenExecutionRequest.setCacheTransferError(true); mavenExecutionRequest.setUserProperties(mavenRequest.getUserProperties()); mavenExecutionRequest.getSystemProperties().putAll(System.getProperties()); if (mavenRequest.getSystemProperties() != null) { mavenExecutionRequest.getSystemProperties().putAll(mavenRequest.getSystemProperties()); } mavenExecutionRequest.getSystemProperties().putAll(getEnvVars()); if (this.mavenHome != null) { mavenExecutionRequest.getSystemProperties().put("maven.home", this.mavenHome.getAbsolutePath()); } if (mavenRequest.getProfiles() != null && !mavenRequest.getProfiles().isEmpty()) { for (String id : mavenRequest.getProfiles()) { Profile p = new Profile(); p.setId(id); p.setSource("cli"); mavenExecutionRequest.addProfile(p); mavenExecutionRequest.addActiveProfile(id); } } mavenExecutionRequest.setLoggingLevel(mavenRequest.getLoggingLevel()); lookup(Logger.class).setThreshold(mavenRequest.getLoggingLevel()); mavenExecutionRequest.setExecutionListener(mavenRequest.getExecutionListener()) .setInteractiveMode(mavenRequest.isInteractive()) .setGlobalChecksumPolicy(mavenRequest.getGlobalChecksumPolicy()).setGoals(mavenRequest.getGoals()); if (mavenRequest.getPom() != null) { mavenExecutionRequest.setPom(new File(mavenRequest.getPom())); } if (mavenRequest.getWorkspaceReader() != null) { mavenExecutionRequest.setWorkspaceReader(mavenRequest.getWorkspaceReader()); } // FIXME inactive profiles //this.mavenExecutionRequest.set return mavenExecutionRequest; }
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.ja v a2s . c o 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; }
From source file:org.kie.scanner.embedder.MavenEmbedder.java
License:Apache License
protected MavenExecutionRequest buildMavenExecutionRequest(MavenRequest mavenRequest) throws MavenEmbedderException, ComponentLookupException { MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest(); if (mavenRequest.getGlobalSettingsFile() != null) { mavenExecutionRequest.setGlobalSettingsFile(new File(mavenRequest.getGlobalSettingsFile())); }// w w w. ja v a2 s . com if (mavenExecutionRequest.getUserSettingsFile() != null) { mavenExecutionRequest.setUserSettingsFile(new File(mavenRequest.getUserSettingsFile())); } try { lookup(MavenExecutionRequestPopulator.class).populateFromSettings(mavenExecutionRequest, getSettings()); lookup(MavenExecutionRequestPopulator.class).populateDefaults(mavenExecutionRequest); } catch (MavenExecutionRequestPopulationException e) { throw new MavenEmbedderException(e.getMessage(), e); } ArtifactRepository localRepository = getLocalRepository(); mavenExecutionRequest.setLocalRepository(localRepository); mavenExecutionRequest.setLocalRepositoryPath(localRepository.getBasedir()); mavenExecutionRequest.setOffline(mavenRequest.isOffline()); mavenExecutionRequest.setUpdateSnapshots(mavenRequest.isUpdateSnapshots()); // TODO check null and create a console one ? mavenExecutionRequest.setTransferListener(mavenRequest.getTransferListener()); mavenExecutionRequest.setCacheNotFound(mavenRequest.isCacheNotFound()); mavenExecutionRequest.setCacheTransferError(true); mavenExecutionRequest.setUserProperties(mavenRequest.getUserProperties()); mavenExecutionRequest.getSystemProperties().putAll(System.getProperties()); if (mavenRequest.getSystemProperties() != null) { mavenExecutionRequest.getSystemProperties().putAll(mavenRequest.getSystemProperties()); } mavenExecutionRequest.getSystemProperties().putAll(getEnvVars()); if (this.mavenHome != null) { mavenExecutionRequest.getSystemProperties().put("maven.home", this.mavenHome.getAbsolutePath()); } if (mavenRequest.getProfiles() != null && !mavenRequest.getProfiles().isEmpty()) { for (String id : mavenRequest.getProfiles()) { Profile p = new Profile(); p.setId(id); p.setSource("cli"); mavenExecutionRequest.addProfile(p); mavenExecutionRequest.addActiveProfile(id); } } mavenExecutionRequest.setLoggingLevel(mavenRequest.getLoggingLevel()); lookup(Logger.class).setThreshold(mavenRequest.getLoggingLevel()); mavenExecutionRequest.setExecutionListener(mavenRequest.getExecutionListener()) .setInteractiveMode(mavenRequest.isInteractive()) .setGlobalChecksumPolicy(mavenRequest.getGlobalChecksumPolicy()).setGoals(mavenRequest.getGoals()); if (mavenRequest.getPom() != null) { mavenExecutionRequest.setPom(new File(mavenRequest.getPom())); } if (mavenRequest.getWorkspaceReader() != null) { mavenExecutionRequest.setWorkspaceReader(mavenRequest.getWorkspaceReader()); } return mavenExecutionRequest; }
From source file:org.sourcepit.common.maven.testing.EmbeddedMaven.java
License:Apache License
public void populateDefaults(final MavenExecutionRequest request) throws Exception, MavenExecutionRequestPopulationException { request.setExecutionListener(eventSpyDispatcher.chainListener(new ExecutionEventLogger(logger))); request.setTransferListener(new BatchModeMavenTransferListener(System.out)); final SettingsBuildingResult settingsResult = buildSettings(null, request.getUserSettingsFile(), request.getSystemProperties(), request.getUserProperties()); executionRequestPopulator.populateFromSettings(request, settingsResult.getEffectiveSettings()); if (localRepo != null) { request.setLocalRepositoryPath(localRepo); }/*from w w w . j ava2 s.c o m*/ if (remoteRepo != null) { request.getRemoteRepositories().add(getRemoteRepository()); } executionRequestPopulator.populateDefaults(request); }