From 80697ad83aa6ec58d81ffce31b9b67f86621bbbc Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Mon, 5 Mar 2018 17:11:41 -0600 Subject: [PATCH] [MJAVADOC-444] add aggregate-no-fork and aggregate-test-no-fork for non-forking versions of aggregate goals. --- .../projects/MJAVADOC-444/invoker.properties | 18 ++++ src/it/projects/MJAVADOC-444/moduleA/pom.xml | 41 ++++++++ .../main/java/com/mycompany/myapp/AppA.java | 31 ++++++ .../java/com/mycompany/myapp/AppATest.java | 57 +++++++++++ src/it/projects/MJAVADOC-444/moduleB/pom.xml | 41 ++++++++ .../main/java/com/mycompany/myapp/AppB.java | 31 ++++++ .../java/com/mycompany/myapp/AppBTest.java | 57 +++++++++++ src/it/projects/MJAVADOC-444/pom.xml | 98 +++++++++++++++++++ src/it/projects/MJAVADOC-444/verify.bsh | 40 ++++++++ .../AggregatorJavadocNoForkReport.java | 39 ++++++++ .../AggregatorTestJavadocNoForkReport.java | 39 ++++++++ src/site/apt/examples/aggregate-nofork.apt.vm | 65 ++++++++++++ src/site/apt/examples/javadoc-nofork.apt.vm | 3 +- src/site/apt/index.apt.vm | 20 +++- src/site/site.xml | 1 + 15 files changed, 576 insertions(+), 5 deletions(-) create mode 100644 src/it/projects/MJAVADOC-444/invoker.properties create mode 100644 src/it/projects/MJAVADOC-444/moduleA/pom.xml create mode 100644 src/it/projects/MJAVADOC-444/moduleA/src/main/java/com/mycompany/myapp/AppA.java create mode 100644 src/it/projects/MJAVADOC-444/moduleA/src/test/java/com/mycompany/myapp/AppATest.java create mode 100644 src/it/projects/MJAVADOC-444/moduleB/pom.xml create mode 100644 src/it/projects/MJAVADOC-444/moduleB/src/main/java/com/mycompany/myapp/AppB.java create mode 100644 src/it/projects/MJAVADOC-444/moduleB/src/test/java/com/mycompany/myapp/AppBTest.java create mode 100644 src/it/projects/MJAVADOC-444/pom.xml create mode 100644 src/it/projects/MJAVADOC-444/verify.bsh create mode 100644 src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocNoForkReport.java create mode 100644 src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocNoForkReport.java create mode 100644 src/site/apt/examples/aggregate-nofork.apt.vm diff --git a/src/it/projects/MJAVADOC-444/invoker.properties b/src/it/projects/MJAVADOC-444/invoker.properties new file mode 100644 index 00000000..3d5509aa --- /dev/null +++ b/src/it/projects/MJAVADOC-444/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/src/it/projects/MJAVADOC-444/moduleA/pom.xml b/src/it/projects/MJAVADOC-444/moduleA/pom.xml new file mode 100644 index 00000000..b2b4670c --- /dev/null +++ b/src/it/projects/MJAVADOC-444/moduleA/pom.xml @@ -0,0 +1,41 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.maven-javadoc-plugin.it + mjavadoc-444 + 1.0-SNAPSHOT + + mjavadoc-444-moduleA + jar + + + + junit + junit + 3.8.1 + test + + + + diff --git a/src/it/projects/MJAVADOC-444/moduleA/src/main/java/com/mycompany/myapp/AppA.java b/src/it/projects/MJAVADOC-444/moduleA/src/main/java/com/mycompany/myapp/AppA.java new file mode 100644 index 00000000..6646f695 --- /dev/null +++ b/src/it/projects/MJAVADOC-444/moduleA/src/main/java/com/mycompany/myapp/AppA.java @@ -0,0 +1,31 @@ +package com.mycompany.myapp; + +/* + * 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 AppA +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/src/it/projects/MJAVADOC-444/moduleA/src/test/java/com/mycompany/myapp/AppATest.java b/src/it/projects/MJAVADOC-444/moduleA/src/test/java/com/mycompany/myapp/AppATest.java new file mode 100644 index 00000000..f54bad87 --- /dev/null +++ b/src/it/projects/MJAVADOC-444/moduleA/src/test/java/com/mycompany/myapp/AppATest.java @@ -0,0 +1,57 @@ +package com.mycompany.myapp; + +/* + * 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 AppATest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppATest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppATest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/src/it/projects/MJAVADOC-444/moduleB/pom.xml b/src/it/projects/MJAVADOC-444/moduleB/pom.xml new file mode 100644 index 00000000..c0538308 --- /dev/null +++ b/src/it/projects/MJAVADOC-444/moduleB/pom.xml @@ -0,0 +1,41 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.maven-javadoc-plugin.it + mjavadoc-444 + 1.0-SNAPSHOT + + mjavadoc-444-moduleB + jar + + + + junit + junit + 3.8.1 + test + + + + diff --git a/src/it/projects/MJAVADOC-444/moduleB/src/main/java/com/mycompany/myapp/AppB.java b/src/it/projects/MJAVADOC-444/moduleB/src/main/java/com/mycompany/myapp/AppB.java new file mode 100644 index 00000000..bf38d7be --- /dev/null +++ b/src/it/projects/MJAVADOC-444/moduleB/src/main/java/com/mycompany/myapp/AppB.java @@ -0,0 +1,31 @@ +package com.mycompany.myapp; + +/* + * 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 AppB +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/src/it/projects/MJAVADOC-444/moduleB/src/test/java/com/mycompany/myapp/AppBTest.java b/src/it/projects/MJAVADOC-444/moduleB/src/test/java/com/mycompany/myapp/AppBTest.java new file mode 100644 index 00000000..e7c57f58 --- /dev/null +++ b/src/it/projects/MJAVADOC-444/moduleB/src/test/java/com/mycompany/myapp/AppBTest.java @@ -0,0 +1,57 @@ +package com.mycompany.myapp; + +/* + * 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 AppBTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppBTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppBTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/src/it/projects/MJAVADOC-444/pom.xml b/src/it/projects/MJAVADOC-444/pom.xml new file mode 100644 index 00000000..d4178e1c --- /dev/null +++ b/src/it/projects/MJAVADOC-444/pom.xml @@ -0,0 +1,98 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.maven-javadoc-plugin.it + mjavadoc-444 + 1.0-SNAPSHOT + pom + + myapp + http://maven.apache.org + + + UTF-8 + + + + moduleA + moduleB + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.3.1 + + + default-enforce + + enforce + + + + + + true + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + @pom.version@ + + + org.apache.maven.plugins + maven-site-plugin + @sitePluginVersion@ + + + + + + + true + + + org.apache.maven.plugins + maven-javadoc-plugin + @pom.version@ + + + + aggregate-no-fork + test-aggregate-no-fork + + + + + + + diff --git a/src/it/projects/MJAVADOC-444/verify.bsh b/src/it/projects/MJAVADOC-444/verify.bsh new file mode 100644 index 00000000..828d834b --- /dev/null +++ b/src/it/projects/MJAVADOC-444/verify.bsh @@ -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. + */ + +import java.io.*; +import org.codehaus.plexus.util.*; + +File indexFile = new File( basedir, "target/site/apidocs/index.html" ); + +if ( !indexFile.exists() ) +{ + System.err.println( indexFile.getAbsolutePath() + " is missing." ); + return false; +} + +File buildLog = new File( basedir, "build.log" ); +String content = IOUtil.toString( new FileInputStream( buildLog ) ); +String needle = ">>> maven-javadoc-plugin"; +if ( content.contains( needle ) ) +{ + System.err.println( "build.log contains '" + needle + "'" ); + return false; +} +return true; diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocNoForkReport.java b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocNoForkReport.java new file mode 100644 index 00000000..0e27b05c --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocNoForkReport.java @@ -0,0 +1,39 @@ +package org.apache.maven.plugins.javadoc; + +/* + * 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; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Generates documentation for the Java code in an aggregator project using the standard + * Javadoc Tool. + * + * @version $Id$ + * @since 3.0.1 + */ +@Mojo( name = "aggregate-no-fork", requiresDependencyResolution = ResolutionScope.COMPILE ) +@Execute( phase = LifecyclePhase.NONE ) +public class AggregatorJavadocNoForkReport + extends AggregatorJavadocReport +{ +} diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocNoForkReport.java b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocNoForkReport.java new file mode 100644 index 00000000..6e061674 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocNoForkReport.java @@ -0,0 +1,39 @@ +package org.apache.maven.plugins.javadoc; + +/* + * 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; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Generates documentation for the Java Test code in an aggregator project using the standard + * Javadoc Tool. + * + * @version $Id$ + * @since 3.0.1 + */ +@Mojo( name = "test-aggregate-no-fork", requiresDependencyResolution = ResolutionScope.TEST ) +@Execute( phase = LifecyclePhase.NONE ) +public class AggregatorTestJavadocNoForkReport + extends AggregatorTestJavadocReport +{ +} diff --git a/src/site/apt/examples/aggregate-nofork.apt.vm b/src/site/apt/examples/aggregate-nofork.apt.vm new file mode 100644 index 00000000..6669f425 --- /dev/null +++ b/src/site/apt/examples/aggregate-nofork.apt.vm @@ -0,0 +1,65 @@ + ------ + Generate aggregate Javadoc without duplicate execution of phase compile. + ------ + +~~ 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 aggregate Javadoc without duplicate execution of phase compile. + + * The standard goals <<>> and <<>> invoke separate lifecyles + <<>> and <<>>. + + * In a CI environment you now might execute something like <<>>. + + * During <<>> build the standard reports will trigger <<>> or + <<>> again, depending on your build this may take some time, because + stuff like <<>> or generating stubs from a WDSL will be invoked again, which may lead + to longer build times. + + * As of version 3.0.1 two new reports are defined, <<>> and <<>> + which will not trigger above phases a second time. + + * Configure this in your <<>> section as follows: + ++-----+ + + ... + + true + + + org.apache.maven.plugins + maven-javadoc-plugin + ${project.version} + + + + aggregate-no-fork + test-aggregate-no-fork + + + + + + + ... + ++-----+ diff --git a/src/site/apt/examples/javadoc-nofork.apt.vm b/src/site/apt/examples/javadoc-nofork.apt.vm index 15b83736..4c8d2183 100644 --- a/src/site/apt/examples/javadoc-nofork.apt.vm +++ b/src/site/apt/examples/javadoc-nofork.apt.vm @@ -70,4 +70,5 @@ Generate Javadoc without duplicate execution of phase generate-sources. +-----+ - <>: These reports may not be used for aggregate reports. + <>: These reports may not be used for aggregate reports. For those, see the example of + {{{./aggregate-nofork.html}generating aggregate Javadocs without execution of phase compile}}. diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 580fe157..0c217f1a 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -49,7 +49,7 @@ javadoc.exe(or .sh) @options @packages | @argfile * Goals Overview - The Javadoc Plugin has 14 goals: + The Javadoc Plugin has 16 goals: * {{{./javadoc-mojo.html}javadoc:javadoc}} generates the Javadoc files for the project. It executes the standard Javadoc tool and supports the parameters used by the tool. @@ -58,12 +58,12 @@ javadoc.exe(or .sh) @options @packages | @argfile the standard Javadoc tool and supports the parameters used by the tool. * {{{./javadoc-no-fork-mojo.html}javadoc:javadoc-no-fork}} generates the Javadoc files for the project. - It executes the standard Javadoc tool and supports the parameters used by the tool without forking the + It executes the standard Javadoc tool and supports the parameters used by the tool without forking the <<>> phase again. Note that this goal does require generation of test sources before site generation, e.g. by invoking <<>>. - * {{{./test-javadoc-no-fork-mojo.html}javadoc:test-javadoc-no-fork}} generates the test Javadoc files for the project. - It executes the standard Javadoc tool and supports the parameters used by the tool without forking the + * {{{./test-javadoc-no-fork-mojo.html}javadoc:test-javadoc-no-fork}} generates the test Javadoc files for the project. + It executes the standard Javadoc tool and supports the parameters used by the tool without forking the <<>> phase again. Note that this goal does require generation of test sources before site generation, e.g. by invoking <<>>. @@ -73,6 +73,16 @@ javadoc.exe(or .sh) @options @packages | @argfile * {{{./test-aggregate-mojo.html}javadoc:test-aggregate}} generates the test Javadoc files for an aggregator project. It executes the standard Javadoc tool and supports the parameters used by the tool. + * {{{./aggregate-no-fork-mojo.html}javadoc:aggregate-no-fork}} generates the Javadoc files for an aggregator project. + It executes the standard Javadoc tool and supports the parameters used by the tool without forking the <>> + phase again. Note that this goal does require generation of class files before site generation, e.g. by invoking + <<>> or <<>>. + + * {{{./test-aggregate-no-fork-mojo.html}javadoc:test-aggregate}} generates the test Javadoc files for an aggregator + project. It executes the standard Javadoc tool and supports the parameters used by the tool without forking the + <<>> phase again. Note that this goal does require generation of test class files before site generation, + e.g. by invoking <<>> or <<>>. + * {{{./jar-mojo.html}javadoc:jar}} creates an archive file of the generated Javadocs. It is used during the release process to create the Javadoc artifact for the project's release. This artifact is uploaded to the remote repository along with the project's compiled binary and source archive. @@ -155,4 +165,6 @@ javadoc.exe(or .sh) @options @packages | @argfile * {{{./examples/javadoc-nofork.html}Generate Javadoc without duplicate execution of phase generate-sources}} + * {{{./examples/aggregate-nofork.html}Generate aggregate Javadocs without execution of phase compile}} + [] diff --git a/src/site/site.xml b/src/site/site.xml index 727da9a7..947580a6 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -55,6 +55,7 @@ under the License. +