List of usage examples for org.apache.maven.project MavenProject getPluginManagement
public PluginManagement getPluginManagement()
From source file:com.bugvm.maven.plugin.AbstractBugVMMojo.java
License:Apache License
protected Config.Builder configure(Config.Builder builder) throws MojoExecutionException { builder.logger(getBugVMLogger());/*w w w . ja v a 2 s .c o m*/ // load config base file if it exists (and properties) if (os != null) { builder.os(OS.valueOf(os)); } if (propertiesFile != null) { if (!propertiesFile.exists()) { throw new MojoExecutionException( "Invalid 'propertiesFile' specified for BugVM compile: " + propertiesFile); } try { getLog().debug( "Including properties file in BugVM compiler config: " + propertiesFile.getAbsolutePath()); builder.addProperties(propertiesFile); } catch (IOException e) { throw new MojoExecutionException( "Failed to add properties file to BugVM config: " + propertiesFile); } } else { try { builder.readProjectProperties(project.getBasedir(), false); } catch (IOException e) { throw new MojoExecutionException("Failed to read BugVM project properties file(s) in " + project.getBasedir().getAbsolutePath(), e); } } if (configFile != null) { if (!configFile.exists()) { throw new MojoExecutionException("Invalid 'configFile' specified for BugVM compile: " + configFile); } try { getLog().debug("Loading config file for BugVM compiler: " + configFile.getAbsolutePath()); builder.read(configFile); } catch (Exception e) { throw new MojoExecutionException("Failed to read BugVM config file: " + configFile); } } else { try { builder.readProjectConfig(project.getBasedir(), false); } catch (Exception e) { throw new MojoExecutionException( "Failed to read project BugVM config file in " + project.getBasedir().getAbsolutePath(), e); } } // Read embedded BugVM <config> if there is one Plugin plugin = project.getPlugin("com.bugvm:bugvm-maven-plugin"); MavenProject p = project; while (p != null && plugin == null) { plugin = p.getPluginManagement().getPluginsAsMap().get("com.bugvm:bugvm-maven-plugin"); if (plugin == null) p = p.getParent(); } if (plugin != null) { getLog().debug("Reading BugVM plugin configuration from " + p.getFile().getAbsolutePath()); Xpp3Dom configDom = (Xpp3Dom) plugin.getConfiguration(); if (configDom != null && configDom.getChild("config") != null) { StringWriter sw = new StringWriter(); XMLWriter xmlWriter = new PrettyPrintXMLWriter(sw, "UTF-8", null); Xpp3DomWriter.write(xmlWriter, configDom.getChild("config")); try { builder.read(new StringReader(sw.toString()), project.getBasedir()); } catch (Exception e) { throw new MojoExecutionException("Failed to read BugVM config embedded in POM", e); } } } File tmpDir = new File(project.getBuild().getDirectory(), "bugvm.tmp"); try { FileUtils.deleteDirectory(tmpDir); } catch (IOException e) { throw new MojoExecutionException("Failed to clean output dir " + tmpDir, e); } tmpDir.mkdirs(); Home home = null; try { home = Home.find(); } catch (Throwable t) { } if (home == null || !home.isDev()) { home = new Config.Home(unpackBugVMDist()); } builder.home(home).tmpDir(tmpDir).skipInstall(true).installDir(installDir); if (home.isDev()) { builder.useDebugLibs(Boolean.getBoolean("bugvm.useDebugLibs")); builder.dumpIntermediates(true); } if (debug != null && !debug.equals("false")) { builder.debug(true); if (debugPort != -1) { builder.addPluginArgument("debug:jdwpport=" + debugPort); } if ("clientmode".equals(debug)) { builder.addPluginArgument("debug:clientmode=true"); } } if (skipSigning) { builder.iosSkipSigning(true); } else { if (signIdentity != null) { getLog().debug("Using explicit signing identity: " + signIdentity); builder.iosSignIdentity(SigningIdentity.find(SigningIdentity.list(), signIdentity)); } if (provisioningProfile != null) { getLog().debug("Using explicit provisioning profile: " + provisioningProfile); builder.iosProvisioningProfile( ProvisioningProfile.find(ProvisioningProfile.list(), provisioningProfile)); } // if (keychainPassword != null) { // builder.keychainPassword(keychainPassword); // } else if (keychainPasswordFile != null) { // builder.keychainPasswordFile(keychainPasswordFile); // } } if (cacheDir != null) { builder.cacheDir(cacheDir); } builder.clearClasspathEntries(); // configure the runtime classpath try { for (Object object : project.getRuntimeClasspathElements()) { String path = (String) object; if (getLog().isDebugEnabled()) { getLog().debug("Including classpath element for BugVM app: " + path); } builder.addClasspathEntry(new File(path)); } } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Error resolving application classpath for BugVM build", e); } return builder; }
From source file:com.github.ferstl.maven.pomenforcers.PedanticPluginManagementOrderEnforcer.java
License:Apache License
@Override protected void doEnforce(ErrorReport report) { MavenProject project = EnforcerRuleUtils.getMavenProject(getHelper()); Collection<PluginModel> declaredManagedPlugins = getProjectModel().getManagedPlugins(); Collection<Plugin> managedPlugins = project.getPluginManagement().getPlugins(); BiMap<PluginModel, PluginModel> matchedPlugins = matchPlugins(declaredManagedPlugins, managedPlugins); Set<PluginModel> resolvedPlugins = matchedPlugins.keySet(); if (!this.pluginOrdering.isOrdered(resolvedPlugins)) { Collection<PluginModel> sortedPlugins = this.pluginOrdering.immutableSortedCopy(resolvedPlugins); report.addLine("Your plugin management has to be ordered this way:").emptyLine() .addDiffUsingToString(resolvedPlugins, sortedPlugins, "Actual Order", "Required Order"); }/*from w w w .j av a2 s .c o m*/ }
From source file:com.redhat.rcm.version.mgr.session.ManagedInfo.java
License:Open Source License
void setToolchain(final File toolchainFile, final MavenProject project) { toolchainKey = new FullProjectKey(project); this.toolchainProject = project; final PluginManagement pm = project.getPluginManagement(); if (pm != null) { for (final Plugin plugin : pm.getPlugins()) { managedPlugins.put(new VersionlessProjectKey(plugin), plugin); }/* w w w.j a v a 2s . c o m*/ } final Model model = project.getOriginalModel(); final Build build = model.getBuild(); if (build != null) { final List<Plugin> plugins = build.getPlugins(); if (plugins != null) { for (final Plugin plugin : plugins) { final VersionlessProjectKey key = new VersionlessProjectKey(plugin); injectedPlugins.put(key, plugin); if (!managedPlugins.containsKey(key) && plugin.getVersion() != null) { injectedPlugins.put(key, plugin); } } } } }
From source file:com.tvarit.plugin.LambdaS3BucketKeyMaker.java
License:Open Source License
public String makeKey(MavenProject project) { Plugin tvaritMavenPlugin = project.getPluginManagement().getPluginsAsMap() .get("io.tvarit:tvarit-maven-plugin"); if (tvaritMavenPlugin == null) tvaritMavenPlugin = (Plugin) project.getPluginArtifactMap().get("io.tvarit:tvarit-maven-plugin"); final String groupId = tvaritMavenPlugin.getGroupId(); final String artifactId = tvaritMavenPlugin.getArtifactId(); final String version = tvaritMavenPlugin.getVersion(); return "default/" + groupId + "/" + artifactId + "/" + version + "/lambda/" + "deployNewWar.zip"; }
From source file:com.tvarit.plugin.TemplateUrlMaker.java
License:Open Source License
public URL makeUrl(MavenProject project, String fileName) throws MalformedURLException { Plugin tvaritMavenPlugin = project.getPluginManagement().getPluginsAsMap() .get("io.tvarit:tvarit-maven-plugin"); if (tvaritMavenPlugin == null) tvaritMavenPlugin = (Plugin) project.getPluginArtifactMap().get("io.tvarit:tvarit-maven-plugin"); final String groupId = tvaritMavenPlugin.getGroupId(); final String artifactId = tvaritMavenPlugin.getArtifactId(); final String version = tvaritMavenPlugin.getVersion(); final String infraTemplateS3Url = "https://s3.amazonaws.com/tvarit/default/" + groupId + "/" + artifactId + "/" + version + "/cfn-templates/" + fileName; return new URL(infraTemplateS3Url); }
From source file:io.fastup.maven.plugin.TemplateUrlMaker.java
License:Open Source License
@Deprecated public URL makeUrl(MavenProject project, String fileName) throws MalformedURLException { Plugin tvaritMavenPlugin = project.getPluginManagement().getPluginsAsMap() .get("io.tvarit:tvarit-maven-plugin"); if (tvaritMavenPlugin == null) tvaritMavenPlugin = (Plugin) project.getPluginArtifactMap().get("io.tvarit:tvarit-maven-plugin"); final String groupId = tvaritMavenPlugin.getGroupId(); final String artifactId = tvaritMavenPlugin.getArtifactId(); final String version = tvaritMavenPlugin.getVersion(); final String infraTemplateS3Url = "https://s3.amazonaws.com/tvarit/default/" + groupId + "/" + artifactId + "/" + version + "/" + fileName; return new URL(infraTemplateS3Url); }
From source file:io.reactiverse.vertx.maven.plugin.utils.MojoUtils.java
License:Apache License
/** * Checks whether or not the given project has a plugin with the given key. The key is given using the * "groupId:artifactId" syntax.// ww w. ja va2 s . co m * * @param project the project * @param pluginKey the plugin * @return an Optional completed if the plugin is found. */ public static Optional<Plugin> hasPlugin(MavenProject project, String pluginKey) { Optional<Plugin> optPlugin = project.getBuildPlugins().stream() .filter(plugin -> pluginKey.equals(plugin.getKey())).findFirst(); if (!optPlugin.isPresent() && project.getPluginManagement() != null) { optPlugin = project.getPluginManagement().getPlugins().stream() .filter(plugin -> pluginKey.equals(plugin.getKey())).findFirst(); } return optPlugin; }
From source file:io.sundr.maven.GenerateBomMojo.java
License:Apache License
/** * Returns the model of the {@link org.apache.maven.project.MavenProject} to generate. * This is a trimmed down version and contains just the stuff that need to go into the bom. * * @param project The source {@link org.apache.maven.project.MavenProject}. * @param config The {@link io.sundr.maven.BomConfig}. * @return The build {@link org.apache.maven.project.MavenProject}. *///w w w . ja va 2 s . com private static MavenProject toGenerate(MavenProject project, BomConfig config, Collection<Dependency> dependencies, Set<Artifact> plugins) { MavenProject toGenerate = project.clone(); toGenerate.setGroupId(project.getGroupId()); toGenerate.setArtifactId(config.getArtifactId()); toGenerate.setVersion(project.getVersion()); toGenerate.setPackaging("pom"); toGenerate.setName(config.getName()); toGenerate.setDescription(config.getDescription()); toGenerate.setUrl(project.getUrl()); toGenerate.setLicenses(project.getLicenses()); toGenerate.setScm(project.getScm()); toGenerate.setDevelopers(project.getDevelopers()); toGenerate.getModel().setDependencyManagement(new DependencyManagement()); for (Dependency dependency : dependencies) { toGenerate.getDependencyManagement().addDependency(dependency); } toGenerate.getModel().setBuild(new Build()); if (!plugins.isEmpty()) { toGenerate.getModel().setBuild(new Build()); toGenerate.getModel().getBuild().setPluginManagement(new PluginManagement()); for (Artifact artifact : plugins) { toGenerate.getPluginManagement().addPlugin(toPlugin(artifact)); } } return toGenerate; }
From source file:net.oneandone.maven.rules.ForbidOverridingManagedPluginsRule.java
License:Apache License
private void checkPluginManagementDiffs(MavenProject project, Log log) { if (project.getParent() != null) { List<Plugin> projectPlugins = project.getBuildPlugins(); if (project.getPluginManagement() != null) { projectPlugins.addAll(project.getPluginManagement().getPlugins()); }//from w w w .jav a 2s . c o m Map<String, Plugin> parentProjectPlugins = project.getParent().getPluginManagement().getPluginsAsMap(); for (Plugin plugin : projectPlugins) { final Plugin parentPlugin = parentProjectPlugins.get(plugin.getKey()); if (parentPlugin != null && !plugin.getVersion().equals(parentPlugin.getVersion()) && !isExcluded(plugin.getKey())) { logHeader(log, "plugin management"); log.warn("Difference for: " + plugin.getKey()); log.warn("Project: " + plugin.getVersion()); log.warn("Parent: " + parentPlugin.getVersion()); log.warn("----------------------------------------"); failureDetected = true; } } } }
From source file:org.codehaus.cargo.documentation.ConfluenceContainerDocumentationGenerator.java
License:Apache License
/** * Returns the download URL used for testing the given container. * @param containerId Container ID./*ww w .j a v a 2 s. c o m*/ * @return Download URL for testing <code>containerId</code>, <code>null</code> if no download * URL is set. */ public String getContainerServerDownloadUrl(String containerId) { File pom = new File(SAMPLES_DIRECTORY, POM).getAbsoluteFile(); Model model = new Model(); try { model = POM_READER.read(new FileReader(pom)); } catch (Exception e) { throw new IllegalStateException("Caught Exception reading pom.xml", e); } MavenProject project = new MavenProject(model); project.setFile(pom); Map<String, Plugin> plugins = project.getPluginManagement().getPluginsAsMap(); Plugin surefire = plugins.get(SUREFIRE_PLUGIN); if (surefire == null) { throw new IllegalStateException("Cannot find plugin " + SUREFIRE_PLUGIN + " in pom file " + pom + ". Found plugins: " + plugins.keySet()); } Xpp3Dom configuration = (Xpp3Dom) surefire.getConfiguration(); if (configuration == null) { throw new IllegalStateException( "Plugin " + SUREFIRE_PLUGIN + " in pom file " + pom + " does not have any configuration."); } Xpp3Dom systemProperties = configuration.getChild(SYSTEM_PROPERTIES); if (systemProperties == null) { throw new IllegalStateException("Plugin " + SUREFIRE_PLUGIN + " in pom file " + pom + " does not have any " + SYSTEM_PROPERTIES + " in its configuration."); } String urlName = "cargo." + containerId + ".url"; for (Xpp3Dom property : systemProperties.getChildren()) { Xpp3Dom nameChild = property.getChild("name"); Xpp3Dom valueChild = property.getChild("value"); if (nameChild == null || valueChild == null) { throw new IllegalStateException("One of the " + SUREFIRE_PLUGIN + "'s configuration options in pom file " + pom + " is incomplete:\n" + property); } if (urlName.equals(nameChild.getValue())) { return valueChild.getValue(); } } return null; }