/** * Add maven-jar-plugin to provided module. * * @param moduleName the name of the module. */ private void addMavenJarPlugin(String moduleName) { // Add plugin maven-jar-plugin Pom module = projectOperations.getPomFromModuleName(moduleName); // Stop if the plugin is already installed for (final Plugin plugin : module.getBuildPlugins()) { if (plugin.getArtifactId().equals(MAVEN_JAR_PLUGIN)) { return; } } final Element configuration = XmlUtils.getConfiguration(getClass()); final Element plugin = XmlUtils.findFirstElement("/configuration/plugin", configuration); // Now install the plugin itself if (plugin != null) { projectOperations.addBuildPlugin(moduleName, new Plugin(plugin), false); } }
/** * Indicates whether the given {@link Plugin} has the same Maven coordinates * as this one; this is not necessarily the same as calling * {@link #equals(Object)}, which may compare more fields beyond the basic * coordinates. * * @param plugin the plugin to check (can be <code>null</code>) * @return <code>false</code> if any coordinates are different */ public boolean hasSameCoordinates(final Plugin dependency) { return dependency != null && compareCoordinates(dependency) == 0; }
@Override public boolean equals(final Object obj) { return obj instanceof Plugin && compareTo((Plugin) obj) == 0; }
/** * Constructor from a POM-style XML element that defines a Maven <plugin>. * * @param plugin the XML element to parse (required) */ public Plugin(final Element plugin) { this(getGroupId(plugin), getArtifactId(plugin), getVersion(plugin), getConfiguration(plugin), getDependencies(plugin), getExecutions(plugin)); }
/** * Compares this plugin's identifying coordinates (i.e. not the version) to * those of the given plugin * * @param other the plugin being compared to (required) * @return see {@link Comparable#compareTo(Object)} */ private int compareCoordinates(final Plugin other) { Validate.notNull(other, "Plugin being compared to cannot be null"); int result = getGroupId().compareTo(other.getGroupId()); if (result == 0) { result = getArtifactId().compareTo(other.getArtifactId()); } return result; }
private void installApplicationConfiguration(String moduleName) { // Add Spring Boot dependences final Element configuration = XmlUtils.getConfiguration(getClass()); final List<Dependency> requiredDependencies = new ArrayList<Dependency>(); final List<Element> dependencies = XmlUtils.findElements("/configuration/dependencies/dependency", configuration); for (final Element dependencyElement : dependencies) { requiredDependencies.add(new Dependency(dependencyElement)); } getProjectOperations().addDependencies(moduleName, requiredDependencies); // Add Plugins List<Element> plugins = XmlUtils.findElements("/configuration/plugins/plugin", configuration); for (Element element : plugins) { Plugin plugin = new Plugin(element); getProjectOperations().addBuildPlugin(moduleName, plugin); } }
"plugin[artifactId = '" + plugin.getArtifactId() + "' and version = '" + plugin.getVersion() + "']", pluginsElement)) { final Plugin candidatePlugin = new Plugin(candidate); if (candidatePlugin.getGroupId().equals(plugin.getGroupId())) { removedPlugins.add(candidatePlugin.getSimpleDescription());
if (StringUtils.isEmpty(newPlugin.getVersion())) { continue; final Plugin existingPlugin = new Plugin(existingPluginElement); if (existingPlugin.hasSameCoordinates(newPlugin)) { inserted = true; break; Element newPluginElement = removeVersionIfBlank(newPlugin.getElement(parentDocument)); pluginManagementElement.appendChild(newPluginElement); addedPlugins.add(newPlugin.getSimpleDescription()); final Plugin existingPlugin = new Plugin(existingPluginElement); if (existingPlugin.hasSameCoordinates(newPlugin)) { if (addToPluginManagement && !StringUtils.isEmpty(newPlugin.getVersion())) { newPluginElement = removeAllItems(newPlugin.getElement(document)); } else { newPluginElement = removeVersionIfBlank(newPlugin.getElement(document)); if (!newPlugin.getVersion().equals(existingPlugin.getVersion())) { addedPlugins.add(newPlugin.getSimpleDescription()); removedPlugins.add(existingPlugin.getSimpleDescription()); if (addToPluginManagement && !StringUtils.isEmpty(newPlugin.getVersion())) {
final Plugin existingPlugin = new Plugin(existingPluginElement); if (existingPlugin.hasSameCoordinates(plugin)) { for (final Execution execution : existingPlugin.getExecutions()) { if (executionId.equals(execution.getId()) && execution.getConfiguration() != null) {
public boolean isInstalledInModule(final String moduleName) { if (projectOperations == null) { projectOperations = getProjectOperations(); } Validate.notNull(projectOperations, "ProjectOperations is required"); final Pom pom = projectOperations.getPomFromModuleName(moduleName); if (pom == null) { return false; } for (final Plugin buildPlugin : pom.getBuildPlugins()) { if ("appengine-maven-plugin".equals(buildPlugin.getArtifactId())) { return true; } } return false; }
pluginElement.appendChild(XmlUtils.createTextElement(document, "groupId", getGroupId())); pluginElement.appendChild(XmlUtils.createTextElement(document, "artifactId", getArtifactId())); pluginElement.appendChild(XmlUtils.createTextElement(document, "version", getVersion()));
cxfPlugin = new Plugin(pluginElement); getProjectOperations().addBuildPlugin(wsdlModuleName, cxfPlugin); break;
/** * Returns any build plugins with the same groupId and artifactId as the * given plugin. This is useful for upgrade cases. * * @param plugin to locate (required; note the version number is ignored in * comparisons) * @return any matching plugins (never returns null, but may return an empty * {@link Set}) */ public Set<Plugin> getBuildPluginsExcludingVersion(final Plugin plugin) { Validate.notNull(plugin, "Plugin to locate is required"); final Set<Plugin> result = new HashSet<Plugin>(); for (final Plugin p : buildPlugins) { if (plugin.getArtifactId().equals(p.getArtifactId()) && plugin.getGroupId().equals(p.getGroupId())) { result.add(p); } } return result; }
public boolean isInstalledInModule(final String moduleName) { if (projectOperations == null) { projectOperations = getProjectOperations(); } Validate.notNull(projectOperations, "ProjectOperations is required"); final Pom pom = projectOperations.getPomFromModuleName(moduleName); if (pom == null) { return false; } for (final Plugin buildPlugin : pom.getBuildPlugins()) { if ("com.force.sdk".equals(buildPlugin.getArtifactId())) { return true; } } return false; }
/** * Add needed dependencies and plugins to run created integration tests. * * @param module {@link String} the module name where add dependencies. */ private void addIntegrationTestDependencies(String moduleName) { // Add dependencies if needed projectOperations.addDependency(moduleName, JUNIT_DEPENDENCY); projectOperations.addDependency(moduleName, ASSERTJ_CORE_DEPENDENCY); projectOperations.addDependency(moduleName, SPRING_TEST_DEPENDENCY); projectOperations.addDependency(moduleName, SPRING_BOOT_TEST_DEPENDENCY); // Add plugin maven-failsafe-plugin Pom module = projectOperations.getPomFromModuleName(moduleName); // Stop if the plugin is already installed for (final Plugin plugin : module.getBuildPlugins()) { if (plugin.getArtifactId().equals("maven-failsafe-plugin")) { return; } } final Element configuration = XmlUtils.getConfiguration(getClass()); final Element plugin = XmlUtils.findFirstElement("/configuration/plugin", configuration); // Now install the plugin itself if (plugin != null) { projectOperations.addBuildPlugin(moduleName, new Plugin(plugin)); } }
/** * Install plugins defined in external XML file * * @param configuration */ @SuppressWarnings("unused") private void updatePlugins(Element configuration) { List<Element> jasperReportsPlugins = XmlUtils.findElements( "/configuration/gvnix/jasperReports/plugins/plugin", configuration); for (Element pluginElement : jasperReportsPlugins) { projectOperations.addBuildPlugin(projectOperations .getFocusedModuleName(), new Plugin(pluginElement)); } }
/** * Indicates whether the given plugin is registered in pluginManagement without checking plugin version * , by checking the result of {@link Plugin#equals(Object)}. * * @param plugin * the plugin to check (can be <code>null</code>) * @return <code>false</code> if a <code>null</code> dependency is given */ public boolean isPluginRegisteredInPluginManagement(final Plugin plugin, boolean checkVersion) { if (checkVersion) { return plugin != null && pluginsInPluginManagement.contains(plugin); } boolean registered = false; Iterator<Plugin> it = pluginsInPluginManagement.iterator(); while (it.hasNext()) { Plugin dp = it.next(); if (plugin.getGroupId().equals(dp.getGroupId()) && plugin.getArtifactId().equals(dp.getArtifactId())) { registered = true; break; } } return plugin != null && registered; }
public boolean isInstalledInModule(final String moduleName) { if (projectOperations == null) { projectOperations = getProjectOperations(); } Validate.notNull(projectOperations, "ProjectOperations is required"); final Pom pom = projectOperations.getPomFromModuleName(moduleName); if (pom == null) { return false; } for (final Plugin buildPlugin : pom.getBuildPlugins()) { if ("com.force.sdk".equals(buildPlugin.getArtifactId())) { return true; } } return false; }
Plugin plugin = new Plugin(pluginElement); if (plugin.getArtifactId().equals("querydsl-maven-plugin")) { queryDslPlugin = plugin;
new Plugin(plugin)); getFileManager().commit();