This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch MJAVADOC-618 in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit ec7ecaa9a709040fbfc9621dcad931737a50d416 Author: rfscholte <[email protected]> AuthorDate: Thu Aug 26 19:22:47 2021 +0200 [MJAVADOC-618] Goal javadoc:aggregate fails with submodules packaged as war --- .../projects/MJAVADOC-618_modular-war/app/pom.xml | 63 ++++++++++++++++++++ .../main/java/com/mycompany/app/Application.java | 27 +++++++++ .../app/src/main/java/module-info.java | 23 ++++++++ .../app/src/main/webapp/WEB-INF/web.xml | 26 +++++++++ .../MJAVADOC-618_modular-war/invoker.properties | 18 ++++++ .../projects/MJAVADOC-618_modular-war/lib/pom.xml | 45 ++++++++++++++ .../src/main/java/com/mycompany/lib/Library.java | 24 ++++++++ .../lib/src/main/java/module-info.java | 23 ++++++++ src/it/projects/MJAVADOC-618_modular-war/pom.xml | 68 ++++++++++++++++++++++ .../MJAVADOC-618_modular-war/verify.groovy | 21 +++++++ .../maven/plugins/javadoc/AbstractJavadocMojo.java | 49 ++++++++++++---- 11 files changed, 375 insertions(+), 12 deletions(-) diff --git a/src/it/projects/MJAVADOC-618_modular-war/app/pom.xml b/src/it/projects/MJAVADOC-618_modular-war/app/pom.xml new file mode 100644 index 0000000..58e2798 --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/app/pom.xml @@ -0,0 +1,63 @@ +<?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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>example-root</artifactId> + <groupId>com.mycompany</groupId> + <version>2.0-SNAPSHOT</version> + </parent> + + <groupId>com.mycompany</groupId> + <artifactId>myproject</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>3.3.1</version> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>com.mycompany</groupId> + <artifactId>lib</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/com/mycompany/app/Application.java b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/com/mycompany/app/Application.java new file mode 100644 index 0000000..e7ef773 --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/com/mycompany/app/Application.java @@ -0,0 +1,27 @@ +package com.mycompany.app; + +/* + * 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 com.mycompany.lib.Library; + +public class Application +{ + private Library library = new Library(); +} diff --git a/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/module-info.java b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/module-info.java new file mode 100644 index 0000000..0267725 --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/module-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +module com.mycompany.app +{ + requires com.mycompany.lib; +} \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-618_modular-war/app/src/main/webapp/WEB-INF/web.xml b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..ba5f22e --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,26 @@ +<?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. + --> + +<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_1.xsd" + version="3.1"> + + <display-name>myproject</display-name> +</web-app> diff --git a/src/it/projects/MJAVADOC-618_modular-war/invoker.properties b/src/it/projects/MJAVADOC-618_modular-war/invoker.properties new file mode 100644 index 0000000..a087705 --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/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.java.version = 11+ +invoker.goals = package javadoc:aggregate-jar diff --git a/src/it/projects/MJAVADOC-618_modular-war/lib/pom.xml b/src/it/projects/MJAVADOC-618_modular-war/lib/pom.xml new file mode 100644 index 0000000..1700d8c --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/lib/pom.xml @@ -0,0 +1,45 @@ +<?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 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.mycompany</groupId> + <artifactId>example-root</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + <artifactId>lib</artifactId> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.1.2</version> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/com/mycompany/lib/Library.java b/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/com/mycompany/lib/Library.java new file mode 100644 index 0000000..dcb8801 --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/com/mycompany/lib/Library.java @@ -0,0 +1,24 @@ +package com.mycompany.lib; + +/* + * 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 Library +{ +} diff --git a/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/module-info.java b/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/module-info.java new file mode 100644 index 0000000..3c6c193 --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/module-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +module com.mycompany.lib +{ + exports com.mycompany.lib; +} \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-618_modular-war/pom.xml b/src/it/projects/MJAVADOC-618_modular-war/pom.xml new file mode 100644 index 0000000..a8f2bac --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/pom.xml @@ -0,0 +1,68 @@ +<?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>com.mycompany</groupId> + <artifactId>example-root</artifactId> + <version>2.0-SNAPSHOT</version> + <packaging>pom</packaging> + <name>example-root</name> + + <modules> + <module>lib</module> + <module>app</module> + </modules> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + <configuration> + <source>11</source> + <target>11</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <quiet>true</quiet> + </configuration> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> diff --git a/src/it/projects/MJAVADOC-618_modular-war/verify.groovy b/src/it/projects/MJAVADOC-618_modular-war/verify.groovy new file mode 100644 index 0000000..7791c69 --- /dev/null +++ b/src/it/projects/MJAVADOC-618_modular-war/verify.groovy @@ -0,0 +1,21 @@ +/* + * 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/apidocs/com.mycompany.lib/com/mycompany/lib/Library.html').exists() +assert new File( basedir, 'target/apidocs/com.mycompany.app/com/mycompany/app/Application.html').exists() 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 41d3b2c..9bde4e8 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -1891,21 +1891,46 @@ public abstract class AbstractJavadocMojo return Collections.singletonList( new File( p.getBuild().getOutputDirectory() ) ); } - protected File getArtifactFile( MavenProject project ) + /** + * Either returns the attached artifact file or outputDirectory + * + * @param project + * @return + */ + protected File getClassesFile( MavenProject project ) { if ( !isAggregator() && isTest() ) { return null; } - else if ( project.getArtifact() != null && project.getArtifact().getFile() != null ) + + if ( project.getArtifact() != null && project.getArtifact().getFile() != null ) { - return project.getArtifact().getFile(); + File artifactFile = project.getArtifact().getFile(); + if ( artifactFile.isDirectory() || artifactFile.getName().endsWith( ".jar" ) ) + { + return artifactFile; + } } - else if ( project.getExecutionProject() != null && project.getExecutionProject().getArtifact() != null ) + else if ( project.getExecutionProject() != null + && project.getExecutionProject().getArtifact() != null + && project.getExecutionProject().getArtifact().getFile() != null ) { - return project.getExecutionProject().getArtifact().getFile(); + File artifactFile = project.getExecutionProject().getArtifact().getFile(); + if ( artifactFile.isDirectory() || artifactFile.getName().endsWith( ".jar" ) ) + { + return artifactFile; + } + } + + if ( project.getBuild().getOutputDirectory() != null ) + { + return new File( project.getBuild().getOutputDirectory() ); + } + else + { + return null; } - return null; } /** @@ -2401,7 +2426,7 @@ public abstract class AbstractJavadocMojo { mappedSourcePaths.add( new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ), - getArtifactFile( project ), + getClassesFile( project ), sourcePaths ) ); } } @@ -2446,7 +2471,7 @@ public abstract class AbstractJavadocMojo mappedSourcePaths.add( new JavadocModule( ArtifactUtils.versionlessKey( subProject.getGroupId(), subProject.getArtifactId() ), - getArtifactFile( subProject ), + getClassesFile( subProject ), additionalSourcePaths ) ); } } @@ -2474,7 +2499,7 @@ public abstract class AbstractJavadocMojo { mappedSourcePaths.add( new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ), - getArtifactFile( project ), + getClassesFile( project ), sourcePaths ) ); } } @@ -2811,7 +2836,7 @@ public abstract class AbstractJavadocMojo { if ( subProject != project ) { - File projectArtifactFile = getArtifactFile( subProject ); + File projectArtifactFile = getClassesFile( subProject ); if ( projectArtifactFile != null ) { classpathElements.add( projectArtifactFile ); @@ -5189,7 +5214,7 @@ public abstract class AbstractJavadocMojo ResolvePathResult result = null; // Prefer jar over outputDirectory, since it may may contain an automatic module name - File artifactFile = getArtifactFile( aggregatedProject ); + File artifactFile = getClassesFile( aggregatedProject ); if ( artifactFile != null ) { ResolvePathRequest<File> request = ResolvePathRequest.ofFile( artifactFile ); @@ -5314,7 +5339,7 @@ public abstract class AbstractJavadocMojo || ModuleNameSource.MANIFEST.equals( mainModuleNameSource ) ) ) { List<File> pathElements = new ArrayList<>( getPathElements() ); - File artifactFile = getArtifactFile( project ); + File artifactFile = getClassesFile( project ); if ( artifactFile != null ) { pathElements.add( 0, artifactFile );
