You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/05/14 23:33:30 UTC
svn commit: r1338439 - in /maven/plugin-tools/trunk/maven-plugin-plugin/src:
it/plugin-report-annotations/ it/plugin-report-annotations/src/
it/plugin-report-annotations/src/main/
it/plugin-report-annotations/src/main/java/ it/plugin-report-annotations...
Author: olamy
Date: Mon May 14 21:33:29 2012
New Revision: 1338439
URL: http://svn.apache.org/viewvc?rev=1338439&view=rev
Log:
add it test for plugin report with annotations
Added:
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties (with props)
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml (with props)
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java (with props)
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/MyMojo.java (with props)
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/verify.bsh (with props)
Modified:
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties?rev=1338439&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties Mon May 14 21:33:29 2012
@@ -0,0 +1 @@
+invoker.goals = clean site -DskipTests
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml?rev=1338439&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml Mon May 14 21:33:29 2012
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its</groupId>
+ <artifactId>plugin-report</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>MPLUGIN-105</name>
+ <description>
+ Test basic site generation to guard against regression.
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>@project.version@</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-impl</artifactId>
+ <version>2.0.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-api</artifactId>
+ <version>3.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>@sitePluginVersion@</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.4</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>index</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java?rev=1338439&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java Mon May 14 21:33:29 2012
@@ -0,0 +1,227 @@
+package org;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.AbstractMavenReportRenderer;
+import org.apache.maven.reporting.MavenReportException;
+
+import java.io.File;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Dummy Reporting Plugin.
+ */
+@Mojo( name = "report", requiresReports = true )
+@Execute( phase = LifecyclePhase.COMPILE )
+public class DummyReport
+ extends AbstractMavenReport
+{
+ /**
+ * Report output directory.
+ */
+ @Parameter( defaultValue = "${project.build.directory}/generated-site/xdoc" )
+ private File outputDirectory;
+
+ /**
+ * Doxia Site Renderer.
+ */
+ @Component
+ private Renderer siteRenderer;
+
+ /**
+ * The Maven Project.
+ */
+ @Parameter( expression = "${project}", readonly = true, required = true )
+ private MavenProject project;
+
+
+ /**
+ * The goal prefix that will appear before the ":".
+ *
+ * @since 2.4
+ */
+ @Parameter( expression = "${goalPrefix}" )
+ protected String goalPrefix;
+
+ /**
+ * Set this to "true" to skip invoking any goals or reports of the plugin.
+ *
+ * @since 2.8
+ */
+ @Parameter( defaultValue = "false", expression = "${maven.plugin.skip}" )
+ private boolean skip;
+
+ /**
+ * Set this to "true" to skip generating the report.
+ *
+ * @since 2.8
+ */
+ @Parameter( defaultValue = "false", expression = "${maven.plugin.report.skip}" )
+ private boolean skipReport;
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Renderer getSiteRenderer()
+ {
+ return siteRenderer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected String getOutputDirectory()
+ {
+ return outputDirectory.getPath();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected MavenProject getProject()
+ {
+ return project;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canGenerateReport()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void executeReport( Locale locale )
+ throws MavenReportException
+ {
+ if ( !canGenerateReport() )
+ {
+ return;
+ }
+ if ( skip || skipReport )
+ {
+ getLog().info( "Maven Plugin Plugin Report generation skipped." );
+ return;
+ }
+
+ // Generate the plugin's documentation
+ generatePluginDocumentation( locale );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDescription( Locale locale )
+ {
+ return getBundle( locale ).getString( "report.plugin.description" );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName( Locale locale )
+ {
+ return getBundle( locale ).getString( "report.plugin.name" );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getOutputName()
+ {
+ return "plugin-info";
+ }
+
+ /**
+ * @param pluginDescriptor not null
+ * @param locale not null
+ * @throws MavenReportException if any
+ */
+ private void generatePluginDocumentation( Locale locale )
+ throws MavenReportException
+ {
+ File outputDir = new File( getOutputDirectory() );
+ outputDir.mkdirs();
+ PluginOverviewRenderer r = new PluginOverviewRenderer( getSink(), locale );
+ r.render();
+ }
+
+ /**
+ * @param locale not null
+ * @return the bundle for this report
+ */
+ protected static ResourceBundle getBundle( Locale locale )
+ {
+ return ResourceBundle.getBundle( "plugin-report", locale, DummyReport.class.getClassLoader() );
+ }
+
+ /**
+ * Generates an overview page with the list of goals
+ * and a link to the goal's page.
+ */
+ static class PluginOverviewRenderer
+ extends AbstractMavenReportRenderer
+ {
+ private final Locale locale;
+
+ /**
+ * @param project not null
+ * @param sink not null
+ * @param locale not null
+ */
+ public PluginOverviewRenderer( Sink sink, Locale locale )
+ {
+ super( sink );
+
+ this.locale = locale;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getTitle()
+ {
+ return getBundle( locale ).getString( "report.plugin.title" );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void renderBody()
+ {
+ startSection( getTitle() );
+ paragraph( "This is a report." );
+ endSection();
+ }
+ }
+}
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/MyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/MyMojo.java?rev=1338439&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/MyMojo.java (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/MyMojo.java Mon May 14 21:33:29 2012
@@ -0,0 +1,65 @@
+package org;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.DependencyScope;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * Does nothing.
+ *
+ * @since 1.0
+ * @deprecated You don't use test goals, do you?
+ */
+@Mojo( name = "noop", defaultPhase = LifecyclePhase.PROCESS_SOURCES,
+ requiresDependencyResolution = DependencyScope.TEST,
+ requiresDirectInvocation = true, requiresOnline = true, inheritByDefault = false, aggregator = true )
+@Execute( phase = LifecyclePhase.COMPILE )
+public class MyMojo
+ extends AbstractMojo
+{
+
+ /**
+ * This is a test.
+ */
+ @SuppressWarnings( "unused" )
+ @Parameter( required = true )
+ private String required;
+
+ /**
+ * This is a test.
+ *
+ * @since 1.1
+ * @deprecated Just testing.
+ */
+ @SuppressWarnings( "unused" )
+ @Parameter( expression = "${string}", defaultValue = "${project.version}/</markup-must-be-escaped>" )
+ private String string;
+
+ public void execute()
+ {
+ // intentional do nothing
+ }
+
+}
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/MyMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/MyMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/verify.bsh?rev=1338439&view=auto
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/verify.bsh (added)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/verify.bsh Mon May 14 21:33:29 2012
@@ -0,0 +1,36 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+ File siteDir = new File( basedir, "target/site" );
+ System.out.println( "Checking for existence of site directory: " + siteDir );
+ if ( !siteDir.isDirectory() )
+ {
+ System.out.println( "FAILED!" );
+ return false;
+ }
+
+ String[] expectedFiles = {
+ "noop-mojo.html",
+ "report-mojo.html",
+ };
+ for ( String path : expectedFiles )
+ {
+ File file = new File( siteDir, path );
+ System.out.println( "Checking for existence of doc file: " + file );
+ if ( !file.isFile() || file.length() <= 0 )
+ {
+ System.out.println( "FAILED!" );
+ return false;
+ }
+ }
+}
+catch( Throwable t )
+{
+ t.printStackTrace();
+ return false;
+}
+
+return true;
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/verify.bsh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/plugin-report-annotations/verify.bsh
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java?rev=1338439&r1=1338438&r2=1338439&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java Mon May 14 21:33:29 2012
@@ -19,6 +19,8 @@ package org.apache.maven.plugin.plugin;
* under the License.
*/
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.model.Plugin;
@@ -48,6 +50,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
+import java.util.Set;
/**
* Generates the Plugin's documentation report.
@@ -56,7 +59,7 @@ import java.util.ResourceBundle;
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$
* @goal report
- * @execute phase="compile"
+ * @execute phase="process-classes"
* @since 2.0
*/
public class PluginReport
@@ -159,6 +162,36 @@ public class PluginReport
private boolean skipReport;
/**
+ * The set of dependencies for the current project
+ *
+ * @parameter default-value = "${project.artifacts}"
+ * @required
+ * @readonly
+ * @since 3.0
+ */
+ protected Set<Artifact> dependencies;
+
+ /**
+ * List of Remote Repositories used by the resolver
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ * @readonly
+ * @required
+ * @since 3.0
+ */
+ protected List<ArtifactRepository> remoteRepos;
+
+ /**
+ * Location of the local repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @readonly
+ * @required
+ * @since 3.0
+ */
+ protected ArtifactRepository local;
+
+ /**
* {@inheritDoc}
*/
protected Renderer getSiteRenderer()
@@ -236,6 +269,11 @@ public class PluginReport
PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
request.setEncoding( encoding );
+ request.setSkipErrorNoDescriptorsFound( true );
+ request.setDependencies( dependencies );
+ request.setLocal( this.local );
+ request.setRemoteRepos( this.remoteRepos );
+
try
{