Skip to content

Commit

Permalink
[MJAVADOC-767] javadoc creates invalid --patch-module statements (#225)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hgschmie committed Aug 20, 2023
1 parent 72c8ee5 commit 89316c9
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 6 deletions.
69 changes: 69 additions & 0 deletions 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>
19 changes: 19 additions & 0 deletions 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+
36 changes: 36 additions & 0 deletions 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>
26 changes: 26 additions & 0 deletions 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>
@@ -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!");
}
}
22 changes: 22 additions & 0 deletions 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;
}
26 changes: 26 additions & 0 deletions 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>
@@ -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!");
}
}
22 changes: 22 additions & 0 deletions 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;
}
Expand Up @@ -4594,12 +4594,14 @@ private void addJavadocOptions(
}

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()) {
Expand Down

0 comments on commit 89316c9

Please sign in to comment.