From a943526212c554ea59459a0a22b8ba7b7c9f9428 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Fri, 14 Feb 2020 13:44:46 +1000 Subject: [PATCH] [MJAVADOC-636] exclude some modules from aggregated javadoc Signed-off-by: olivier lamy --- .../b/c/d1/pom.xml | 33 +++++++ .../b/c/d1/src/main/java/a/b/c/d/D1.java | 25 ++++++ .../b/c/d2/pom.xml | 33 +++++++ .../b/c/d2/src/main/java/a/b/c/d/D2.java | 25 ++++++ .../b/c/pom.xml | 39 ++++++++ .../b/e/pom.xml | 33 +++++++ .../b/e/src/main/java/a/b/e/E.java | 25 ++++++ .../b/pom.xml | 39 ++++++++ .../f/pom.xml | 33 +++++++ .../f/src/main/java/a/f/F.java | 24 +++++ .../invoker.properties | 19 ++++ .../pom.xml | 89 +++++++++++++++++++ .../verify.groovy | 38 ++++++++ .../plugins/javadoc/AbstractJavadocMojo.java | 36 +++++++- 14 files changed, 490 insertions(+), 1 deletion(-) create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d1/pom.xml create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d1/src/main/java/a/b/c/d/D1.java create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d2/pom.xml create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d2/src/main/java/a/b/c/d/D2.java create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/pom.xml create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/e/pom.xml create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/e/src/main/java/a/b/e/E.java create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/pom.xml create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/f/pom.xml create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/f/src/main/java/a/f/F.java create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/invoker.properties create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/pom.xml create mode 100644 src/it/projects/MJAVADOC-636-aggregate_module_skipped/verify.groovy diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d1/pom.xml b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d1/pom.xml new file mode 100644 index 00000000..643a6aad --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d1/pom.xml @@ -0,0 +1,33 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.javadoc.it + mjavadoc636c + 1.0-SNAPSHOT + + mjavadoc636d1 + + diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d1/src/main/java/a/b/c/d/D1.java b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d1/src/main/java/a/b/c/d/D1.java new file mode 100644 index 00000000..36885525 --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d1/src/main/java/a/b/c/d/D1.java @@ -0,0 +1,25 @@ +package a.b.c.d; + +/* + * 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. + */ + +public class D1 +{ + +} \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d2/pom.xml b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d2/pom.xml new file mode 100644 index 00000000..e770e53b --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d2/pom.xml @@ -0,0 +1,33 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.javadoc.it + mjavadoc636c + 1.0-SNAPSHOT + + mjavadoc636d2 + + diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d2/src/main/java/a/b/c/d/D2.java b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d2/src/main/java/a/b/c/d/D2.java new file mode 100644 index 00000000..d588de3e --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/d2/src/main/java/a/b/c/d/D2.java @@ -0,0 +1,25 @@ +package a.b.c.d; + +/* + * 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. + */ + +public class D2 +{ + +} \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/pom.xml b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/pom.xml new file mode 100644 index 00000000..1af9c3a7 --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/c/pom.xml @@ -0,0 +1,39 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.javadoc.it + mjavadoc636b + 1.0-SNAPSHOT + + mjavadoc636c + pom + + + d1 + d2 + + + diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/e/pom.xml b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/e/pom.xml new file mode 100644 index 00000000..8c50b2ad --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/e/pom.xml @@ -0,0 +1,33 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.javadoc.it + mjavadoc636b + 1.0-SNAPSHOT + + mjavadoc636e + + diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/e/src/main/java/a/b/e/E.java b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/e/src/main/java/a/b/e/E.java new file mode 100644 index 00000000..9b8dcb73 --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/e/src/main/java/a/b/e/E.java @@ -0,0 +1,25 @@ +package a.b.e; + +/* + * 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. + */ + +public interface E +{ + +} \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/pom.xml b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/pom.xml new file mode 100644 index 00000000..f463f5ab --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/b/pom.xml @@ -0,0 +1,39 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.javadoc.it + mjavadoc636 + 1.0-SNAPSHOT + + mjavadoc636b + pom + + + c + e + + + diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/f/pom.xml b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/f/pom.xml new file mode 100644 index 00000000..a1c798a5 --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/f/pom.xml @@ -0,0 +1,33 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.javadoc.it + mjavadoc636 + 1.0-SNAPSHOT + + mjavadoc636f + + diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/f/src/main/java/a/f/F.java b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/f/src/main/java/a/f/F.java new file mode 100644 index 00000000..1f726333 --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/f/src/main/java/a/f/F.java @@ -0,0 +1,24 @@ +package a.f; + +/* + * 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. + */ + +public interface F +{ +} \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/invoker.properties b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/invoker.properties new file mode 100644 index 00000000..233d924e --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/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 = javadoc:jar javadoc:aggregate-jar +invoker.goals = clean package javadoc:jar javadoc:aggregate-jar install diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/pom.xml b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/pom.xml new file mode 100644 index 00000000..2573892b --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/pom.xml @@ -0,0 +1,89 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.javadoc.it + mjavadoc636 + 1.0-SNAPSHOT + pom + + https://issues.apache.org/jira/browse/MJAVADOC-134 + + + UTF-8 + + + + b + f + + + + + + + org.apache.maven.plugins + maven-site-plugin + @sitePluginVersion@ + + + org.apache.maven.plugins + maven-javadoc-plugin + @project.version@ + + mjavadoc636e,mjavadoc636d1 + + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + aggregate + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.9 + + + + index + + + + + + + diff --git a/src/it/projects/MJAVADOC-636-aggregate_module_skipped/verify.groovy b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/verify.groovy new file mode 100644 index 00000000..d7aaec71 --- /dev/null +++ b/src/it/projects/MJAVADOC-636-aggregate_module_skipped/verify.groovy @@ -0,0 +1,38 @@ +/* + * 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.util.jar.* + +def aggregatedJavadoc = new File( basedir, 'target/mjavadoc636-1.0-SNAPSHOT-javadoc.jar'); + +assert aggregatedJavadoc.exists() + +def jar = new JarFile(aggregatedJavadoc) + +def files = new ArrayList() + +for (JarEntry file in jar.entries()){ + files.add(file.getName()) +} + +assert !files.contains("a/b/e/E.html") +assert !files.contains("a/b/c/d/D1.html") +assert files.contains("a/b/c/d/D2.html") +assert files.contains("a/f/F.html") + diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java index c04c1f97..ee29c6a1 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -1749,6 +1749,17 @@ public abstract class AbstractJavadocMojo defaultValue = "${project.build.directory}/maven-javadoc-plugin-stale-data.txt" ) private File staleDataPath; + + /** + *

+ * Comma separated list of modules (artifactId) to not add in aggregated javadoc + *

+ * + * @since 3.2.0 + */ + @Parameter( property = "maven.javadoc.skippedModules" ) + private String skippedModules; + // ---------------------------------------------------------------------- // protected methods // ---------------------------------------------------------------------- @@ -6806,6 +6817,10 @@ protected void failOnError( String prefix, Exception e ) } + /** + * + * @return List of projects to be part of aggregated javadoc + */ private List getAggregatedProjects() { if ( this.reactorProjects == null ) @@ -6815,7 +6830,8 @@ private List getAggregatedProjects() Map reactorProjectsMap = new HashMap<>(); for ( MavenProject reactorProject : this.reactorProjects ) { - if ( !isSkippedJavadoc( reactorProject ) ) + if ( !isSkippedJavadoc( reactorProject ) && // + !isSkippedModule( reactorProject ) ) { reactorProjectsMap.put( reactorProject.getBasedir().toPath(), reactorProject ); } @@ -6824,6 +6840,24 @@ private List getAggregatedProjects() return new ArrayList<>( modulesForAggregatedProject( project, reactorProjectsMap ) ); } + /** + * + * @return true if the module need to be skipped from aggregate generation + */ + protected boolean isSkippedModule( MavenProject mavenProject ) + { + if ( StringUtils.isEmpty( this.skippedModules ) ) + { + return false; + } + List modulesToSkip = Arrays.asList( StringUtils.split( this.skippedModules, ',' ) ); + return modulesToSkip.contains( mavenProject.getArtifactId() ); + } + + /** + * + * @return true if the pom configuration skip javadoc generation for the project + */ protected boolean isSkippedJavadoc( MavenProject mavenProject ) { String property = mavenProject.getProperties().getProperty( "maven.javadoc.skip" );