use of org.apache.maven.plugin.descriptor.PluginDescriptor in project maven-plugins by apache.
the class TestJavadocReportTest method testTestJavadoc.
/**
* Test the test-javadoc configuration for the plugin
*
* @throws Exception if any
*/
public void testTestJavadoc() throws Exception {
File testPom = new File(getBasedir(), "src/test/resources/unit/test-javadoc-test/test-javadoc-test-plugin-config.xml");
TestJavadocReport mojo = (TestJavadocReport) lookupMojo("test-javadoc", testPom);
PluginDescriptor pluginDescriptor = new PluginDescriptor();
pluginDescriptor.setPlugin(new Plugin());
setVariableValueToObject(mojo, "plugin", pluginDescriptor);
mojo.execute();
File generatedFile = new File(getBasedir(), "target/test/unit/test-javadoc-test/target/site/apidocs/maven/AppTest.html");
assertTrue(FileUtils.fileExists(generatedFile.getAbsolutePath()));
}
use of org.apache.maven.plugin.descriptor.PluginDescriptor in project scala-maven-plugin by davidB.
the class ScalaCompilerSupport method getAnalysisCacheMap.
protected Map<File, File> getAnalysisCacheMap() {
HashMap<File, File> map = new HashMap<File, File>();
String scalaPluginKey = ((PluginDescriptor) getPluginContext().get("pluginDescriptor")).getPluginLookupKey();
for (MavenProject project1 : reactorProjects) {
Plugin plugin = project1.getPlugin(scalaPluginKey);
if (plugin != null) {
Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
Xpp3Dom analysisCache = (configuration != null) ? configuration.getChild("analysisCacheFile") : null;
File analysisCacheFile = (analysisCache != null) ? new File(analysisCache.getValue()) : defaultAnalysisCacheFile(project1);
File classesDirectory = new File(project1.getBuild().getOutputDirectory());
map.put(classesDirectory.getAbsoluteFile(), analysisCacheFile.getAbsoluteFile());
Xpp3Dom testAnalysisCache = (configuration != null) ? configuration.getChild("testAnalysisCacheFile") : null;
File testAnalysisCacheFile = (testAnalysisCache != null) ? new File(testAnalysisCache.getValue()) : defaultTestAnalysisCacheFile(project1);
File testClassesDirectory = new File(project1.getBuild().getTestOutputDirectory());
map.put(testClassesDirectory.getAbsoluteFile(), testAnalysisCacheFile.getAbsoluteFile());
}
}
return map;
}
use of org.apache.maven.plugin.descriptor.PluginDescriptor in project maven-plugins by apache.
the class CheckstyleViolationCheckMojoTest method doTestPlainOutputFile.
private void doTestPlainOutputFile(boolean failsOnError) throws Exception {
File pluginXmlFile = new File(getBasedir(), "src/test/plugin-configs/check-plugin-plain-output.xml");
Mojo mojo = lookupMojo("check", pluginXmlFile);
assertNotNull("Mojo found.", mojo);
PluginDescriptor descriptorStub = new PluginDescriptor();
descriptorStub.setGroupId("org.apache.maven.plugins");
descriptorStub.setArtifactId("maven-checkstyle-plugin");
setVariableValueToObject(mojo, "plugin", descriptorStub);
setVariableValueToObject(mojo, "failsOnError", failsOnError);
mojo.execute();
}
use of org.apache.maven.plugin.descriptor.PluginDescriptor in project maven-plugins by apache.
the class CompilerMojoTestCase method getMockMojoExecution.
private MojoExecution getMockMojoExecution() {
MojoDescriptor md = new MojoDescriptor();
md.setGoal("compile");
MojoExecution me = new MojoExecution(md);
PluginDescriptor pd = new PluginDescriptor();
pd.setArtifactId("maven-compiler-plugin");
md.setPluginDescriptor(pd);
return me;
}
use of org.apache.maven.plugin.descriptor.PluginDescriptor in project maven-plugins by apache.
the class DescribeMojo method isReportGoal.
/**
* Determines if this Mojo should be used as a report or not. This resolves the plugin project along with all of its
* transitive dependencies to determine if the Java class of this goal implements <code>MavenReport</code>.
*
* @param md Mojo descriptor
* @return Whether or not this goal should be used as a report.
*/
private boolean isReportGoal(MojoDescriptor md) {
PluginDescriptor pd = md.getPluginDescriptor();
List<URL> urls = new ArrayList<URL>();
ProjectBuildingRequest pbr = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
pbr.setRemoteRepositories(remoteRepositories);
pbr.setResolveDependencies(true);
pbr.setProject(null);
pbr.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
try {
Artifact jar = artifactResolver.resolveArtifact(pbr, toArtifactCoordinate(pd, "jar")).getArtifact();
Artifact pom = artifactResolver.resolveArtifact(pbr, toArtifactCoordinate(pd, "pom")).getArtifact();
MavenProject project = projectBuilder.build(pom.getFile(), pbr).getProject();
urls.add(jar.getFile().toURI().toURL());
for (Object artifact : project.getCompileClasspathElements()) {
urls.add(new File((String) artifact).toURI().toURL());
}
ClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
return MavenReport.class.isAssignableFrom(Class.forName(md.getImplementation(), false, classLoader));
} catch (Exception e) {
getLog().warn("Couldn't identify if this goal is a report goal: " + e.getMessage());
return false;
}
}
Aggregations