You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by GitBox <gi...@apache.org> on 2017/10/26 07:41:46 UTC

[GitHub] asfgit closed pull request #7: MPLUGIN-294 - 'report' mojo should use 'extractors' configuration parameter

asfgit closed pull request #7: MPLUGIN-294 - 'report' mojo should use 'extractors' configuration parameter
URL: https://github.com/apache/maven-plugin-tools/pull/7
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/maven-plugin-plugin/src/it/mplugin-294-report-extractors/invoker.properties b/maven-plugin-plugin/src/it/mplugin-294-report-extractors/invoker.properties
new file mode 100644
index 00000000..c30c4c83
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-294-report-extractors/invoker.properties
@@ -0,0 +1,20 @@
+# 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.
+
+invoker.goals = clean site -DskipTests
+
+#invoker.debug = false
diff --git a/maven-plugin-plugin/src/it/mplugin-294-report-extractors/pom.xml b/maven-plugin-plugin/src/it/mplugin-294-report-extractors/pom.xml
new file mode 100644
index 00000000..f060ce32
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-294-report-extractors/pom.xml
@@ -0,0 +1,100 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its</groupId>
+  <artifactId>plugin-report-extractors</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>MPLUGIN-294</name> 
+  <description>
+    Report with 'java-annotations' extractor only.
+  </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>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <extractors>
+            <extractor>java-annotations</extractor>
+          </extractors>
+        </configuration>
+      </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.8.1</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>
+        <configuration>
+          <extractors>
+            <extractor>java-annotations</extractor>
+          </extractors>
+        </configuration>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
diff --git a/maven-plugin-plugin/src/it/mplugin-294-report-extractors/src/main/java/org/MyMojo.java b/maven-plugin-plugin/src/it/mplugin-294-report-extractors/src/main/java/org/MyMojo.java
new file mode 100644
index 00000000..82a95ab3
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-294-report-extractors/src/main/java/org/MyMojo.java
@@ -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.ResolutionScope;
+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 = ResolutionScope.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( property = "string", defaultValue = "${project.version}/</markup-must-be-escaped>" )
+    private String string;
+
+    public void execute()
+    {
+        // intentional do nothing
+    }
+
+}
diff --git a/maven-plugin-plugin/src/it/mplugin-294-report-extractors/verify.groovy b/maven-plugin-plugin/src/it/mplugin-294-report-extractors/verify.groovy
new file mode 100644
index 00000000..e232ae46
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-294-report-extractors/verify.groovy
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+def found = false
+new File(basedir, "build.log").eachLine {
+    line ->
+    if (line.contains("java-javadoc mojo extractor")) {
+        found = true
+    }
+}
+assert !found: "The build shouldn't use 'java-javadoc' extractor."
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
index fa5c4242..3205fc78 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
@@ -144,6 +144,32 @@
     protected String goalPrefix;
 
     /**
+     * The role names of mojo extractors to use.
+     * <p/>
+     * If not set, all mojo extractors will be used. If set to an empty extractor name, no mojo extractors
+     * will be used.
+     * <p/>
+     * Example:
+     * <p/>
+     * <pre>
+     *  &lt;!-- Use all mojo extractors --&gt;
+     *  &lt;extractors/&gt;
+     *
+     *  &lt;!-- Use no mojo extractors --&gt;
+     *  &lt;extractors&gt;
+     *      &lt;extractor/&gt;
+     *  &lt;/extractors&gt;
+     *
+     *  &lt;!-- Use only bsh mojo extractor --&gt;
+     *  &lt;extractors&gt;
+     *      &lt;extractor&gt;bsh&lt;/extractor&gt;
+     *  &lt;/extractors&gt;
+     * </pre>
+     */
+    @Parameter
+    protected Set<String> extractors;
+
+    /**
      * Set this to "true" to skip invoking any goals or reports of the plugin.
      *
      * @since 2.8
@@ -258,6 +284,8 @@ private PluginDescriptor extractPluginDescriptor()
                                + defaultGoalPrefix + "'.\n" );
         }
 
+        mojoScanner.setActiveExtractors( extractors );
+
         // TODO: could use this more, eg in the writing of the plugin descriptor!
         PluginDescriptor pluginDescriptor = new PluginDescriptor();
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org