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 2020/01/18 15:11:29 UTC

[maven-javadoc-plugin] branch https updated: http to central not supported anymore, switch to https

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

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


The following commit(s) were added to refs/heads/https by this push:
     new 82d1f94  http to central not supported anymore, switch to https
82d1f94 is described below

commit 82d1f94579c055614f00be5351d3cc856cbe8fb6
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Jan 18 16:11:15 2020 +0100

    http to central not supported anymore, switch to https
---
 pom.xml                                            | 50 ++++++++++++++++------
 .../plugins/javadoc/AbstractFixJavadocMojo.java    | 13 +++++-
 .../maven/plugins/javadoc/AbstractJavadocMojo.java |  3 +-
 .../apache/maven/plugins/javadoc/JavadocUtil.java  |  4 +-
 .../maven/plugins/javadoc/FixJavadocMojoTest.java  | 13 ++++--
 src/test/resources/unit/settings.xml               | 30 +++++++++++++
 6 files changed, 95 insertions(+), 18 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4ac6f93..9dad6e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,7 +70,8 @@ under the License.
     <mavenVersion>3.0</mavenVersion>
     <doxiaVersion>1.7</doxiaVersion>
     <doxia-sitetoolsVersion>1.7.4</doxia-sitetoolsVersion>
-    <wagonVersion>1.0-beta-6</wagonVersion>
+    <wagonVersion>2.4</wagonVersion>
+    <sonatypeAetherVersion>1.13.1</sonatypeAetherVersion>
     <!-- for ITs -->
     <sitePluginVersion>3.3</sitePluginVersion>
     <projectInfoReportsPluginVersion>2.7</projectInfoReportsPluginVersion>
@@ -124,6 +125,36 @@ under the License.
     </contributor>
   </contributors>
 
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.sonatype.aether</groupId>
+        <artifactId>aether-api</artifactId>
+        <version>${sonatypeAetherVersion}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.sonatype.aether</groupId>
+        <artifactId>aether-connector</artifactId>
+        <version>${sonatypeAetherVersion}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.sonatype.aether</groupId>
+        <artifactId>aether-connector-wagon</artifactId>
+        <version>${sonatypeAetherVersion}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.sonatype.aether</groupId>
+        <artifactId>aether-impl</artifactId>
+        <version>${sonatypeAetherVersion}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.sonatype.aether</groupId>
+        <artifactId>aether-util</artifactId>
+        <version>${sonatypeAetherVersion}</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  
   <dependencies>
     <dependency> <!-- @TODO remove!! -->
       <groupId>org.apache.maven</groupId>
@@ -316,13 +347,13 @@ under the License.
     <dependency>
       <groupId>org.sonatype.aether</groupId>
       <artifactId>aether-connector-wagon</artifactId>
-      <version>1.7</version>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.wagon</groupId>
       <artifactId>wagon-http</artifactId>
-      <version>1.0-beta-6</version>
+      <version>${wagonVersion}</version>
+      <classifier>shaded</classifier>
       <scope>test</scope>
     </dependency>
   </dependencies>
@@ -394,15 +425,10 @@ under the License.
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
-          <systemProperties>
-            <property>
-              <name>maven.home</name>
-              <value>${maven.home}</value>
-            </property>
-          </systemProperties>
-          <environmentVariables>
-            <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED>
-          </environmentVariables>
+          <systemPropertyVariables>
+            <maven.home>${maven.home}</maven.home>
+            <https.protocols>${https.protocols}</https.protocols>
+          </systemPropertyVariables> 
         </configuration>
       </plugin>
       <plugin>
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
index 95e0863..fb18bf5 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java
@@ -43,6 +43,7 @@ import org.apache.commons.lang3.ClassUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -377,6 +378,9 @@ public abstract class AbstractFixJavadocMojo
     @Parameter( defaultValue = "${project}", readonly = true, required = true )
     private MavenProject project;
 
+    @Parameter ( defaultValue = "${session}", readonly = true, required = true )
+    private MavenSession session;
+
     /**
      * The current user system settings for use in Maven.
      */
@@ -483,6 +487,11 @@ public abstract class AbstractFixJavadocMojo
     // protected methods
     // ----------------------------------------------------------------------
 
+    protected final MavenProject getProject()
+    {
+        return project;
+    }    
+
     /**
      * @param p not null maven project.
      * @return the artifact type.
@@ -697,8 +706,10 @@ public abstract class AbstractFixJavadocMojo
         invokerDir.mkdirs();
         File invokerLogFile = FileUtils.createTempFile( "clirr-maven-plugin", ".txt", invokerDir );
         new File( project.getBuild().getDirectory(), "invoker-clirr-maven-plugin.txt" );
+
         JavadocUtil.invokeMaven( getLog(), new File( localRepository.getBasedir() ), project.getFile(),
-                                 Collections.singletonList( clirrGoal ), properties, invokerLogFile );
+                                 Collections.singletonList( clirrGoal ), properties, invokerLogFile,
+                                 session.getRequest().getGlobalSettingsFile() );
 
         try
         {
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 2b6a590..c043531 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -6186,7 +6186,8 @@ public abstract class AbstractJavadocMojo
                 try
                 {
                     JavadocUtil.invokeMaven( getLog(), new File( localRepository.getBasedir() ), p.getFile(),
-                                             Collections.singletonList( javadocGoal ), null, invokerLogFile );
+                                             Collections.singletonList( javadocGoal ), null, invokerLogFile,
+                                             session.getRequest().getGlobalSettingsFile() );
                 }
                 catch ( MavenInvocationException e )
                 {
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
index 997c5ed..eec7639 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -781,11 +781,12 @@ public class JavadocUtil
      * @param goals a not null goals list.
      * @param properties the properties for the goals, could be null.
      * @param invokerLog the log file where the invoker will be written, if null using <code>System.out</code>.
+     * @param globalSettingsFile reference to settings file, could be null.
      * @throws MavenInvocationException if any
      * @since 2.6
      */
     protected static void invokeMaven( Log log, File localRepositoryDir, File projectFile, List<String> goals,
-                                       Properties properties, File invokerLog )
+                                       Properties properties, File invokerLog, File globalSettingsFile )
         throws MavenInvocationException
     {
         if ( projectFile == null )
@@ -829,6 +830,7 @@ public class JavadocUtil
         InvocationRequest request = new DefaultInvocationRequest();
         request.setBaseDirectory( projectFile.getParentFile() );
         request.setPomFile( projectFile );
+        request.setGlobalSettingsFile( globalSettingsFile );
         request.setBatchMode( true );
         if ( log != null )
         {
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java b/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
index e4fc2be..1db9339 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
@@ -27,6 +27,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
@@ -614,9 +615,15 @@ public class FixJavadocMojoTest
 
         FixJavadocMojo mojo = (FixJavadocMojo) lookupMojo( "fix", testPom );
         assertNotNull( mojo );
+        
+        MavenSession session = newMavenSession( mojo.getProject() );
+        // Ensure remote repo connection uses SSL
+        File globalSettingsFile = new File( getBasedir(), "target/test-classes/unit/settings.xml" );
+        session.getRequest().setGlobalSettingsFile( globalSettingsFile );
+        setVariableValueToObject( mojo, "session", session );
 
         // compile the test project
-        invokeCompileGoal( testPom, mojo.getLog() );
+        invokeCompileGoal( testPom, globalSettingsFile, mojo.getLog() );
         assertTrue( new File( testPomBasedir, "target/classes" ).exists() );
 
         mojo.execute();
@@ -639,7 +646,7 @@ public class FixJavadocMojoTest
      * @param log not null
      * @throws MavenInvocationException if any
      */
-    private void invokeCompileGoal( File testPom, Log log )
+    private void invokeCompileGoal( File testPom, File globalSettingsFile, Log log )
         throws Exception
     {
         List<String> goals = new ArrayList<>();
@@ -670,7 +677,7 @@ public class FixJavadocMojoTest
         }
         
         JavadocUtil.invokeMaven( log, new File( getBasedir(), "target/local-repo" ), testPom, goals, properties,
-                                 invokerLogFile );
+                                 invokerLogFile, globalSettingsFile );
     }
 
     // ----------------------------------------------------------------------
diff --git a/src/test/resources/unit/settings.xml b/src/test/resources/unit/settings.xml
new file mode 100644
index 0000000..bfadfb4
--- /dev/null
+++ b/src/test/resources/unit/settings.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+
+<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>httpsCentral</id>
+      <url>https://repo.maven.apache.org/maven2</url>
+      <mirrorOf>central</mirrorOf>
+    </mirror>
+  </mirrors>
+</settings>