List of usage examples for org.apache.maven.plugin.descriptor MojoDescriptor setPluginDescriptor
public void setPluginDescriptor(PluginDescriptor pluginDescriptor)
From source file:fr.jcgay.maven.plugin.buildplan.model.builder.MojoExecutionBuilder.java
License:Apache License
public MojoExecution build() { if (useMojoDescriptorConstructor) { MojoDescriptor descriptor = new MojoDescriptor(); descriptor.setGoal(goal);//from w ww .ja v a 2 s .c om descriptor.setPhase(phase); PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setArtifactId(artifactId); descriptor.setPluginDescriptor(pluginDescriptor); return new MojoExecution(descriptor, executionId); } else { Plugin plugin = new Plugin(); plugin.setArtifactId(artifactId); return new MojoExecution(plugin, goal, executionId); } }
From source file:org.efaps.maven_java5.EfapsAnnotationDescriptorExtractor.java
License:Open Source License
/** * * @param _project/*from www . ja va 2 s . c om*/ * @param _pluginDescriptor */ public List<MojoDescriptor> execute(final MavenProject _project, final PluginDescriptor _pluginDescriptor) throws InvalidPluginDescriptorException { final List<MojoDescriptor> descriptors = new ArrayList<MojoDescriptor>(); // check all compiled classes for mojos final File classesDirectory = new File(_project.getBuild().getOutputDirectory()); final DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(classesDirectory); scanner.setIncludes(new String[] { "**/*.class" }); scanner.scan(); if (getLogger().isDebugEnabled()) { getLogger().debug("Scanning " + scanner.getIncludedFiles().length + " classes"); } final String[] included = scanner.getIncludedFiles(); if (included.length > 0) { final ClassLoader cl = getClassLoader(_project); for (final String file : scanner.getIncludedFiles()) { final MojoDescriptor desc = scan(cl, file.substring(0, file.lastIndexOf(".class")).replace('/', '.')); if (desc != null) { desc.setPluginDescriptor(_pluginDescriptor); descriptors.add(desc); if (getLogger().isInfoEnabled()) { getLogger().info("Found mojo " + desc.getImplementation()); } } } } final Resource resource = new Resource(); resource.setDirectory(classesDirectory.getAbsolutePath()); resource.setIncludes(Collections.EMPTY_LIST); resource.setExcludes(Collections.EMPTY_LIST); _project.addResource(resource); return descriptors; }