From 89316c9d47909a5ab1d6a97c056598a63eb2a667 Mon Sep 17 00:00:00 2001 From: Henning Schmiedehausen Date: Sun, 20 Aug 2023 13:08:05 -0700 Subject: [PATCH] [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. --- src/it/projects/MJAVADOC-767/doc/pom.xml | 69 +++++++++++++++++++ .../projects/MJAVADOC-767/invoker.properties | 19 +++++ src/it/projects/MJAVADOC-767/pom.xml | 36 ++++++++++ src/it/projects/MJAVADOC-767/thing1/pom.xml | 26 +++++++ .../src/main/java/jdbug/thing1/Main.java | 26 +++++++ .../thing1/src/main/java/module-info.java | 22 ++++++ src/it/projects/MJAVADOC-767/thing2/pom.xml | 26 +++++++ .../src/main/java/jdbug/thing2/Main.java | 26 +++++++ .../thing2/src/main/java/module-info.java | 22 ++++++ .../plugins/javadoc/AbstractJavadocMojo.java | 14 ++-- 10 files changed, 280 insertions(+), 6 deletions(-) create mode 100644 src/it/projects/MJAVADOC-767/doc/pom.xml create mode 100644 src/it/projects/MJAVADOC-767/invoker.properties create mode 100644 src/it/projects/MJAVADOC-767/pom.xml create mode 100644 src/it/projects/MJAVADOC-767/thing1/pom.xml create mode 100644 src/it/projects/MJAVADOC-767/thing1/src/main/java/jdbug/thing1/Main.java create mode 100644 src/it/projects/MJAVADOC-767/thing1/src/main/java/module-info.java create mode 100644 src/it/projects/MJAVADOC-767/thing2/pom.xml create mode 100644 src/it/projects/MJAVADOC-767/thing2/src/main/java/jdbug/thing2/Main.java create mode 100644 src/it/projects/MJAVADOC-767/thing2/src/main/java/module-info.java 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 00000000..e9bc5d68 --- /dev/null +++ b/src/it/projects/MJAVADOC-767/doc/pom.xml @@ -0,0 +1,69 @@ + + + + 4.0.0 + + + org.apache.maven.plugins.javadoc.it + mjavadoc767 + 1.0-SNAPSHOT + + + doc + pom + + + + org.apache.maven.plugins.javadoc.it + thing1 + 1.0-SNAPSHOT + + + org.apache.maven.plugins.javadoc.it + thing2 + 1.0-SNAPSHOT + + + + + + + maven-javadoc-plugin + @project.version@ + + + javadoc-jar + + aggregate-jar + + package + + 9 + false + true + false + + *:* + + + *:thing2 + + + + + + + + diff --git a/src/it/projects/MJAVADOC-767/invoker.properties b/src/it/projects/MJAVADOC-767/invoker.properties new file mode 100644 index 00000000..c30bd85d --- /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 00000000..d17cb7eb --- /dev/null +++ b/src/it/projects/MJAVADOC-767/pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + + org.apache.maven.plugins.javadoc.it + mjavadoc767 + 1.0-SNAPSHOT + pom + + https://issues.apache.org/jira/browse/MJAVADOC-767 + + + UTF-8 + 9 + 9 + + + + thing1 + thing2 + doc + + 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 00000000..7a310fa5 --- /dev/null +++ b/src/it/projects/MJAVADOC-767/thing1/pom.xml @@ -0,0 +1,26 @@ + + + + 4.0.0 + + + org.apache.maven.plugins.javadoc.it + mjavadoc767 + 1.0-SNAPSHOT + + + thing1 + jar + 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 00000000..8d6618fd --- /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 00000000..b880104c --- /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 00000000..6b0a9320 --- /dev/null +++ b/src/it/projects/MJAVADOC-767/thing2/pom.xml @@ -0,0 +1,26 @@ + + + + 4.0.0 + + + org.apache.maven.plugins.javadoc.it + mjavadoc767 + 1.0-SNAPSHOT + + + thing2 + jar + 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 00000000..9aef86fc --- /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 00000000..28ce9ed2 --- /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 a2ba79fd..18fea1cc 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 @@ private void addJavadocOptions( } for (Entry> 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()) {