List of usage examples for org.apache.maven.plugin.descriptor PluginDescriptor getMojos
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<MojoDescriptor> getMojos()
From source file:com.cedarsoft.fish.maven.MavenCompletionGenerator.java
private void printCompletion(Plugin plugin) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { PluginDescriptor pluginDescriptor = pluginManager.loadPluginDescriptor(plugin, project, session); List<MojoDescriptor> mojos = pluginDescriptor.getMojos(); for (MojoDescriptor mojo : mojos) { StringBuilder builder = new StringBuilder(); builder.append("complete -c mvn -a \"").append(mojo.getFullGoalName()).append("\" -d \"") .append(replaceSpecialChars(mojo.getDescription())).append("\""); System.out.println(builder.toString()); }/*from w w w . j a v a 2 s .com*/ }
From source file:com.github.spyhunter99.pdf.plugin.PdfMojo.java
License:Apache License
/** * Generate all Maven reports defined in <code>${project.reporting}</code> part * only if <code>generateReports</code> is enabled. * * @param locale not null/* ww w . j a v a 2s . c o m*/ * @throws MojoExecutionException if any * @throws IOException if any * @since 1.1 */ private void generateMavenReports(Locale locale) throws MojoExecutionException, IOException { if (!includeReports) { getLog().info("Skipped report generation."); return; } if (project.getReporting() == null) { getLog().info("No report was specified."); return; } for (final ReportPlugin reportPlugin : project.getReporting().getPlugins()) { final PluginDescriptor pluginDescriptor = getPluginDescriptor(reportPlugin); if (pluginDescriptor != null) { List<String> goals = new ArrayList<String>(8); for (final ReportSet reportSet : reportPlugin.getReportSets()) { for (String goal : reportSet.getReports()) { goals.add(goal); } } List mojoDescriptors = pluginDescriptor.getMojos(); for (Object mojoDescriptor1 : mojoDescriptors) { final MojoDescriptor mojoDescriptor = (MojoDescriptor) mojoDescriptor1; if (goals.isEmpty() || (!goals.isEmpty() && goals.contains(mojoDescriptor.getGoal()))) { MavenReport report = getMavenReport(mojoDescriptor); generateMavenReport(report, mojoDescriptor.getPluginDescriptor().getPluginArtifact(), locale); } } } } // generate project-info report if (!getGeneratedMavenReports(locale).isEmpty()) { File outDir = new File(getGeneratedSiteDirectoryTmp(), "xdoc"); if (!locale.getLanguage().equals(defaultLocale.getLanguage())) { outDir = new File(new File(getGeneratedSiteDirectoryTmp(), locale.getLanguage()), "xdoc"); } outDir.mkdirs(); File piReport = new File(outDir, "project-info.xml"); StringWriter sw = new StringWriter(); PdfSink sink = new PdfSink(sw); ProjectInfoRenderer r = new ProjectInfoRenderer(sink, getGeneratedMavenReports(locale), i18n, locale); r.render(); writeGeneratedReport(sw.toString(), piReport); } // copy generated site copySiteDir(getGeneratedSiteDirectoryTmp(), getSiteDirectoryTmp()); copySiteDir(generatedSiteDirectory, getSiteDirectoryTmp()); }
From source file:io.takari.maven.plugins.configurator.MojoConfigurationProcessor.java
License:Open Source License
String determineGoal(String className, PluginDescriptor pluginDescriptor) throws ComponentConfigurationException { List<MojoDescriptor> mojos = pluginDescriptor.getMojos(); for (MojoDescriptor mojo : mojos) { if (className.equals(mojo.getImplementation())) { return mojo.getGoal(); }/*from ww w.ja va 2 s . c o m*/ } throw new ComponentConfigurationException("Cannot find the goal implementation with " + className); }
From source file:io.takari.maven.testing.Maven30xRuntime.java
License:Open Source License
private Map<String, MojoDescriptor> readPluginXml(DefaultPlexusContainer container) throws Exception { Map<String, MojoDescriptor> mojoDescriptors = new HashMap<String, MojoDescriptor>(); Enumeration<URL> resources = getClass().getClassLoader().getResources(PATH_PLUGINXML); while (resources.hasMoreElements()) { InputStream is = resources.nextElement().openStream(); if (is == null) { return Collections.emptyMap(); }/*from w w w .j av a 2 s . c o m*/ XmlStreamReader reader = new XmlStreamReader(is); @SuppressWarnings("rawtypes") Map contextData = container.getContext().getContextData(); @SuppressWarnings("unchecked") InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( new BufferedReader(reader), contextData); PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build(interpolationFilterReader); Artifact artifact = container.lookup(RepositorySystem.class) // .createArtifact(pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(), pluginDescriptor.getVersion(), ".jar"); artifact.setFile(getPluginArtifactFile()); pluginDescriptor.setPluginArtifact(artifact); pluginDescriptor.setArtifacts(Arrays.asList(artifact)); for (ComponentDescriptor<?> desc : pluginDescriptor.getComponents()) { container.addComponentDescriptor(desc); } for (MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos()) { // TODO decide how to handle duplicate goals // this is possible when one plugin extends another // for example, Tycho 'compile' goal is an extension of standard maven 'compile' mojoDescriptors.put(mojoDescriptor.getGoal(), mojoDescriptor); } } return mojoDescriptors; }
From source file:org.eclipse.m2e.editor.xml.internal.mojo.MojoParameterMetadataProvider.java
License:Open Source License
List<MojoParameter> loadMojoParameters(PluginDescriptor desc, String goal, IProgressMonitor monitor) throws CoreException { PlexusConfigHelper helper = new PlexusConfigHelper(); if (goal.equals("*")) { //$NON-NLS-1$ List<MojoParameter> parameters = new ArrayList<>(); Set<String> collected = new HashSet<>(); for (MojoDescriptor mojo : desc.getMojos()) { for (MojoParameter p : loadMojoParameters(desc, mojo, helper, monitor)) { if (collected.add(p.getName())) { parameters.add(p);// ww w . j a va2s . c o m } } } return parameters; } return loadMojoParameters(desc, desc.getMojo(goal), helper, monitor); }
From source file:org.jszip.maven.AbstractJSZipMojo.java
License:Apache License
protected MojoDescriptor findMojoDescriptor(PluginDescriptor pluginDescriptor, Class<? extends Mojo> mojoClass) { MojoDescriptor mojoDescriptor = null; for (MojoDescriptor d : pluginDescriptor.getMojos()) { if (mojoClass.getName().equals(d.getImplementation())) { mojoDescriptor = pluginDescriptor.getMojo(d.getGoal()); break; }/*from w ww . jav a 2 s .co m*/ } if (mojoDescriptor == null) { getLog().error("Cannot find goal that corresponds to " + mojoClass); throw new IllegalStateException("This plugin should always have the " + mojoClass.getName() + " goal"); } return mojoDescriptor; }