Skip to content

Commit

Permalink
[MJAVADOC-568] javadoc:jar fails when project has Automatic-Module-Na…
Browse files Browse the repository at this point in the history
…me and (implicit) uses offlinelinks with element-list

Reduce change of split packages
  • Loading branch information
rfscholte committed Feb 15, 2019
1 parent bb50d3e commit f09e0c8
Show file tree
Hide file tree
Showing 11 changed files with 327 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -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 = 9+
invoker.goals = package
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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>

<parent>
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc568</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>java-module</artifactId>

</project>
Original file line number Diff line number Diff line change
@@ -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 normal {
exports normal to mojo;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package normal;

/*
* 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.
*/

/**
* This is a comment.
*/
public class Testcase
{
}
66 changes: 66 additions & 0 deletions src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?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>
<parent>
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc568</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>mojo</artifactId>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>mojo</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>java-module</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package mojo;

/*
* 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 normal.Testcase;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;

/**
* This is also a comment.
*/
@Mojo(name = "my-mojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class TestcaseMojo extends AbstractMojo
{
public Testcase createTestcase()
{
return null;
}

@Override
public void execute()
{
}
}
76 changes: 76 additions & 0 deletions src/it/projects/MJAVADOC-568_manifest-splitpackage/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?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>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc568</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>9</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>@project.version@</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modules>
<module>java-module</module>
<module>mojo</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2243,10 +2243,10 @@ protected Map<Path, Collection<String>> getFiles( Collection<Path> sourcePaths )
}

/**
* Method to get the source paths. If no source path is specified in the parameter, the compile source roots
* of the project will be used.
* Method to get the source paths per reactorProject. If no source path is specified in the parameter, the compile
* source roots of the project will be used.
*
* @return a Collection of the project absolute source paths as <code>String</code>
* @return a Map of the project absolute source paths per projects key (G:A)
* @throws MavenReportException {@link MavenReportException}
* @see JavadocUtil#pruneDirs(MavenProject, Collection)
*/
Expand Down Expand Up @@ -2657,10 +2657,10 @@ private static List<String> trimValues( List<String> items )
* @return all classpath elements
* @throws MavenReportException if any.
*/
private List<File> getPathElements()
private Collection<File> getPathElements()
throws MavenReportException
{
List<File> classpathElements = new ArrayList<>();
Set<File> classpathElements = new LinkedHashSet<>();
Map<String, Artifact> compileArtifactMap = new LinkedHashMap<>();

if ( isTest() )
Expand All @@ -2669,7 +2669,6 @@ private List<File> getPathElements()
}

populateCompileArtifactMap( compileArtifactMap, project.getArtifacts() );


if ( isAggregator() )
{
Expand Down Expand Up @@ -5075,11 +5074,19 @@ private void addJavadocOptions( File javadocOutputDirectory,

if ( supportModulePath
&& ( isAggregator() || ( mainResolvePathResult != null
&& ModuleNameSource.MODULEDESCRIPTOR.equals( mainResolvePathResult.getModuleNameSource() ) ) )
&& ( ModuleNameSource.MODULEDESCRIPTOR.equals( mainResolvePathResult.getModuleNameSource() )
|| ModuleNameSource.MANIFEST.equals( mainResolvePathResult.getModuleNameSource() ) ) ) )
&& !isTest() )
{
List<File> pathElements = new ArrayList<>( getPathElements() );
File artifactFile = getArtifactFile( project );
if ( artifactFile != null )
{
pathElements.add( 0, artifactFile );
}

ResolvePathsRequest<File> request =
ResolvePathsRequest.ofFiles( getPathElements() );
ResolvePathsRequest.ofFiles( pathElements );

if ( mainResolvePathResult != null )
{
Expand All @@ -5093,12 +5100,18 @@ private void addJavadocOptions( File javadocOutputDirectory,
ResolvePathsResult<File> result = locationManager.resolvePaths( request );

Set<File> modulePathElements = new HashSet<>( result.getModulepathElements().keySet() ) ;
modulePathElements.addAll( getProjectBuildOutputDirs( getProject() ) );

Set<File> directDependencyArtifactFiles = new HashSet<>( project.getDependencyArtifacts().size() );
for ( Artifact depArt : project.getDependencyArtifacts() )
{
directDependencyArtifactFiles.add( depArt.getFile() );
}

Collection<File> classPathElements = new ArrayList<>( result.getClasspathElements().size() );
for ( File file : result.getClasspathElements() )
{
if ( file.isDirectory() && new File( file, "module-info.class" ).exists() )
if ( directDependencyArtifactFiles.contains( file )
|| ( file.isDirectory() && new File( file, "module-info.class" ).exists() ) )
{
modulePathElements.add( file );
}
Expand All @@ -5122,14 +5135,6 @@ private void addJavadocOptions( File javadocOutputDirectory,
throw new MavenReportException( e.getMessage(), e );
}
}
else if ( supportModulePath && ( mainResolvePathResult != null
&& ModuleNameSource.MANIFEST.equals( mainResolvePathResult.getModuleNameSource() ) ) && !isTest() )
{
List<File> modulePathFiles = new ArrayList<>( getPathElements() );
modulePathFiles.add( project.getArtifact().getFile() );
String modulepath = StringUtils.join( modulePathFiles.iterator(), File.pathSeparator );
addArgIfNotEmpty( arguments, "--module-path", JavadocUtil.quotedPathArgument( modulepath ) , false, false );
}
else if ( supportModulePath && moduleDescriptorSource && !isTest() )
{
String modulepath = StringUtils.join( getPathElements().iterator(), File.pathSeparator );
Expand Down

0 comments on commit f09e0c8

Please sign in to comment.