You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/02/24 09:59:26 UTC
[maven-javadoc-plugin] 01/01: [MJAVADOC-338] When
includeDependencySources=true the javadoc plugin should not download the
internet every time it is run
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MJAVADOC-338
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit 24cc38b378463487d243097d02ab242750c76c01
Author: rfscholte <rf...@apache.org>
AuthorDate: Sun Feb 24 10:59:19 2019 +0100
[MJAVADOC-338] When includeDependencySources=true the javadoc plugin should not download the internet every time it is run
---
src/it/mrm/repository/mjavadoc338-direct.pom | 35 ++++++++++
src/it/mrm/repository/mjavadoc338-transitive.pom | 27 ++++++++
src/it/mrm/settings.xml | 9 +++
.../invoker.properties | 19 +++++
.../pom.xml | 40 ++++-------
.../src/main/java/foo/Bar.java | 22 ++++++
.../MJAVADOC-338_downloadSources/verify.groovy | 26 +++++++
.../module1/pom.xml | 2 +-
.../MJAVADOC-514_3rdparty-doclettags/pom.xml | 2 +-
.../maven/plugins/javadoc/AbstractJavadocMojo.java | 80 +++++++++++-----------
10 files changed, 193 insertions(+), 69 deletions(-)
diff --git a/src/it/mrm/repository/mjavadoc338-direct.pom b/src/it/mrm/repository/mjavadoc338-direct.pom
new file mode 100644
index 0000000..811e24b
--- /dev/null
+++ b/src/it/mrm/repository/mjavadoc338-direct.pom
@@ -0,0 +1,35 @@
+<?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.its</groupId>
+ <artifactId>mjavadoc338-direct</artifactId>
+ <version>1.0</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugins.javadoc.its</groupId>
+ <artifactId>mjavadoc338-transitive</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/src/it/mrm/repository/mjavadoc338-transitive.pom b/src/it/mrm/repository/mjavadoc338-transitive.pom
new file mode 100644
index 0000000..e376ca5
--- /dev/null
+++ b/src/it/mrm/repository/mjavadoc338-transitive.pom
@@ -0,0 +1,27 @@
+<?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.its</groupId>
+ <artifactId>mjavadoc338-transitive</artifactId>
+ <version>1.0</version>
+
+</project>
diff --git a/src/it/mrm/settings.xml b/src/it/mrm/settings.xml
index b9a75c2..9b3cc33 100644
--- a/src/it/mrm/settings.xml
+++ b/src/it/mrm/settings.xml
@@ -20,6 +20,15 @@ under the License.
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+ <mirrors>
+ <mirror>
+ <id>mrm-maven-plugin</id>
+ <name>Mock Repository Manager</name>
+ <url>@mrm.repository.url@</url>
+ <mirrorOf>*,!repo494,!repo514</mirrorOf>
+ </mirror>
+ </mirrors>
+
<profiles>
<profile>
<id>it-repo</id>
diff --git a/src/it/projects/MJAVADOC-338_downloadSources/invoker.properties b/src/it/projects/MJAVADOC-338_downloadSources/invoker.properties
new file mode 100644
index 0000000..e10618d
--- /dev/null
+++ b/src/it/projects/MJAVADOC-338_downloadSources/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.debug = false
+invoker.goals.1 = javadoc:javadoc
+invoker.goals.2 = javadoc:javadoc
diff --git a/src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml b/src/it/projects/MJAVADOC-338_downloadSources/pom.xml
similarity index 64%
copy from src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml
copy to src/it/projects/MJAVADOC-338_downloadSources/pom.xml
index 65bacad..6e1bb87 100644
--- a/src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml
+++ b/src/it/projects/MJAVADOC-338_downloadSources/pom.xml
@@ -22,29 +22,14 @@
<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.maven-javadoc-plugin.it</groupId>
- <artifactId>mjavadoc-514</artifactId>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc338</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
-
- <url>https://issues.apache.org/jira/browse/MJAVADOC-514</url>
- <repositories>
- <repository>
- <id>local.private</id>
- <url>@mrm.3rdparty.url@</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
<build>
<pluginManagement>
<plugins>
@@ -53,19 +38,20 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>@project.version@</version>
<configuration>
- <useStandardDocletOptions>false</useStandardDocletOptions>
- <docletArtifacts>
- <artifact>
- <groupId>org.apache.maven.plugins.javadoc.its</groupId>
- <artifactId>doclet</artifactId>
- <version>1.0</version>
- </artifact>
- </docletArtifacts>
- <doclet>org.apache.maven.plugins.javadoc.its.Doclet</doclet>
+ <includeDependencySources>true</includeDependencySources>
+ <doclint>none</doclint>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
-
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugins.javadoc.its</groupId>
+ <artifactId>mjavadoc338-direct</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+
</project>
diff --git a/src/it/projects/MJAVADOC-338_downloadSources/src/main/java/foo/Bar.java b/src/it/projects/MJAVADOC-338_downloadSources/src/main/java/foo/Bar.java
new file mode 100644
index 0000000..32d2c4f
--- /dev/null
+++ b/src/it/projects/MJAVADOC-338_downloadSources/src/main/java/foo/Bar.java
@@ -0,0 +1,22 @@
+package foo;
+
+/*
+ * 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 Bar {}
diff --git a/src/it/projects/MJAVADOC-338_downloadSources/verify.groovy b/src/it/projects/MJAVADOC-338_downloadSources/verify.groovy
new file mode 100644
index 0000000..2e540ae
--- /dev/null
+++ b/src/it/projects/MJAVADOC-338_downloadSources/verify.groovy
@@ -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.
+ */
+ // NOOO never from central
+
+def buildLog = new File(basedir,'build.log')
+assert 1 == buildLog.readLines().count{it ==~ /\[INFO\] Downloading from mrm-maven-plugin\: .+\/mjavadoc338-direct-1\.0-sources\.jar/}
+assert 1 == buildLog.readLines().count{it ==~ /\[INFO\] Downloading from mrm-maven-plugin\: .+\/mjavadoc338-direct-1\.0-javadoc-resources\.jar/}
+
+assert !buildLog.readLines().any{it ==~ /\[INFO\] Downloading from .+\/mjavadoc338-transitive-1\.0-sources\.jar/}
+assert !buildLog.readLines().any{it ==~ /\[INFO\] Downloading from .+\/mjavadoc338-transitive-1\.0-javadoc-resources\.jar/}
diff --git a/src/it/projects/MJAVADOC-494_aggregate-repositories/module1/pom.xml b/src/it/projects/MJAVADOC-494_aggregate-repositories/module1/pom.xml
index 26f4cf2..00dad30 100644
--- a/src/it/projects/MJAVADOC-494_aggregate-repositories/module1/pom.xml
+++ b/src/it/projects/MJAVADOC-494_aggregate-repositories/module1/pom.xml
@@ -24,7 +24,7 @@
<repositories>
<repository>
- <id>local.private</id>
+ <id>repo494</id>
<url>@mrm.3rdparty.url@</url>
<releases>
<enabled>true</enabled>
diff --git a/src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml b/src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml
index 65bacad..57346d0 100644
--- a/src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml
+++ b/src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml
@@ -34,7 +34,7 @@
<repositories>
<repository>
- <id>local.private</id>
+ <id>repo514</id>
<url>@mrm.3rdparty.url@</url>
<releases>
<enabled>true</enabled>
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 1ba1535..fc51609 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -2442,32 +2442,6 @@ public abstract class AbstractJavadocMojo
final SourceResolverConfig config = getDependencySourceResolverConfig();
- final List<TransformableFilter> andFilters = new ArrayList<>();
-
- final List<String> dependencyIncludes = dependencySourceIncludes;
- final List<String> dependencyExcludes = dependencySourceExcludes;
-
- if ( !includeTransitiveDependencySources || isNotEmpty( dependencyIncludes ) || isNotEmpty(
- dependencyExcludes ) )
- {
- if ( !includeTransitiveDependencySources )
- {
- andFilters.add( createDependencyArtifactFilter() );
- }
-
- if ( isNotEmpty( dependencyIncludes ) )
- {
- andFilters.add( new PatternInclusionsFilter( dependencyIncludes ) );
- }
-
- if ( isNotEmpty( dependencyExcludes ) )
- {
- andFilters.add( new PatternExclusionsFilter( dependencyExcludes ) );
- }
-
- config.withFilter( new AndFilter( andFilters ) );
- }
-
try
{
return resourceResolver.resolveDependencySourcePaths( config );
@@ -2506,9 +2480,41 @@ public abstract class AbstractJavadocMojo
*/
private SourceResolverConfig getDependencySourceResolverConfig()
{
- return configureDependencySourceResolution(
- new SourceResolverConfig( project, session.getProjectBuildingRequest(),
- sourceDependencyCacheDir ).withReactorProjects( reactorProjects ) );
+ final List<TransformableFilter> andFilters = new ArrayList<>();
+
+ final List<String> dependencyIncludes = dependencySourceIncludes;
+ final List<String> dependencyExcludes = dependencySourceExcludes;
+
+ if ( !includeTransitiveDependencySources || isNotEmpty( dependencyIncludes ) || isNotEmpty(
+ dependencyExcludes ) )
+ {
+ if ( !includeTransitiveDependencySources )
+ {
+ andFilters.add( createDependencyArtifactFilter() );
+ }
+
+ if ( isNotEmpty( dependencyIncludes ) )
+ {
+ andFilters.add( new PatternInclusionsFilter( dependencyIncludes ) );
+ }
+
+ if ( isNotEmpty( dependencyExcludes ) )
+ {
+ andFilters.add( new PatternExclusionsFilter( dependencyExcludes ) );
+ }
+ }
+
+ return configureDependencySourceResolution( new SourceResolverConfig( project,
+ getProjectBuildingRequest( project ),
+ sourceDependencyCacheDir ).withReactorProjects( reactorProjects ) )
+ .withFilter( new AndFilter( andFilters ) );
+
+ }
+
+ private ProjectBuildingRequest getProjectBuildingRequest( MavenProject currentProject )
+ {
+ return new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() )
+ .setRemoteRepositories( currentProject.getRemoteArtifactRepositories() );
}
/**
@@ -2707,9 +2713,7 @@ public abstract class AbstractJavadocMojo
sb.append( subProject.getArtifactId() ).append( ":" );
sb.append( subProject.getVersion() ).append( '\n' );
- ProjectBuildingRequest buildingRequest = session.getProjectBuildingRequest();
- buildingRequest =
- buildingRequest.setRemoteRepositories( subProject.getRemoteArtifactRepositories() );
+ ProjectBuildingRequest buildingRequest = getProjectBuildingRequest( subProject );
List<Dependency> managedDependencies = null;
if ( subProject.getDependencyManagement() != null )
@@ -2783,7 +2787,7 @@ public abstract class AbstractJavadocMojo
try
{
- return artifactResolver.resolveArtifact( session.getProjectBuildingRequest(), coordinate ).getArtifact();
+ return artifactResolver.resolveArtifact( getProjectBuildingRequest( project ), coordinate ).getArtifact();
}
catch ( ArtifactResolverException e )
{
@@ -3573,7 +3577,7 @@ public abstract class AbstractJavadocMojo
coordinate.setVersion( javadocArtifact.getVersion() );
Iterable<ArtifactResult> deps =
- dependencyResolver.resolveDependencies( session.getProjectBuildingRequest(), coordinate,
+ dependencyResolver.resolveDependencies( getProjectBuildingRequest( project ), coordinate,
ScopeFilter.including( "compile", "provided" ) );
for ( ArtifactResult a : deps )
{
@@ -3607,11 +3611,7 @@ public abstract class AbstractJavadocMojo
coordinate.setArtifactId( javadocArtifact.getArtifactId() );
coordinate.setVersion( javadocArtifact.getVersion() );
- DefaultProjectBuildingRequest buildingRequest =
- new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
- buildingRequest.setRemoteRepositories( project.getRemoteArtifactRepositories() );
-
- return artifactResolver.resolveArtifact( buildingRequest, coordinate ).getArtifact();
+ return artifactResolver.resolveArtifact( getProjectBuildingRequest( project ), coordinate ).getArtifact();
}
/**
@@ -6142,7 +6142,7 @@ public abstract class AbstractJavadocMojo
try
{
MavenProject artifactProject =
- mavenProjectBuilder.build( artifact, session.getProjectBuildingRequest() ).getProject();
+ mavenProjectBuilder.build( artifact, getProjectBuildingRequest( project ) ).getProject();
if ( StringUtils.isNotEmpty( artifactProject.getUrl() ) )
{