List of usage examples for org.apache.maven.execution DefaultMavenExecutionRequest setUpdateSnapshots
@Override
public MavenExecutionRequest setUpdateSnapshots(boolean updateSnapshots)
From source file:com.bluexml.side.util.dependencies.MavenUtil.java
License:Open Source License
public MavenExecutionResult doMavenGoal(File baseDir, List<String> goals, Map<String, String> parameters, List<String> profiles, Boolean offline) throws Exception { System.out.println(baseDir.getAbsolutePath()); DefaultMavenExecutionRequest archetypeCreateRequest = new DefaultMavenExecutionRequest(); archetypeCreateRequest.setBaseDirectory(baseDir); archetypeCreateRequest.setGoals(goals); archetypeCreateRequest.setInteractiveMode(false); archetypeCreateRequest.setProperty("basedir", baseDir.getAbsolutePath().toString()); // set active profile if (profiles != null && !profiles.isEmpty()) { archetypeCreateRequest.addActiveProfiles(profiles); }/*from ww w . j a va 2 s . co m*/ // set offline if (offline != null) { archetypeCreateRequest.setOffline(offline); } if (parameters != null) { // manage additional parameters for (Map.Entry<String, String> param : parameters.entrySet()) { archetypeCreateRequest.setProperty(param.getKey(), param.getValue()); } } MavenEmbedder embedder = getEmbedder(); archetypeCreateRequest.setUpdateSnapshots(true); //System.out.println("Active profiles :"+archetypeCreateRequest.getActiveProfiles()); if (archetypeCreateRequest.getActiveProfiles().size() == 0) { throw new Exception("No active profile found report this bug to SIDE developers team"); } MavenExecutionResult result = embedder.execute(archetypeCreateRequest); return result; }
From source file:fitnesse.wikitext.widgets.Downloader.java
License:Apache License
public List<String> getArtifactAndDependencies(String pomUrl) throws MavenEmbedderException, XmlPullParserException, IOException, DependencyResolutionRequiredException, DownloadException { File pom = downloadPom(pomUrl); MavenEmbedder embedder = new MavenEmbedder(createConfiguration()); Model model = embedder.readModel(pom); File tmpPom = createPomWithProjectAsDependency(pom, model); DefaultMavenExecutionRequest defaultMavenExecutionRequest = new DefaultMavenExecutionRequest(); defaultMavenExecutionRequest.setUpdateSnapshots(true); MavenExecutionResult mavenResult = embedder .readProjectWithDependencies(defaultMavenExecutionRequest.setPom(tmpPom)); List compileClasspathElements = mavenResult.getProject().getCompileClasspathElements(); // little hack for now to remove source dir // TODO: find a way to have only jars elements, not sources elements compileClasspathElements.remove(0);/*from www .jav a 2s . c o m*/ return compileClasspathElements; }