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

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

commit d278901af149829ace50ce6c65b1cbe5db0b0199
Author: olivier lamy <[email protected]>
AuthorDate: Mon Jul 29 16:16:40 2019 +1000

    Revert "[MINVOKER-249] InstallMojo extraArtifacts are always downloaded 
(optionally local repo must checked first)"
    
    This reverts commit ecb35c2e729e130581075a2bc33d8b770b8d072c.
---
 pom.xml                                            |  6 --
 src/it/install-extra-artifacts-local-repo/pom.xml  | 71 ---------------------
 .../install-extra-artifacts-local-repo/verify.bsh  | 69 ---------------------
 .../apache/maven/plugins/invoker/InstallMojo.java  | 72 ++++------------------
 4 files changed, 13 insertions(+), 205 deletions(-)

diff --git a/pom.xml b/pom.xml
index 342467b..5461d7a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -333,12 +333,6 @@ under the License.
                   <goal>clean</goal>
                   <goal>initialize</goal>
                 </goals>
-                <extraArtifacts>
-                  <extraArtifact>junit:junit:3.8.2</extraArtifact>
-                  
<extraArtifact>org.apache.maven.plugins:maven-clean-plugin:2.4:maven-plugin</extraArtifact>
-                  
<extraArtifact>org.apache.maven.plugins:maven-clean-plugin:2.4:jar:javadoc</extraArtifact>
-                  <extraArtifact>jdom:jdom:1.1</extraArtifact>
-                </extraArtifacts>
               </configuration>
             </plugin>
           </plugins>
diff --git a/src/it/install-extra-artifacts-local-repo/pom.xml 
b/src/it/install-extra-artifacts-local-repo/pom.xml
deleted file mode 100644
index 6634ce0..0000000
--- a/src/it/install-extra-artifacts-local-repo/pom.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?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/maven-v4_0_0.xsd";>
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.maven.plugins.invoker</groupId>
-  <artifactId>stage-extras</artifactId>
-  <version>1.0-SNAPSHOT</version>
-  <packaging>pom</packaging>
-
-  <description>
-    Test to check for staging of external dependencies directly from local 
repository (MINVOKER-102).
-  </description>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-invoker-plugin</artifactId>
-        <version>@pom.version@</version>
-        <configuration>
-          <useLocalRepository>true</useLocalRepository>
-          
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
-          <extraArtifacts>
-            <!-- gid:aid:version -->
-            <extraArtifact>junit:junit:3.8.2</extraArtifact>
-            <!-- gid:aid:version:type -->
-            
<extraArtifact>org.apache.maven.plugins:maven-clean-plugin:2.4:maven-plugin</extraArtifact>
-            <!-- gid:aid:version:type:classifier -->
-            
<extraArtifact>org.apache.maven.plugins:maven-clean-plugin:2.4:jar:javadoc</extraArtifact>
-            <!-- relocated -->
-            <extraArtifact>jdom:jdom:1.1</extraArtifact>
-          </extraArtifacts>
-        </configuration>
-        <executions>
-          <execution>
-            <id>integration-test</id>
-            <phase>initialize</phase>
-            <goals>
-              <goal>install</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
-</project>
diff --git a/src/it/install-extra-artifacts-local-repo/verify.bsh 
b/src/it/install-extra-artifacts-local-repo/verify.bsh
deleted file mode 100644
index ba95e36..0000000
--- a/src/it/install-extra-artifacts-local-repo/verify.bsh
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 java.io.*;
-import java.util.*;
-import java.util.regex.*;
-
-try
-{
-    File itRepoDir = new File( basedir, "target/it-repo" );
-    if ( !itRepoDir.isDirectory() )
-    {
-        System.out.println( "IT local repository missing: " + itRepoDir );
-        return false;
-    }
-
-    String[] files =
-    {
-        
"org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4.jar",
-        
"org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4.pom",
-        
"org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4-javadoc.jar",
-        "org/apache/maven/plugins/maven-plugins/16/maven-plugins-16.pom",
-        "org/apache/maven/maven-parent/15/maven-parent-15.pom",
-        "org/apache/apache/6/apache-6.pom",
-        "org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar",
-        "org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom",
-        "junit/junit/3.8.2/junit-3.8.2.jar",
-        "junit/junit/3.8.2/junit-3.8.2.pom",
-        "jdom/jdom/1.1/jdom-1.1.pom",
-        "org/jdom/jdom/1.1/jdom-1.1.pom",
-        "org/jdom/jdom/1.1/jdom-1.1.jar",
-    };
-    for ( String file : files )
-    {
-        File stagedFile = new File( itRepoDir, file );
-        System.out.println( "Checking for existence of: " + stagedFile );
-        if ( !stagedFile.isFile() )
-        {
-            throw new IllegalStateException( "Missing: " + stagedFile );
-        }
-        if ( file.endsWith( "jdom-1.1.jar" ) && stagedFile.length() < 1024 * 
10 )
-        {
-            throw new IllegalStateException( "Corrupt: " + stagedFile );
-        }
-    }
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
-
-return true;
diff --git a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java 
b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java
index 0610d8c..63543c9 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java
@@ -19,6 +19,15 @@ package org.apache.maven.plugins.invoker;
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Map;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -37,25 +46,12 @@ import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter;
 import org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller;
-import 
org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException;
-import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
 import 
org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate;
 import 
org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
 import 
org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
 import org.apache.maven.shared.transfer.repository.RepositoryManager;
 import org.codehaus.plexus.util.FileUtils;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-
 /**
  * Installs the project artifacts of the main build into the local repository 
as a preparation to run the sub projects.
  * More precisely, all artifacts of the project itself, all its locally 
reachable parent POMs and all its dependencies
@@ -165,14 +161,6 @@ public class InstallMojo
     @Component
     private DependencyResolver resolver;
 
-    /**
-     * if the local repository is not used as test repo, the parameter can 
force get artifacts from local repo
-     * if available instead of download the artifacts again.
-     * @since 3.2.1
-     */
-    @Parameter( property = "invoker.useLocalRepository", defaultValue = 
"false" )
-    private boolean useLocalRepository;
-
     private ProjectBuildingRequest projectBuildingRequest;
 
     /**
@@ -217,19 +205,8 @@ public class InstallMojo
         {
             throw new MojoExecutionException( "Failed to create directory: " + 
localRepositoryPath );
         }
-
-        // we just don't want to download everything again..
-        if ( !localRepository.getBasedir().equals( 
localRepositoryPath.getPath() ) && useLocalRepository )
-        {
-            projectBuildingRequest =
-                repositoryManager.setLocalRepositoryBasedir( 
session.getProjectBuildingRequest(),
-                                                             new File( 
localRepository.getBasedir() ) );
-        }
-        else
-        {
-            projectBuildingRequest =
-                repositoryManager.setLocalRepositoryBasedir( 
session.getProjectBuildingRequest(), localRepositoryPath );
-        }
+        projectBuildingRequest =
+            repositoryManager.setLocalRepositoryBasedir( 
session.getProjectBuildingRequest(), localRepositoryPath );
     }
 
     /**
@@ -641,37 +618,14 @@ public class InstallMojo
                 coordinate.setType( type );
                 coordinate.setClassifier( classifier );
 
-                Iterable<ArtifactResult> artifactResults =
-                    resolver.resolveDependencies( projectBuildingRequest, 
coordinate,
-                                                  new PatternExclusionsFilter( 
Collections.<String>emptyList() ) );
-                if ( !localRepository.getBasedir().equals( 
localRepositoryPath.getPath() ) && useLocalRepository )
-                {
-                    // using another request with the correct target repo
-                    installer.install( 
repositoryManager.setLocalRepositoryBasedir( 
session.getProjectBuildingRequest(),
-                                                                               
     localRepositoryPath ),
-                                       toArtifactsList( artifactResults ) );
-                }
+                resolver.resolveDependencies( projectBuildingRequest, 
coordinate,
+                                              new PatternExclusionsFilter( 
Collections.<String>emptyList() ) );
             }
             catch ( DependencyResolverException e )
             {
                 throw new MojoExecutionException( "Unable to resolve 
dependencies for: " + coordinate, e );
             }
-            catch ( ArtifactInstallerException e )
-            {
-                throw new MojoExecutionException( "Fail to install artifacts: 
" + coordinate, e );
-            }
-        }
-    }
-
-    // FIXME could be simplify with using lambda... maybe in the next 
century... :P
-    private List<Artifact> toArtifactsList( Iterable<ArtifactResult> 
artifactResults )
-    {
-        List<Artifact> artifacts = new ArrayList<>( );
-        for ( ArtifactResult artifactResult : artifactResults )
-        {
-            artifacts.add( artifactResult.getArtifact() );
         }
-        return artifacts;
     }
 
 }

Reply via email to