You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/03/02 14:04:33 UTC

[maven-jxr] 01/01: Add non-forking jxr/test-jxr goals

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch JXR-143
in repository https://gitbox.apache.org/repos/asf/maven-jxr.git

commit 6f50a1c74d0d3aabe1f0223c5b3791f713ab7276
Author: Matt Nelson <ma...@cerner.com>
AuthorDate: Fri Jan 18 14:58:03 2019 -0600

    Add non-forking jxr/test-jxr goals
---
 .../src/it/JXR-143_nofork/invoker.properties       | 18 +++++
 maven-jxr-plugin/src/it/JXR-143_nofork/pom.xml     | 92 ++++++++++++++++++++++
 .../src/main/java/org/apache/maven/jxr/it/App.java | 33 ++++++++
 .../main/java/org/apache/maven/jxr/it/App2.java    | 32 ++++++++
 .../test/java/org/apache/maven/jxr/it/AppTest.java | 57 ++++++++++++++
 .../src/it/JXR-143_nofork/verify.groovy            | 40 ++++++++++
 .../apache/maven/plugin/jxr/JxrNoForkReport.java   | 39 +++++++++
 .../maven/plugin/jxr/JxrTestNoForkReport.java      | 39 +++++++++
 .../src/site/apt/examples/nofork.apt.vm            | 72 +++++++++++++++++
 maven-jxr-plugin/src/site/apt/index.apt            | 11 ++-
 maven-jxr-plugin/src/site/site.xml                 |  1 +
 11 files changed, 431 insertions(+), 3 deletions(-)

diff --git a/maven-jxr-plugin/src/it/JXR-143_nofork/invoker.properties b/maven-jxr-plugin/src/it/JXR-143_nofork/invoker.properties
new file mode 100644
index 0000000..3d5509a
--- /dev/null
+++ b/maven-jxr-plugin/src/it/JXR-143_nofork/invoker.properties
@@ -0,0 +1,18 @@
+# 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 verify site
diff --git a/maven-jxr-plugin/src/it/JXR-143_nofork/pom.xml b/maven-jxr-plugin/src/it/JXR-143_nofork/pom.xml
new file mode 100644
index 0000000..c1cf179
--- /dev/null
+++ b/maven-jxr-plugin/src/it/JXR-143_nofork/pom.xml
@@ -0,0 +1,92 @@
+<?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.jxr.it</groupId>
+  <artifactId>jxr143</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>jxr143</name>
+  <url>http://maven.apache.org</url>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <phase>validate</phase>
+            <configuration>
+              <rules>
+                <AlwaysPass />
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-site-plugin</artifactId>
+        <version>@sitePluginVersion@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+  <reporting>
+    <excludeDefaults>true</excludeDefaults>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+        <version>@project.version@</version>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>jxr-no-fork</report>
+              <report>test-jxr-no-fork</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
diff --git a/maven-jxr-plugin/src/it/JXR-143_nofork/src/main/java/org/apache/maven/jxr/it/App.java b/maven-jxr-plugin/src/it/JXR-143_nofork/src/main/java/org/apache/maven/jxr/it/App.java
new file mode 100644
index 0000000..d73b2cf
--- /dev/null
+++ b/maven-jxr-plugin/src/it/JXR-143_nofork/src/main/java/org/apache/maven/jxr/it/App.java
@@ -0,0 +1,33 @@
+package org.apache.maven.jxr.it;
+
+/*
+ * 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.
+ */
+
+/**
+ * Hello world!
+ *
+ */
+public class App
+    extends App2
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git a/maven-jxr-plugin/src/it/JXR-143_nofork/src/main/java/org/apache/maven/jxr/it/App2.java b/maven-jxr-plugin/src/it/JXR-143_nofork/src/main/java/org/apache/maven/jxr/it/App2.java
new file mode 100644
index 0000000..076ece9
--- /dev/null
+++ b/maven-jxr-plugin/src/it/JXR-143_nofork/src/main/java/org/apache/maven/jxr/it/App2.java
@@ -0,0 +1,32 @@
+package org.apache.maven.jxr.it;
+
+/*
+ * 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.
+ */
+
+/**
+ * Hello world!
+ *
+ */
+public class App2
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git a/maven-jxr-plugin/src/it/JXR-143_nofork/src/test/java/org/apache/maven/jxr/it/AppTest.java b/maven-jxr-plugin/src/it/JXR-143_nofork/src/test/java/org/apache/maven/jxr/it/AppTest.java
new file mode 100644
index 0000000..a762ed3
--- /dev/null
+++ b/maven-jxr-plugin/src/it/JXR-143_nofork/src/test/java/org/apache/maven/jxr/it/AppTest.java
@@ -0,0 +1,57 @@
+package org.apache.maven.jxr.it;
+
+/*
+ * 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 junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}
diff --git a/maven-jxr-plugin/src/it/JXR-143_nofork/verify.groovy b/maven-jxr-plugin/src/it/JXR-143_nofork/verify.groovy
new file mode 100644
index 0000000..bb0cc6e
--- /dev/null
+++ b/maven-jxr-plugin/src/it/JXR-143_nofork/verify.groovy
@@ -0,0 +1,40 @@
+
+/*
+ * 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.
+ */
+assert new File( basedir, 'target/site' ).exists();
+
+content = new File( basedir, 'target/site/project-reports.html' ).text;
+
+assert content.contains( 'xref/index.html' );
+assert content.contains( 'xref-test/index.html' );
+
+assert new File( basedir, 'target/site/xref' ).exists();
+assert new File( basedir, 'target/site/xref/index.html' ).exists();
+assert new File( basedir, 'target/site/xref/org/apache/maven/jxr/it/App.html' ).exists();
+
+assert new File( basedir, 'target/site/xref-test' ).exists();
+assert new File( basedir, 'target/site/xref-test/index.html' ).exists();
+assert new File( basedir, 'target/site/xref-test/org/apache/maven/jxr/it/AppTest.html' ).exists();
+
+content = new File( basedir, 'target/site/xref/org/apache/maven/jxr/it/App.html' ).text;
+assert content.contains( 'App2.html' );
+
+assert 1 == new File( basedir, 'build.log' ).text.count('Always pass!');
+
+return true;
\ No newline at end of file
diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrNoForkReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrNoForkReport.java
new file mode 100644
index 0000000..105cd0f
--- /dev/null
+++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrNoForkReport.java
@@ -0,0 +1,39 @@
+package org.apache.maven.plugin.jxr;
+
+/*
+ * 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.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Creates an html-based, cross referenced version of Java source code
+ * for a project with forking. Note that this goal does require generation of sources before
+ * site generation, e.g. by invoking <tt>mvn clean deploy site</tt>.
+ *
+ * @since 3.1.0
+ * @version $Id$
+ */
+@Mojo( name = "jxr-no-fork" )
+@Execute( phase = LifecyclePhase.NONE )
+public class JxrNoForkReport
+    extends JxrReport
+{
+}
diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestNoForkReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestNoForkReport.java
new file mode 100644
index 0000000..fd3356b
--- /dev/null
+++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestNoForkReport.java
@@ -0,0 +1,39 @@
+package org.apache.maven.plugin.jxr;
+
+/*
+ * 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.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Creates an html-based, cross referenced version of Java source code
+ * for a project's test sources without forking. Note that this goal does require generation of test 
+ * sources before site generation, e.g. by invoking <tt>mvn clean deploy site</tt>.
+ *
+ * @since 3.1.0
+ * @version $Id$
+ */
+@Mojo( name = "test-jxr-no-fork" )
+@Execute( phase = LifecyclePhase.NONE )
+public class JxrTestNoForkReport
+    extends JxrTestReport
+{
+}
diff --git a/maven-jxr-plugin/src/site/apt/examples/nofork.apt.vm b/maven-jxr-plugin/src/site/apt/examples/nofork.apt.vm
new file mode 100644
index 0000000..23f8c33
--- /dev/null
+++ b/maven-jxr-plugin/src/site/apt/examples/nofork.apt.vm
@@ -0,0 +1,72 @@
+ ------
+ Generate JXR without duplicate execution of phase generate-sources.
+ ------
+ Matt Nelson
+ ------
+ 2019-01-18
+ ------
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Generate JXR without duplicate execution of phase generate-sources and generate-test-sources.
+
+ * The standard goals <<<jxr>>> and <<<test-jxr>>> invoke separate lifecyles
+ <<<generate-sources>>> and <<<generate-test-sources>>>.
+
+ * In a CI environment you now might execute something like <<<mvn clean deploy site site-deploy>>>.
+
+ * During <<<site>>> build the standard reports will trigger <<<generate-sources>>> or
+ <<<generate-test-sources>>> again, depending on your build this may take some time, because
+ stuff like <<<enforcer>>> or generating stubs from a WDSL will be invoked again, which may lead
+ to longer build times.
+
+ * See {{{https://issues.apache.org/jira/browse/JXR-143}JXR-143}} as well.
+
+ * As of version 3.1 two new reports are defined, <<<jxr-no-fork>>> and <<<test-jxr-no-fork>>>
+ which will not trigger above phases a second time.
+
+ * Configure this in your <<<reporting>>> section as follows:
+
++-----+
+<project>
+  ...
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+        <version>${project.version}</version>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>jxr-no-fork</report>
+              <report>test-jxr-no-fork</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+  ...
+</project>
++-----+
+
+ <<Note>>: These reports may not be used for aggregate reports.
\ No newline at end of file
diff --git a/maven-jxr-plugin/src/site/apt/index.apt b/maven-jxr-plugin/src/site/apt/index.apt
index 4e112cb..15aa19e 100644
--- a/maven-jxr-plugin/src/site/apt/index.apt
+++ b/maven-jxr-plugin/src/site/apt/index.apt
@@ -32,16 +32,19 @@ Maven JXR Plugin
 
 * Goals Overview
 
-  The JXR Plugin has 4 goals:
+  The JXR Plugin has 6 goals:
 
   * {{{./jxr-mojo.html}jxr:jxr}} is used to generate a cross-reference page of the project's main sources. The generated JXR
   files can be linked to the javadocs of the project.
 
-  * {{{./aggregate-mojo.html}jxr:aggregate}} is used to generate an aggregated cross-reference page of the project's main sources. The generated JXR
-  files can be linked to the javadocs of the project.
+  * {{{./jxr-no-fork-mojo.html}jxr:jxr-nofork}} is used to generate a cross-reference page of the project's main sources without forking the <<<generate-sources>>> phase again. Note that this goal does require generation of main sources before site generation, e.g. by invoking <<<mvn clean deploy site>>>.
+
+  * {{{./aggregate-mojo.html}jxr:aggregate}} is used to generate an aggregated cross-reference page of the project's main sources. The generated JXR files can be linked to the javadocs of the project.
 
   * {{{./test-jxr-mojo.html}jxr:test-jxr}} on the other hand, is used to generate a cross-reference page of the project's test sources.
 
+  * {{{./test-jxr-no-fork-mojo.html}jxr:test-jxr-nofork}} on the other hand, is used to generate a cross-reference page of the project's test sources. without forking the <<<generate-test-sources>>> phase again. Note that this goal does require generation of test sources before site generation, e.g. by invoking <<<mvn clean deploy site>>>.
+
   * {{{./test-aggregate-mojo.html}jxr:test-aggregate}} on the other hand, is used to generate an aggregated cross-reference page of the project's test sources.
 
 * Usage
@@ -73,4 +76,6 @@ Maven JXR Plugin
 
    * {{{./examples/linkjavadoc.html}Linking JXR Files to Javadocs}}
 
+   * {{{./examples/nofork.html}Generate JXR without duplicate execution of phase generate-sources}}
+
    []
diff --git a/maven-jxr-plugin/src/site/site.xml b/maven-jxr-plugin/src/site/site.xml
index 98faf0e..b9aa21d 100644
--- a/maven-jxr-plugin/src/site/site.xml
+++ b/maven-jxr-plugin/src/site/site.xml
@@ -37,6 +37,7 @@ under the License.
       <item name="Aggregating JXR Reports for Multi-module Projects" href="/examples/aggregate.html"/>
       <item name="Including/Excluding Source Files" href="/examples/include-exclude.html"/>
       <item name="Linking JXR Files to Javadocs" href="/examples/linkjavadoc.html"/>
+      <item name="Generate JXR without duplicate execution of phase generate-sources" href="/examples/nofork.html"/>
       <item name="JXR Sample Report" href="/xref/index.html"/>
     </menu>
     <menu ref="reports"/>