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 2018/12/01 11:48:20 UTC

[maven-javadoc-plugin] branch master updated: [MJAVADOC-514] Maven Javadoc Plugin can't get dependency from third party maven repository

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new dee1993  [MJAVADOC-514] Maven Javadoc Plugin can't get dependency from third party maven repository
dee1993 is described below

commit dee19932870bf9284b07b1dd68bfc2e743725d10
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Dec 1 12:21:50 2018 +0100

    [MJAVADOC-514] Maven Javadoc Plugin can't get dependency from third party maven repository
---
 .../apache/maven/plugins/javadoc/its/Doclet.class  | Bin 0 -> 673 bytes
 src/it/mrm/3rdparty/doclet-1.0.pom                 |  27 ++++++++
 .../invoker.properties                             |  18 ++++++
 .../MJAVADOC-514_3rdparty-doclettags/pom.xml       |  71 +++++++++++++++++++++
 .../src/main/java/foo/bar/ALotOfLinkTags.java      |  29 +++++++++
 .../maven/plugins/javadoc/AbstractJavadocMojo.java |  13 +++-
 6 files changed, 155 insertions(+), 3 deletions(-)

diff --git a/src/it/mrm/3rdparty/doclet-1.0.jar/org/apache/maven/plugins/javadoc/its/Doclet.class b/src/it/mrm/3rdparty/doclet-1.0.jar/org/apache/maven/plugins/javadoc/its/Doclet.class
new file mode 100644
index 0000000..66711f7
Binary files /dev/null and b/src/it/mrm/3rdparty/doclet-1.0.jar/org/apache/maven/plugins/javadoc/its/Doclet.class differ
diff --git a/src/it/mrm/3rdparty/doclet-1.0.pom b/src/it/mrm/3rdparty/doclet-1.0.pom
new file mode 100644
index 0000000..476c7a9
--- /dev/null
+++ b/src/it/mrm/3rdparty/doclet-1.0.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>doclet</artifactId>
+  <version>1.0</version>
+    
+</project>
diff --git a/src/it/projects/MJAVADOC-514_3rdparty-doclettags/invoker.properties b/src/it/projects/MJAVADOC-514_3rdparty-doclettags/invoker.properties
new file mode 100644
index 0000000..22c9049
--- /dev/null
+++ b/src/it/projects/MJAVADOC-514_3rdparty-doclettags/invoker.properties
@@ -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.goals=clean javadoc:javadoc
diff --git a/src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml b/src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml
new file mode 100644
index 0000000..65bacad
--- /dev/null
+++ b/src/it/projects/MJAVADOC-514_3rdparty-doclettags/pom.xml
@@ -0,0 +1,71 @@
+<?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.maven-javadoc-plugin.it</groupId>
+  <artifactId>mjavadoc-514</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>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <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>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+</project>
diff --git a/src/it/projects/MJAVADOC-514_3rdparty-doclettags/src/main/java/foo/bar/ALotOfLinkTags.java b/src/it/projects/MJAVADOC-514_3rdparty-doclettags/src/main/java/foo/bar/ALotOfLinkTags.java
new file mode 100644
index 0000000..16954e8
--- /dev/null
+++ b/src/it/projects/MJAVADOC-514_3rdparty-doclettags/src/main/java/foo/bar/ALotOfLinkTags.java
@@ -0,0 +1,29 @@
+package foo.bar;
+
+/*
+ * 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.
+ */
+
+/**
+ * 
+ * @author Robert Scholte
+ * @since 3.0.2
+ */
+public class ALotOfLinkTags
+{
+}
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 4173940..7a506ba 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -53,6 +53,7 @@ import org.apache.maven.plugins.javadoc.options.io.xpp3.JavadocOptionsXpp3Writer
 import org.apache.maven.plugins.javadoc.resolver.JavadocBundle;
 import org.apache.maven.plugins.javadoc.resolver.ResourceResolver;
 import org.apache.maven.plugins.javadoc.resolver.SourceResolverConfig;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
@@ -109,6 +110,7 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
@@ -3485,7 +3487,7 @@ public abstract class AbstractJavadocMojo
             coordinate.setGroupId( javadocArtifact.getGroupId() );
             coordinate.setArtifactId( javadocArtifact.getArtifactId() );
             coordinate.setVersion( javadocArtifact.getVersion() );
-
+            
             Iterable<ArtifactResult> deps =
                 dependencyResolver.resolveDependencies( session.getProjectBuildingRequest(), coordinate,
                                                         ScopeFilter.including( "compile", "provided" ) );
@@ -3521,7 +3523,11 @@ public abstract class AbstractJavadocMojo
         coordinate.setArtifactId( javadocArtifact.getArtifactId() );
         coordinate.setVersion( javadocArtifact.getVersion() );
 
-        return artifactResolver.resolveArtifact( session.getProjectBuildingRequest(), coordinate ).getArtifact();
+        DefaultProjectBuildingRequest buildingRequest =
+            new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
+        buildingRequest.setRemoteRepositories( project.getRemoteArtifactRepositories() );
+        
+        return artifactResolver.resolveArtifact( buildingRequest, coordinate ).getArtifact();
     }
 
     /**
@@ -5799,7 +5805,8 @@ public abstract class AbstractJavadocMojo
 
         try ( InputStream in = this.getClass().getResourceAsStream( resourceName ) )
         {
-            Files.copy( in, javaApiListFile );
+            // TODO only copy when changed
+            Files.copy( in, javaApiListFile, StandardCopyOption.REPLACE_EXISTING );
         }
         catch ( IOException ioe )
         {