[MJAVADOC-767] javadoc creates invalid --patch-module statements (#225)
Fixes empty --patch-module command line entries
When using an exclude filter, it is possible that the plugin creates
javadoc --patch-module command line options, that do not actually have
a value.
This changes skips such empty entries.
diff --git a/src/it/projects/MJAVADOC-767/doc/pom.xml b/src/it/projects/MJAVADOC-767/doc/pom.xml
new file mode 100644
index 0000000..e9bc5d6
--- /dev/null
+++ b/src/it/projects/MJAVADOC-767/doc/pom.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc767</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>doc</artifactId>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>thing1</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>thing2</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>javadoc-jar</id>
+ <goals>
+ <goal>aggregate-jar</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <jvmVersion>9</jvmVersion>
+ <skip>false</skip>
+ <includeDependencySources>true</includeDependencySources>
+ <detectOfflineLinks>false</detectOfflineLinks>
+ <dependencySourceIncludes>
+ <dependencySourceInclude>*:*</dependencySourceInclude>
+ </dependencySourceIncludes>
+ <dependencySourceExcludes>
+ <dependencySourceExclude>*:thing2</dependencySourceExclude>
+ </dependencySourceExcludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/projects/MJAVADOC-767/invoker.properties b/src/it/projects/MJAVADOC-767/invoker.properties
new file mode 100644
index 0000000..c30bd85
--- /dev/null
+++ b/src/it/projects/MJAVADOC-767/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= package
+invoker.java.version = 9+
diff --git a/src/it/projects/MJAVADOC-767/pom.xml b/src/it/projects/MJAVADOC-767/pom.xml
new file mode 100644
index 0000000..d17cb7e
--- /dev/null
+++ b/src/it/projects/MJAVADOC-767/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc767</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <url>https://issues.apache.org/jira/browse/MJAVADOC-767</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>9</maven.compiler.source>
+ <maven.compiler.target>9</maven.compiler.target>
+ </properties>
+
+ <modules>
+ <module>thing1</module>
+ <module>thing2</module>
+ <module>doc</module>
+ </modules>
+</project>
diff --git a/src/it/projects/MJAVADOC-767/thing1/pom.xml b/src/it/projects/MJAVADOC-767/thing1/pom.xml
new file mode 100644
index 0000000..7a310fa
--- /dev/null
+++ b/src/it/projects/MJAVADOC-767/thing1/pom.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc767</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>thing1</artifactId>
+ <packaging>jar</packaging>
+</project>
diff --git a/src/it/projects/MJAVADOC-767/thing1/src/main/java/jdbug/thing1/Main.java b/src/it/projects/MJAVADOC-767/thing1/src/main/java/jdbug/thing1/Main.java
new file mode 100644
index 0000000..8d6618f
--- /dev/null
+++ b/src/it/projects/MJAVADOC-767/thing1/src/main/java/jdbug/thing1/Main.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package jdbug.thing1;
+
+public final class Main {
+ public static final void main(String ... args) throws Exception {
+ System.out.println("Hello, World!");
+ }
+}
diff --git a/src/it/projects/MJAVADOC-767/thing1/src/main/java/module-info.java b/src/it/projects/MJAVADOC-767/thing1/src/main/java/module-info.java
new file mode 100644
index 0000000..b880104
--- /dev/null
+++ b/src/it/projects/MJAVADOC-767/thing1/src/main/java/module-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 jdbug.thing1 {
+ exports jdbug.thing1;
+}
diff --git a/src/it/projects/MJAVADOC-767/thing2/pom.xml b/src/it/projects/MJAVADOC-767/thing2/pom.xml
new file mode 100644
index 0000000..6b0a932
--- /dev/null
+++ b/src/it/projects/MJAVADOC-767/thing2/pom.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc767</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>thing2</artifactId>
+ <packaging>jar</packaging>
+</project>
diff --git a/src/it/projects/MJAVADOC-767/thing2/src/main/java/jdbug/thing2/Main.java b/src/it/projects/MJAVADOC-767/thing2/src/main/java/jdbug/thing2/Main.java
new file mode 100644
index 0000000..9aef86f
--- /dev/null
+++ b/src/it/projects/MJAVADOC-767/thing2/src/main/java/jdbug/thing2/Main.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package jdbug.thing2;
+
+public final class Main {
+ public static final void main(String ... args) throws Exception {
+ System.out.println("Hello, World!");
+ }
+}
diff --git a/src/it/projects/MJAVADOC-767/thing2/src/main/java/module-info.java b/src/it/projects/MJAVADOC-767/thing2/src/main/java/module-info.java
new file mode 100644
index 0000000..28ce9ed
--- /dev/null
+++ b/src/it/projects/MJAVADOC-767/thing2/src/main/java/module-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 jdbug.thing2 {
+ exports jdbug.thing2;
+}
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 a2ba79f..18fea1c 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -4594,12 +4594,14 @@
}
for (Entry<String, Collection<Path>> entry : patchModules.entrySet()) {
- addArgIfNotEmpty(
- arguments,
- "--patch-module",
- entry.getKey() + '=' + JavadocUtil.quotedPathArgument(getSourcePath(entry.getValue())),
- false,
- false);
+ if (!entry.getValue().isEmpty()) {
+ addArgIfNotEmpty(
+ arguments,
+ "--patch-module",
+ entry.getKey() + '=' + JavadocUtil.quotedPathArgument(getSourcePath(entry.getValue())),
+ false,
+ false);
+ }
}
if (doclet != null && !doclet.isEmpty()) {