List of usage examples for org.apache.maven.project DefaultProjectBuilderConfiguration DefaultProjectBuilderConfiguration
public DefaultProjectBuilderConfiguration()
From source file:com.cedarsoft.fish.maven.MavenCompletionGenerator.java
public void execute() throws MojoExecutionException, MojoFailureException { getLog().info("Executing..."); try {/*from w ww . j ava 2 s . c o m*/ DefaultProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); configuration.setLocalRepository(localRepository); project = projectBuilder.buildStandaloneSuperProject(configuration); addDefaultPlugins(); addMojoHausPlugins(); addOtherPlugins(); //plugin.setGroupId("net.sourceforge.cobertura"); //plugin.setArtifactId("cobertura"); //plugin.setVersion("2.1.1"); // //plugin.setGroupId("com.cedarsoft.fish"); //plugin.setArtifactId("maven"); //plugin.setVersion("1.0.0-SNAPSHOT"); // ////Old plugin? //plugin.setGroupId("maven-plugins"); //plugin.setArtifactId("maven-cobertura-plugin"); //plugin.setVersion("1.4"); for (Plugin plugin : plugins) { printCompletion(plugin); } } catch (ProjectBuildingException | PluginManagerException | ArtifactResolutionException | PluginNotFoundException | PluginVersionNotFoundException | InvalidPluginException | ArtifactNotFoundException | PluginVersionResolutionException | InvalidVersionSpecificationException e) { throw new RuntimeException(e); } }
From source file:com.greenpepper.maven.runner.CommandLineRunner.java
License:Open Source License
private void interpolateProject() throws InitializationException, Exception, ModelInterpolationException { StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator(new DefaultPathTranslator()); interpolator.enableLogging(new PlexusLoggerAdapter(embedder.getLogger())); interpolator.initialize();//from w ww. j av a 2 s . co m ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); config.setLocalRepository(getLocalRepository()); config.setGlobalProfileManager(getProfileManager()); interpolator.interpolate(project.getModel(), project.getBasedir(), config, logger.isDebugEnabled()); }
From source file:com.pongasoft.maven.ant.tasks.ResolveTask.java
License:Apache License
private MavenProject createMavenProject() { MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup(MavenProjectBuilder.ROLE); try {/* w ww . j av a2s .com*/ ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); config.setLocalRepository(_localRepo).setGlobalProfileManager(getProfileManager()); return projectBuilder.buildStandaloneSuperProject(config); } catch (ProjectBuildingException e) { throw new BuildException(e); } }
From source file:de.jiac.micro.mojo.ConfiguratorMojo.java
License:Open Source License
private Model checkModel(Model model) throws ModelInterpolationException, ProjectBuildingException { if (model.getParent() != null) { Parent parent = model.getParent(); Artifact parentArt = artifactFactory.createArtifact(parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), "compile", "pom"); MavenProject parentProj = mavenProjectBuilder.buildFromRepository(parentArt, remoteRepositories, localRepository);//from w w w . j a va 2 s .c o m Model parentModel = parentProj.getModel(); if (parentModel.getParent() != null) { parentModel = checkModel(parentModel); } modelInheritanceAssembler.assembleModelInheritance(model, parentModel); } DefaultProjectBuilderConfiguration projectBuilderConfig = new DefaultProjectBuilderConfiguration(); projectBuilderConfig.setExecutionProperties(model.getProperties()); return modelInterpolator.interpolate(model, null, projectBuilderConfig, true); }
From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java
License:Apache License
/** * Returns the pluginManagement section of the super-pom. * * @return Returns the pluginManagement section of the super-pom. * @throws MojoExecutionException when things go wrong. *//*from www . j a va2 s . c o m*/ private Map<String, String> getSuperPomPluginManagement() throws MojoExecutionException { if (new DefaultArtifactVersion("3.0").compareTo(runtimeInformation.getApplicationVersion()) <= 0) { getLog().debug("Using Maven 3.x strategy to determine superpom defined plugins"); try { Method getPluginsBoundByDefaultToAllLifecycles = LifecycleExecutor.class .getMethod("getPluginsBoundByDefaultToAllLifecycles", new Class[] { String.class }); Set<Plugin> plugins = (Set<Plugin>) getPluginsBoundByDefaultToAllLifecycles .invoke(lifecycleExecutor, new Object[] { getProject().getPackaging() }); // we need to provide a copy with the version blanked out so that inferring from super-pom // works as for 2.x as 3.x fills in the version on us! Map<String, String> result = new LinkedHashMap<String, String>(plugins.size()); for (Plugin plugin : plugins) { result.put(getPluginCoords(plugin), getPluginVersion(plugin)); } URL superPom = getClass().getClassLoader().getResource("org/apache/maven/model/pom-4.0.0.xml"); if (superPom != null) { try { Reader reader = ReaderFactory.newXmlReader(superPom); try { StringBuilder buf = new StringBuilder(IOUtil.toString(reader)); ModifiedPomXMLEventReader pom = newModifiedPomXER(buf); Pattern pathRegex = Pattern.compile("/project(/profiles/profile)?" + "((/build(/pluginManagement)?)|(/reporting))" + "/plugins/plugin"); Stack<StackState> pathStack = new Stack<StackState>(); StackState curState = null; while (pom.hasNext()) { XMLEvent event = pom.nextEvent(); if (event.isStartDocument()) { curState = new StackState(""); pathStack.clear(); } else if (event.isStartElement()) { String elementName = event.asStartElement().getName().getLocalPart(); if (curState != null && pathRegex.matcher(curState.path).matches()) { if ("groupId".equals(elementName)) { curState.groupId = pom.getElementText().trim(); continue; } else if ("artifactId".equals(elementName)) { curState.artifactId = pom.getElementText().trim(); continue; } else if ("version".equals(elementName)) { curState.version = pom.getElementText().trim(); continue; } } pathStack.push(curState); curState = new StackState(curState.path + "/" + elementName); } else if (event.isEndElement()) { if (curState != null && pathRegex.matcher(curState.path).matches()) { if (curState.artifactId != null) { Plugin plugin = new Plugin(); plugin.setArtifactId(curState.artifactId); plugin.setGroupId(curState.groupId == null ? PomHelper.APACHE_MAVEN_PLUGINS_GROUPID : curState.groupId); plugin.setVersion(curState.version); if (!result.containsKey(getPluginCoords(plugin))) { result.put(getPluginCoords(plugin), getPluginVersion(plugin)); } } } curState = pathStack.pop(); } } } finally { IOUtil.close(reader); } } catch (IOException e) { // ignore } catch (XMLStreamException e) { // ignore } } return result; } catch (NoSuchMethodException e1) { // no much we can do here } catch (InvocationTargetException e1) { // no much we can do here } catch (IllegalAccessException e1) { // no much we can do here } } getLog().debug("Using Maven 2.x strategy to determine superpom defined plugins"); Map<String, String> superPomPluginManagement = new HashMap(); try { MavenProject superProject = projectBuilder .buildStandaloneSuperProject(new DefaultProjectBuilderConfiguration()); superPomPluginManagement.putAll(getPluginManagement(superProject.getOriginalModel())); } catch (ProjectBuildingException e) { throw new MojoExecutionException("Could not determine the super pom.xml", e); } return superPomPluginManagement; }
From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java
License:Apache License
/** * @throws MojoExecutionException when things go wrong * @throws MojoFailureException when things go wrong in a very bad way * @see AbstractVersionsUpdaterMojo#execute() * @since 1.0-alpha-1/*from w w w . java 2s . com*/ */ public void execute() throws MojoExecutionException, MojoFailureException { logInit(); Set<String> pluginsWithVersionsSpecified; try { pluginsWithVersionsSpecified = findPluginsWithVersionsSpecified(getProject()); } catch (XMLStreamException e) { throw new MojoExecutionException(e.getMessage(), e); } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); } Map<String, String> superPomPluginManagement = getSuperPomPluginManagement(); getLog().debug("superPom plugins = " + superPomPluginManagement); Map<String, String> parentPluginManagement = new HashMap<String, String>(); Map<String, String> parentBuildPlugins = new HashMap<String, String>(); Map<String, String> parentReportPlugins = new HashMap<String, String>(); List<MavenProject> parents = getParentProjects(getProject()); for (MavenProject parentProject : parents) { getLog().debug("Processing parent: " + parentProject.getGroupId() + ":" + parentProject.getArtifactId() + ":" + parentProject.getVersion() + " -> " + parentProject.getFile()); StringWriter writer = new StringWriter(); boolean havePom = false; Model interpolatedModel; try { Model originalModel = parentProject.getOriginalModel(); if (originalModel == null) { getLog().warn("project.getOriginalModel()==null for " + parentProject.getGroupId() + ":" + parentProject.getArtifactId() + ":" + parentProject.getVersion() + " is null, substituting project.getModel()"); originalModel = parentProject.getModel(); } try { new MavenXpp3Writer().write(writer, originalModel); writer.close(); havePom = true; } catch (IOException e) { // ignore } interpolatedModel = modelInterpolator.interpolate(originalModel, null, new DefaultProjectBuilderConfiguration() .setExecutionProperties(getProject().getProperties()), false); } catch (ModelInterpolationException e) { throw new MojoExecutionException(e.getMessage(), e); } if (havePom) { try { Set<String> withVersionSpecified = findPluginsWithVersionsSpecified( new StringBuilder(writer.toString())); Map<String, String> map = getPluginManagement(interpolatedModel); map.keySet().retainAll(withVersionSpecified); parentPluginManagement.putAll(map); map = getBuildPlugins(interpolatedModel, true); map.keySet().retainAll(withVersionSpecified); parentPluginManagement.putAll(map); map = getReportPlugins(interpolatedModel, true); map.keySet().retainAll(withVersionSpecified); parentPluginManagement.putAll(map); } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); } catch (XMLStreamException e) { throw new MojoExecutionException(e.getMessage(), e); } } else { parentPluginManagement.putAll(getPluginManagement(interpolatedModel)); parentPluginManagement.putAll(getBuildPlugins(interpolatedModel, true)); parentPluginManagement.putAll(getReportPlugins(interpolatedModel, true)); } } Set<Plugin> plugins = getProjectPlugins(superPomPluginManagement, parentPluginManagement, parentBuildPlugins, parentReportPlugins, pluginsWithVersionsSpecified); List<String> updates = new ArrayList<String>(); List<String> lockdowns = new ArrayList<String>(); Map<ArtifactVersion, Map<String, String>> upgrades = new TreeMap<ArtifactVersion, Map<String, String>>( new MavenVersionComparator()); ArtifactVersion curMavenVersion = runtimeInformation.getApplicationVersion(); ArtifactVersion specMavenVersion = new DefaultArtifactVersion(getRequiredMavenVersion(getProject(), "2.0")); ArtifactVersion minMavenVersion = null; boolean superPomDrivingMinVersion = false; Iterator<Plugin> i = plugins.iterator(); while (i.hasNext()) { Object plugin = i.next(); String groupId = getPluginGroupId(plugin); String artifactId = getPluginArtifactId(plugin); String version = getPluginVersion(plugin); String coords = ArtifactUtils.versionlessKey(groupId, artifactId); if (version == null) { version = parentPluginManagement.get(coords); } getLog().debug(new StringBuilder().append("Checking ").append(coords).append(" for updates newer than ") .append(version).toString()); String effectiveVersion = version; VersionRange versionRange; boolean unspecified = version == null; try { versionRange = unspecified ? VersionRange.createFromVersionSpec("[0,)") : VersionRange.createFromVersionSpec(version); } catch (InvalidVersionSpecificationException e) { throw new MojoExecutionException("Invalid version range specification: " + version, e); } Artifact artifact = artifactFactory.createPluginArtifact(groupId, artifactId, versionRange); ArtifactVersion artifactVersion = null; try { // now we want to find the newest version that is compatible with the invoking version of Maven ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions(artifact, true); ArtifactVersion[] newerVersions = artifactVersions .getVersions(Boolean.TRUE.equals(this.allowSnapshots)); ArtifactVersion minRequires = null; for (int j = newerVersions.length - 1; j >= 0; j--) { Artifact probe = artifactFactory.createDependencyArtifact(groupId, artifactId, VersionRange.createFromVersion(newerVersions[j].toString()), "pom", null, "runtime"); try { getHelper().resolveArtifact(probe, true); MavenProject mavenProject = projectBuilder.buildFromRepository(probe, remotePluginRepositories, localRepository); ArtifactVersion requires = new DefaultArtifactVersion( getRequiredMavenVersion(mavenProject, "2.0")); if (specMavenVersion.compareTo(requires) >= 0 && artifactVersion == null) { artifactVersion = newerVersions[j]; } if (effectiveVersion == null && curMavenVersion.compareTo(requires) >= 0) { // version was unspecified, current version of maven thinks it should use this effectiveVersion = newerVersions[j].toString(); } if (artifactVersion != null && effectiveVersion != null) { // no need to look at any older versions. break; } if (minRequires == null || minRequires.compareTo(requires) > 0) { Map<String, String> upgradePlugins = upgrades.get(requires); if (upgradePlugins == null) { upgrades.put(requires, upgradePlugins = new LinkedHashMap<String, String>()); } String upgradePluginKey = compactKey(groupId, artifactId); if (!upgradePlugins.containsKey(upgradePluginKey)) { upgradePlugins.put(upgradePluginKey, newerVersions[j].toString()); } minRequires = requires; } } catch (ArtifactResolutionException e) { // ignore bad version } catch (ArtifactNotFoundException e) { // ignore bad version } catch (ProjectBuildingException e) { // ignore bad version } } if (effectiveVersion != null) { VersionRange currentVersionRange = VersionRange.createFromVersion(effectiveVersion); Artifact probe = artifactFactory.createDependencyArtifact(groupId, artifactId, currentVersionRange, "pom", null, "runtime"); try { getHelper().resolveArtifact(probe, true); MavenProject mavenProject = projectBuilder.buildFromRepository(probe, remotePluginRepositories, localRepository); ArtifactVersion requires = new DefaultArtifactVersion( getRequiredMavenVersion(mavenProject, "2.0")); if (minMavenVersion == null || minMavenVersion.compareTo(requires) < 0) { minMavenVersion = requires; } } catch (ArtifactResolutionException e) { // ignore bad version } catch (ArtifactNotFoundException e) { // ignore bad version } catch (ProjectBuildingException e) { // ignore bad version } } } catch (ArtifactMetadataRetrievalException e) { throw new MojoExecutionException(e.getMessage(), e); } String newVersion; if (version == null && pluginsWithVersionsSpecified.contains(coords)) { // Hack ALERT! // // All this should be re-written in a less "pom is xml" way... but it'll // work for now :-( // // we have removed the version information, as it was the same as from // the super-pom... but it actually was specified. version = artifactVersion != null ? artifactVersion.toString() : null; } getLog().debug("[" + coords + "].version=" + version); getLog().debug("[" + coords + "].artifactVersion=" + artifactVersion); getLog().debug("[" + coords + "].effectiveVersion=" + effectiveVersion); getLog().debug("[" + coords + "].specified=" + pluginsWithVersionsSpecified.contains(coords)); if (version == null || !pluginsWithVersionsSpecified.contains(coords)) { version = (String) superPomPluginManagement.get(ArtifactUtils.versionlessKey(artifact)); getLog().debug("[" + coords + "].superPom.version=" + version); newVersion = artifactVersion != null ? artifactVersion.toString() : (version != null ? version : (effectiveVersion != null ? effectiveVersion : "(unknown)")); StringBuilder buf = new StringBuilder(compactKey(groupId, artifactId)); buf.append(' '); int padding = WARN_PAD_SIZE - newVersion.length() - (version != null ? FROM_SUPER_POM.length() : 0); while (buf.length() < padding) { buf.append('.'); } buf.append(' '); if (version != null) { buf.append(FROM_SUPER_POM); superPomDrivingMinVersion = true; } buf.append(newVersion); lockdowns.add(buf.toString()); } else if (artifactVersion != null) { newVersion = artifactVersion.toString(); } else { newVersion = null; } if (version != null && artifactVersion != null && newVersion != null && effectiveVersion != null && new DefaultArtifactVersion(effectiveVersion) .compareTo(new DefaultArtifactVersion(newVersion)) < 0) { StringBuilder buf = new StringBuilder(compactKey(groupId, artifactId)); buf.append(' '); int padding = INFO_PAD_SIZE - version.length() - newVersion.length() - 4; while (buf.length() < padding) { buf.append('.'); } buf.append(' '); buf.append(effectiveVersion); buf.append(" -> "); buf.append(newVersion); updates.add(buf.toString()); } } logLine(false, ""); if (updates.isEmpty()) { logLine(false, "All plugins with a version specified are using the latest versions."); } else { logLine(false, "The following plugin updates are available:"); for (String update : updates) { logLine(false, " " + update); } } logLine(false, ""); if (lockdowns.isEmpty()) { logLine(false, "All plugins have a version specified."); } else { getLog().warn("The following plugins do not have their version specified:"); for (String lockdown : lockdowns) { getLog().warn(" " + lockdown); } } logLine(false, ""); boolean noMavenMinVersion = getRequiredMavenVersion(getProject(), null) == null; boolean noExplicitMavenMinVersion = getProject().getPrerequisites() == null || getProject().getPrerequisites().getMaven() == null; if (noMavenMinVersion) { getLog().warn("Project does not define minimum Maven version, default is: 2.0"); } else if (noExplicitMavenMinVersion) { logLine(false, "Project inherits minimum Maven version as: " + specMavenVersion); } else { ArtifactVersion explicitMavenVersion = new DefaultArtifactVersion( getProject().getPrerequisites().getMaven()); if (explicitMavenVersion.compareTo(specMavenVersion) < 0) { logLine(true, "Project's effective minimum Maven (from parent) is: " + specMavenVersion); logLine(true, "Project defines minimum Maven version as: " + explicitMavenVersion); } else { logLine(false, "Project defines minimum Maven version as: " + specMavenVersion); } } logLine(false, "Plugins require minimum Maven version of: " + minMavenVersion); if (superPomDrivingMinVersion) { logLine(false, "Note: the super-pom from Maven " + curMavenVersion + " defines some of the plugin"); logLine(false, " versions and may be influencing the plugins required minimum Maven"); logLine(false, " version."); } logLine(false, ""); if ("maven-plugin".equals(getProject().getPackaging())) { if (noMavenMinVersion) { getLog().warn( "Project (which is a Maven Plugin) does not define required minimum version of Maven."); getLog().warn("Update the pom.xml to contain"); getLog().warn(" <prerequisites>"); getLog().warn(" <maven><!-- minimum version of Maven that the plugin works with --></maven>"); getLog().warn(" </prerequisites>"); getLog().warn("To build this plugin you need at least Maven " + minMavenVersion); getLog().warn( "A Maven Enforcer rule can be used to enforce this if you have not already set one up"); } else if (minMavenVersion != null && specMavenVersion.compareTo(minMavenVersion) < 0) { getLog().warn("Project (which is a Maven Plugin) targets Maven " + specMavenVersion + " or newer"); getLog().warn("but requires Maven " + minMavenVersion + " or newer to build."); getLog().warn("This may or may not be a problem. A Maven Enforcer rule can help "); getLog().warn("enforce that the correct version of Maven is used to build this plugin."); } else { logLine(false, "No plugins require a newer version of Maven than specified by the pom."); } } else { if (noMavenMinVersion) { logLine(true, "Project does not define required minimum version of Maven."); logLine(true, "Update the pom.xml to contain"); logLine(true, " <prerequisites>"); logLine(true, " <maven>" + minMavenVersion + "</maven>"); logLine(true, " </prerequisites>"); } else if (minMavenVersion != null && specMavenVersion.compareTo(minMavenVersion) < 0) { logLine(true, "Project requires an incorrect minimum version of Maven."); logLine(true, "Either change plugin versions to those compatible with " + specMavenVersion); logLine(true, "or update the pom.xml to contain"); logLine(true, " <prerequisites>"); logLine(true, " <maven>" + minMavenVersion + "</maven>"); logLine(true, " </prerequisites>"); } else { logLine(false, "No plugins require a newer version of Maven than specified by the pom."); } } for (Map.Entry<ArtifactVersion, Map<String, String>> mavenUpgrade : upgrades.entrySet()) { ArtifactVersion mavenUpgradeVersion = (ArtifactVersion) mavenUpgrade.getKey(); Map<String, String> upgradePlugins = mavenUpgrade.getValue(); if (upgradePlugins.isEmpty() || specMavenVersion.compareTo(mavenUpgradeVersion) >= 0) { continue; } logLine(false, ""); logLine(false, "Require Maven " + mavenUpgradeVersion + " to use the following plugin updates:"); for (Map.Entry<String, String> entry : upgradePlugins.entrySet()) { StringBuilder buf = new StringBuilder(" "); buf.append(entry.getKey()); buf.append(' '); String s = entry.getValue(); int padding = INFO_PAD_SIZE - s.length() + 2; while (buf.length() < padding) { buf.append('.'); } buf.append(' '); buf.append(s); logLine(false, buf.toString()); } } logLine(false, ""); }
From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java
License:Apache License
/** * Returns the set of all plugins used by the project. * * @param superPomPluginManagement the super pom's pluginManagement plugins. * @param parentPluginManagement the parent pom's pluginManagement plugins. * @param parentBuildPlugins the parent pom's build plugins. * @param parentReportPlugins the parent pom's report plugins. * @param pluginsWithVersionsSpecified the plugin coords that have a version defined in the project. * @return the set of plugins used by the project. * @throws org.apache.maven.plugin.MojoExecutionException * if things go wrong.//from w w w. j a va 2 s . co m */ private Set<Plugin> getProjectPlugins(Map<String, String> superPomPluginManagement, Map<String, String> parentPluginManagement, Map<String, String> parentBuildPlugins, Map<String, String> parentReportPlugins, Set<String> pluginsWithVersionsSpecified) throws MojoExecutionException { Map<String, Plugin> plugins = new HashMap<String, Plugin>(); getLog().debug("Building list of project plugins..."); if (getLog().isDebugEnabled()) { StringWriter origModel = new StringWriter(); try { origModel.write("Original model:\n"); getProject().writeOriginalModel(origModel); getLog().debug(origModel.toString()); } catch (IOException e) { // ignore } } debugVersionMap("super-pom version map", superPomPluginManagement); debugVersionMap("parent version map", parentPluginManagement); Map<String, String> excludePluginManagement = new HashMap<String, String>(superPomPluginManagement); excludePluginManagement.putAll(parentPluginManagement); debugVersionMap("aggregate version map", excludePluginManagement); excludePluginManagement.keySet().removeAll(pluginsWithVersionsSpecified); debugVersionMap("final aggregate version map", excludePluginManagement); Model originalModel; try { originalModel = modelInterpolator.interpolate(getProject().getOriginalModel(), getProject().getBasedir(), new DefaultProjectBuilderConfiguration().setExecutionProperties(getProject().getProperties()), true); } catch (ModelInterpolationException e) { throw new MojoExecutionException(e.getMessage(), e); } try { addProjectPlugins(plugins, originalModel.getBuild().getPluginManagement().getPlugins(), excludePluginManagement); } catch (NullPointerException e) { // guess there are no plugins here } debugPluginMap("after adding local pluginManagement", plugins); try { List<Plugin> lifecyclePlugins = new ArrayList<Plugin>(getLifecyclePlugins(getProject()).values()); for (Iterator<Plugin> i = lifecyclePlugins.iterator(); i.hasNext();) { Plugin lifecyclePlugin = i.next(); if (getPluginVersion(lifecyclePlugin) != null) { // version comes from lifecycle, therefore cannot modify i.remove(); } else { // lifecycle leaves version open String parentVersion = parentPluginManagement.get(getPluginCoords(lifecyclePlugin)); if (parentVersion != null) { // parent controls version i.remove(); } } } addProjectPlugins(plugins, lifecyclePlugins, parentPluginManagement); debugPluginMap("after adding lifecycle plugins", plugins); } catch (NullPointerException e) { // using maven 3.x or newer } try { List<Plugin> buildPlugins = new ArrayList<Plugin>(originalModel.getBuild().getPlugins()); for (Iterator<Plugin> i = buildPlugins.iterator(); i.hasNext();) { Plugin buildPlugin = i.next(); if (getPluginVersion(buildPlugin) == null) { String parentVersion = parentPluginManagement.get(getPluginCoords(buildPlugin)); if (parentVersion != null) { // parent controls version i.remove(); } } } addProjectPlugins(plugins, buildPlugins, parentBuildPlugins); } catch (NullPointerException e) { // guess there are no plugins here } debugPluginMap("after adding build plugins", plugins); try { List<ReportPlugin> reportPlugins = new ArrayList<ReportPlugin>( originalModel.getReporting().getPlugins()); for (Iterator<ReportPlugin> i = reportPlugins.iterator(); i.hasNext();) { ReportPlugin reportPlugin = i.next(); if (getPluginVersion(reportPlugin) == null) { String parentVersion = parentPluginManagement.get(getPluginCoords(reportPlugin)); if (parentVersion != null) { // parent controls version i.remove(); } } } addProjectPlugins(plugins, toPlugins(reportPlugins), parentReportPlugins); } catch (NullPointerException e) { // guess there are no plugins here } debugPluginMap("after adding reporting plugins", plugins); for (Profile profile : originalModel.getProfiles()) { try { addProjectPlugins(plugins, profile.getBuild().getPluginManagement().getPlugins(), excludePluginManagement); } catch (NullPointerException e) { // guess there are no plugins here } debugPluginMap("after adding build pluginManagement for profile " + profile.getId(), plugins); try { addProjectPlugins(plugins, profile.getBuild().getPlugins(), parentBuildPlugins); } catch (NullPointerException e) { // guess there are no plugins here } debugPluginMap("after adding build plugins for profile " + profile.getId(), plugins); try { addProjectPlugins(plugins, toPlugins(profile.getReporting().getPlugins()), parentReportPlugins); } catch (NullPointerException e) { // guess there are no plugins here } debugPluginMap("after adding reporting plugins for profile " + profile.getId(), plugins); } Set<Plugin> result = new TreeSet<Plugin>(new PluginComparator()); result.addAll(plugins.values()); return result; }
From source file:org.eclipse.che.maven.server.MavenServerImpl.java
License:Open Source License
private static Model internalInterpolate(Model model, File projectDir) throws RemoteException { try {//from w ww.j a v a2s . c o m AbstractStringBasedModelInterpolator interpolator = new org.apache.maven.project.interpolation.StringSearchModelInterpolator( new DefaultPathTranslator()); interpolator.initialize(); Properties props = new Properties(); //MavenServerUtil.collectSystemProperties(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration() .setExecutionProperties(props); config.setBuildStartTime(new Date()); model = interpolator.interpolate(model, projectDir, config, false); } catch (ModelInterpolationException e) { MavenServerContext.getLogger().warning(e); } catch (InitializationException e) { MavenServerContext.getLogger().error(e); } return model; }
From source file:org.jetbrains.idea.maven.server.embedder.Maven2ServerEmbedderImpl.java
License:Apache License
private static Model doInterpolate(Model result, File basedir) throws RemoteException { try {//from www . j av a 2 s . c om AbstractStringBasedModelInterpolator interpolator = new CustomModelInterpolator( new DefaultPathTranslator()); interpolator.initialize(); Properties props = MavenServerUtil.collectSystemProperties(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration() .setExecutionProperties(props); result = interpolator.interpolate(result, basedir, config, false); } catch (ModelInterpolationException e) { Maven2ServerGlobals.getLogger().warn(e); } catch (InitializationException e) { Maven2ServerGlobals.getLogger().error(e); } return result; }
From source file:org.jetbrains.idea.maven.server.Maven30ServerEmbedderImpl.java
License:Apache License
private static Model doInterpolate(Model result, File basedir) throws RemoteException { try {/*www .jav a 2 s . c o m*/ AbstractStringBasedModelInterpolator interpolator = new CustomMaven3ModelInterpolator( new DefaultPathTranslator()); interpolator.initialize(); Properties props = MavenServerUtil.collectSystemProperties(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration() .setExecutionProperties(props); config.setBuildStartTime(new Date()); result = interpolator.interpolate(result, basedir, config, false); } catch (ModelInterpolationException e) { Maven3ServerGlobals.getLogger().warn(e); } catch (InitializationException e) { Maven3ServerGlobals.getLogger().error(e); } return result; }