From 2d10bff932a39278beafac5235c028cecb0fecba Mon Sep 17 00:00:00 2001 From: Harald Wellmann Date: Thu, 3 Dec 2015 21:08:56 +0100 Subject: [PATCH 1/3] [MJAVADOC-437] for aggregate reports, do not resolve artifacts of current reactor to make initial build pass --- .../maven/plugin/javadoc/AbstractJavadocMojo.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java b/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java index e52a35052b..a3f5062646 100644 --- a/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java +++ b/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java @@ -2501,7 +2501,9 @@ private String[] getExcludedPackages() /** * Method that sets the classpath elements that will be specified in the javadoc -classpath - * parameter. + * parameter. Since we have all the sources of the current reactor, it is sufficient to consider the + * dependencies of the reactor modules, excluding the module artifacts which may not yet be available + * when the reactor project is built for the first time. * * @return a String that contains the concatenated classpath elements, separated by the System pathSeparator * string (colon (:) on Solaris or semi-colon (;) on Windows). @@ -2523,6 +2525,11 @@ private String getClasspath() if ( isAggregator() && project.isExecutionRoot() ) { + List reactorArtifacts = new ArrayList(); + for ( MavenProject p : reactorProjects ) + { + reactorArtifacts.add( p.getArtifact() ); + } try { for ( MavenProject subProject : reactorProjects ) @@ -2532,6 +2539,8 @@ private String getClasspath() classpathElements.addAll( getProjectBuildOutputDirs( subProject ) ); Set dependencyArtifacts = subProject.createArtifacts( factory, null, null ); + // do not attempt to resolve artifacts of the current reactor which may not exist yet + dependencyArtifacts.removeAll( reactorArtifacts ); if ( !dependencyArtifacts.isEmpty() ) { ArtifactResolutionResult result = null; From 046411f5172f7d5f9dd5030457fa3c67c47ba681 Mon Sep 17 00:00:00 2001 From: Harald Wellmann Date: Sat, 5 Dec 2015 16:11:55 +0100 Subject: [PATCH 2/3] [MJAVADOC-437] added integration test --- .../src/it/MJAVADOC-437/invoker.properties | 19 +++++ .../src/it/MJAVADOC-437/module1/pom.xml | 36 +++++++++ .../src/main/java/com/example/foo/Foo.java | 33 ++++++++ .../src/it/MJAVADOC-437/module2/pom.xml | 50 ++++++++++++ .../src/main/java/com/example/bar/Bar.java | 37 +++++++++ .../src/it/MJAVADOC-437/pom.xml | 80 +++++++++++++++++++ .../src/it/MJAVADOC-437/verify.bsh | 64 +++++++++++++++ 7 files changed, 319 insertions(+) create mode 100644 maven-javadoc-plugin/src/it/MJAVADOC-437/invoker.properties create mode 100644 maven-javadoc-plugin/src/it/MJAVADOC-437/module1/pom.xml create mode 100644 maven-javadoc-plugin/src/it/MJAVADOC-437/module1/src/main/java/com/example/foo/Foo.java create mode 100644 maven-javadoc-plugin/src/it/MJAVADOC-437/module2/pom.xml create mode 100644 maven-javadoc-plugin/src/it/MJAVADOC-437/module2/src/main/java/com/example/bar/Bar.java create mode 100644 maven-javadoc-plugin/src/it/MJAVADOC-437/pom.xml create mode 100644 maven-javadoc-plugin/src/it/MJAVADOC-437/verify.bsh diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/invoker.properties b/maven-javadoc-plugin/src/it/MJAVADOC-437/invoker.properties new file mode 100644 index 0000000000..3f0a694c09 --- /dev/null +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/invoker.properties @@ -0,0 +1,19 @@ +# 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 javadoc:aggregate + diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/module1/pom.xml b/maven-javadoc-plugin/src/it/MJAVADOC-437/module1/pom.xml new file mode 100644 index 0000000000..5c19e61605 --- /dev/null +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/module1/pom.xml @@ -0,0 +1,36 @@ + + + + + + 4.0.0 + + + org.apache.maven.plugins.maven-javadoc-plugin.it + mjavadoc437 + 1.0-SNAPSHOT + + + org.apache.maven.plugins.maven-javadoc-plugin.it + mjavadoc437-module1 + 1.0-SNAPSHOT + Test MJAVADOC-437 Module 1 + + diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/module1/src/main/java/com/example/foo/Foo.java b/maven-javadoc-plugin/src/it/MJAVADOC-437/module1/src/main/java/com/example/foo/Foo.java new file mode 100644 index 0000000000..587af691d8 --- /dev/null +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/module1/src/main/java/com/example/foo/Foo.java @@ -0,0 +1,33 @@ +package com.example.foo; + +/* + * 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. + */ + +/** + * This is a Foo. + */ +public class Foo +{ + /** + * Frobnicates the foo. + */ + public void frobnicate() + { + } +} diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/pom.xml b/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/pom.xml new file mode 100644 index 0000000000..bf7ae7038d --- /dev/null +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/pom.xml @@ -0,0 +1,50 @@ + + + + + + 4.0.0 + + + org.apache.maven.plugins.maven-javadoc-plugin.it + mjavadoc437 + 1.0-SNAPSHOT + + + org.apache.maven.plugins.maven-javadoc-plugin.it + mjavadoc437-module2 + 1.0-SNAPSHOT + Test MJAVADOC-437 Module 2 + + + + org.apache.maven.plugins.maven-javadoc-plugin.it + mjavadoc437-module1 + ${project.version} + + + commons-io + commons-io + 2.2 + + + + + diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/src/main/java/com/example/bar/Bar.java b/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/src/main/java/com/example/bar/Bar.java new file mode 100644 index 0000000000..1da52c7c35 --- /dev/null +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/src/main/java/com/example/bar/Bar.java @@ -0,0 +1,37 @@ +package com.example.bar; + +/* + * 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.commons.io.ByteOrderMark; + +/** + * This is a Bar. + */ +public class Bar +{ + /** + * Glibbyfies the bar. + * @param bom byte order mark + */ + public void glibbify(ByteOrderMark bom) + { + // empty + } +} diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/pom.xml b/maven-javadoc-plugin/src/it/MJAVADOC-437/pom.xml new file mode 100644 index 0000000000..270a2e8b17 --- /dev/null +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/pom.xml @@ -0,0 +1,80 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.maven-javadoc-plugin.it + mjavadoc437 + pom + 1.0-SNAPSHOT + Test MJAVADOC-437 + + + module1 + module2 + + + + UTF-8 + + + + + junit + junit + 3.8.2 + test + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 2.5 + + + org.apache.maven.plugins + maven-javadoc-plugin + @pom.version@ + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/verify.bsh b/maven-javadoc-plugin/src/it/MJAVADOC-437/verify.bsh new file mode 100644 index 0000000000..8cf5ad9f21 --- /dev/null +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/verify.bsh @@ -0,0 +1,64 @@ + +/* + * 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.*; + +// In JDK 7, javadoc terminates with exit code 0 even when there are errors. +// To find an error, we either have to parse the build.log generated by +// maven-invoker-plugin, or look at the generated HTML files. +// The latter is approach is more stable, as it does not depend on a given +// javadoc version or the error message formatting. +// Our module2 has a dependency on commons-io, and class Bar has a parameter +// of type org.apache.commons.io.ByteOrderMark. In the generated Javadoc, +// this parameter type should occur with its fully qualified name. +// If the package prefix is missing, we know that maven-javadoc-plugin +// failed to resolve the classpath dependencies. + +boolean result = true; + +try +{ + File javadoc = new File( basedir, "target/site/apidocs/com/example/bar/Bar.html" ); + if ( !javadoc.exists() ) + { + System.err.println( javadoc + " is missing" ); + return false; + } + + FileReader fr = new FileReader( javadoc ); + BufferedReader br = new BufferedReader( fr ); + String line; + while( ( line = br.readLine() ) != null ) + { + if ( line.contains( "org.apache.commons.io" ) ) + { + return true; + } + } + System.err.println( "package name org.apache.commons.io not found" ); + return false; +} +catch( RuntimeException e ) +{ + e.printStackTrace(); + return false; +} + +return result; From c858d3ca7c5f74124d394161e06e7950602198df Mon Sep 17 00:00:00 2001 From: Harald Wellmann Date: Sun, 6 Dec 2015 22:32:23 +0100 Subject: [PATCH 3/3] [MJAVADOC-437] test cleanup removed unneeded dependencies and plugins fixed formatting closed BufferedReader documented the need for an external dependency (e.g. commons-io) --- maven-javadoc-plugin/pom.xml | 1 + .../src/it/MJAVADOC-437/module2/pom.xml | 12 +- .../src/main/java/com/example/bar/Bar.java | 10 ++ .../src/it/MJAVADOC-437/pom.xml | 28 ---- .../src/it/MJAVADOC-437/verify.bsh | 133 +++++++++--------- 5 files changed, 86 insertions(+), 98 deletions(-) diff --git a/maven-javadoc-plugin/pom.xml b/maven-javadoc-plugin/pom.xml index 2ffd4dd0b6..d570f65aaf 100644 --- a/maven-javadoc-plugin/pom.xml +++ b/maven-javadoc-plugin/pom.xml @@ -405,6 +405,7 @@ under the License. MJAVADOC-369/pom.xml MJAVADOC-407/pom.xml MJAVADOC-414/pom.xml + MJAVADOC-437/pom.xml diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/pom.xml b/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/pom.xml index bf7ae7038d..f527126159 100644 --- a/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/pom.xml +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/pom.xml @@ -39,12 +39,12 @@ mjavadoc437-module1 ${project.version} - - commons-io - commons-io - 2.2 - - + + + commons-io + commons-io + 2.2 + diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/src/main/java/com/example/bar/Bar.java b/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/src/main/java/com/example/bar/Bar.java index 1da52c7c35..ca1b535d3a 100644 --- a/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/src/main/java/com/example/bar/Bar.java +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/module2/src/main/java/com/example/bar/Bar.java @@ -28,6 +28,16 @@ public class Bar { /** * Glibbyfies the bar. + *

+ * NOTE: The parameter using an external dependency is essential to + * make the test fail with maven-javadoc-plugin 2.10.3. + *

+ * If one dependency fails to be resolved (the one on module1), all + * dependencies of the current module will be skipped. + *

+ * As a result, in the generated Javadoc, ByteOrderMark will be missing + * the package prefix. + * * @param bom byte order mark */ public void glibbify(ByteOrderMark bom) diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/pom.xml b/maven-javadoc-plugin/src/it/MJAVADOC-437/pom.xml index 270a2e8b17..be64d03fc5 100644 --- a/maven-javadoc-plugin/src/it/MJAVADOC-437/pom.xml +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/pom.xml @@ -37,23 +37,9 @@ UTF-8 - - - junit - junit - 3.8.2 - test - - - - - org.apache.maven.plugins - maven-plugin-plugin - 2.5 - org.apache.maven.plugins maven-javadoc-plugin @@ -61,20 +47,6 @@ - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-javadoc-plugin - - diff --git a/maven-javadoc-plugin/src/it/MJAVADOC-437/verify.bsh b/maven-javadoc-plugin/src/it/MJAVADOC-437/verify.bsh index 8cf5ad9f21..0507b02e3c 100644 --- a/maven-javadoc-plugin/src/it/MJAVADOC-437/verify.bsh +++ b/maven-javadoc-plugin/src/it/MJAVADOC-437/verify.bsh @@ -1,64 +1,69 @@ - -/* - * 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.*; - -// In JDK 7, javadoc terminates with exit code 0 even when there are errors. -// To find an error, we either have to parse the build.log generated by -// maven-invoker-plugin, or look at the generated HTML files. -// The latter is approach is more stable, as it does not depend on a given -// javadoc version or the error message formatting. -// Our module2 has a dependency on commons-io, and class Bar has a parameter -// of type org.apache.commons.io.ByteOrderMark. In the generated Javadoc, -// this parameter type should occur with its fully qualified name. -// If the package prefix is missing, we know that maven-javadoc-plugin -// failed to resolve the classpath dependencies. - -boolean result = true; - -try -{ - File javadoc = new File( basedir, "target/site/apidocs/com/example/bar/Bar.html" ); - if ( !javadoc.exists() ) - { - System.err.println( javadoc + " is missing" ); - return false; - } - - FileReader fr = new FileReader( javadoc ); - BufferedReader br = new BufferedReader( fr ); - String line; - while( ( line = br.readLine() ) != null ) - { - if ( line.contains( "org.apache.commons.io" ) ) - { - return true; - } - } - System.err.println( "package name org.apache.commons.io not found" ); - return false; -} -catch( RuntimeException e ) -{ - e.printStackTrace(); - return false; -} - -return result; + +/* + * 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.*; + +// In JDK 7, javadoc terminates with exit code 0 even when there are errors. +// To find an error, we either have to parse the build.log generated by +// maven-invoker-plugin, or look at the generated HTML files. +// The latter is approach is more stable, as it does not depend on a given +// javadoc version or the error message formatting. +// Our module2 has a dependency on commons-io, and class Bar has a parameter +// of type org.apache.commons.io.ByteOrderMark. In the generated Javadoc, +// this parameter type should occur with its fully qualified name. +// If the package prefix is missing, we know that maven-javadoc-plugin +// failed to resolve the classpath dependencies. + +boolean result = true; + +try +{ + File javadoc = new File( basedir, "target/site/apidocs/com/example/bar/Bar.html" ); + if ( !javadoc.exists() ) + { + System.err.println( javadoc + " is missing" ); + return false; + } + + FileReader fr = new FileReader( javadoc ); + BufferedReader br = new BufferedReader( fr ); + String line; + while ( ( line = br.readLine() ) != null ) + { + if ( line.contains( "org.apache.commons.io" ) ) + { + result = true; + break; + } + } + br.close(); + if ( !result ) + { + System.err.println( "package name org.apache.commons.io not found" ); + } + return result; +} +catch ( Exception e ) +{ + e.printStackTrace(); + return false; +} + +return result;