You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2019/05/01 10:02:31 UTC

[maven-artifact-transfer] branch MSHARED-817 created (now d71fb02)

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

khmarbaise pushed a change to branch MSHARED-817
in repository https://gitbox.apache.org/repos/asf/maven-artifact-transfer.git.


      at d71fb02  [MSHARED-817] Change eclipse aether dependency scope to provided

This branch includes the following new commits:

     new d71fb02  [MSHARED-817] Change eclipse aether dependency scope to provided

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-artifact-transfer] 01/01: [MSHARED-817] Change eclipse aether dependency scope to provided

Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MSHARED-817
in repository https://gitbox.apache.org/repos/asf/maven-artifact-transfer.git

commit d71fb025bf393c604ab9bf79b66658ddcd102662
Author: Gabriel Belingueres <be...@gmail.com>
AuthorDate: Wed May 1 00:57:22 2019 -0300

    [MSHARED-817] Change eclipse aether dependency scope to provided
    
    - Changed eclipse aether dependency to provided scope.
    - Removed shading of aether classes.
    - Added method to import aether library inside TransferUtils to use from
    a plugin.
    - Modified ProjectDeployerMojo and ProjectInstallerMojo plugins used for
    ITs.
---
 pom.xml                                            | 38 ++--------------------
 .../plugin/project/deploy/ProjectDeployerMojo.java |  8 +++++
 .../project/install/ProjectInstallerMojo.java      |  6 ++++
 .../shared/transfer/artifact/TransferUtils.java    | 23 +++++++++++++
 4 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/pom.xml b/pom.xml
index 767ea44..e373e1e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,40 +68,6 @@
         </executions>
       </plugin>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-shade-plugin</artifactId>
-        <!--
-         ! explicit overwrite cause otherwise we get an 2.4.3...instead. 
-         -->
-        <version>3.1.0</version>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-            <configuration>
-              <artifactSet>
-                <includes>
-                  <include>org.eclipse.aether:aether-util</include>
-                </includes>
-              </artifactSet>
-              <filters>
-                <filter>
-                  <artifact>org.eclipse.aether:aether-util</artifact>
-                  <includes>
-                    <!-- to prevent java.lang.ClassNotFoundException: org.eclipse.aether.util.artifact.SubArtifact (M3.1.1 - M3.3.3) -->
-                    <include>org/eclipse/aether/util/artifact/SubArtifact.class</include>
-                    <!-- to prevent java.lang.ClassNotFoundException: org.eclipse.aether.util.filter.* (M3.1.1+ ) -->
-                    <include>org/eclipse/aether/util/filter/*</include>
-                  </includes>
-                </filter>
-              </filters>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
         <groupId>org.apache.rat</groupId>
         <artifactId>apache-rat-plugin</artifactId>
         <configuration>
@@ -206,7 +172,7 @@
       <groupId>org.sonatype.aether</groupId>
       <artifactId>aether-impl</artifactId>
       <version>1.7</version>
-      <scope>test</scope>
+      <scope>provided</scope>
     </dependency>
 
     <!-- Maven 3.1.x and above -->
@@ -220,7 +186,7 @@
       <groupId>org.eclipse.aether</groupId>
       <artifactId>aether-util</artifactId>
       <version>0.9.0.M2</version>
-      <!-- provided scoped dependencies aren't shaded -->
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.eclipse.aether</groupId>
diff --git a/src/it/maven-project-deployer-plugin/src/main/java/org/apache/maven/plugin/project/deploy/ProjectDeployerMojo.java b/src/it/maven-project-deployer-plugin/src/main/java/org/apache/maven/plugin/project/deploy/ProjectDeployerMojo.java
index 26c794e..13967bf 100644
--- a/src/it/maven-project-deployer-plugin/src/main/java/org/apache/maven/plugin/project/deploy/ProjectDeployerMojo.java
+++ b/src/it/maven-project-deployer-plugin/src/main/java/org/apache/maven/plugin/project/deploy/ProjectDeployerMojo.java
@@ -32,18 +32,21 @@ import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProjectHelper;
 import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.transfer.artifact.TransferUtils;
 import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException;
 import org.apache.maven.shared.transfer.project.NoFileAssignedException;
 import org.apache.maven.shared.transfer.project.deploy.ProjectDeployer;
 import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest;
 import org.apache.maven.shared.transfer.project.install.ProjectInstaller;
 import org.apache.maven.shared.transfer.repository.RepositoryManager;
+import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
 
 /**
  * This mojo is implemented to test the {@link ProjectInstaller} part of the maven-artifact-transfer shared component.
@@ -65,6 +68,9 @@ public class ProjectDeployerMojo
     @Parameter( defaultValue = "${session}", required = true, readonly = true )
     protected MavenSession session;
 
+    @Parameter( defaultValue = "${plugin}", required = true, readonly = true )
+    protected PluginDescriptor pluginDescriptor;
+
     @Component
     private ProjectDeployer deployer;
 
@@ -112,6 +118,8 @@ public class ProjectDeployerMojo
             pdr.setProject( session.getCurrentProject());
             
             ArtifactRepository repo = session.getCurrentProject().getDistributionManagementArtifactRepository();
+            
+            TransferUtils.importAetherLibrary( pluginDescriptor );
             deployer.deploy( session.getProjectBuildingRequest(), pdr, repo );
         }
         catch ( IOException e )
diff --git a/src/it/maven-project-installer-plugin/src/main/java/org/apache/maven/plugin/project/install/ProjectInstallerMojo.java b/src/it/maven-project-installer-plugin/src/main/java/org/apache/maven/plugin/project/install/ProjectInstallerMojo.java
index 2e6a878..ab910e4 100644
--- a/src/it/maven-project-installer-plugin/src/main/java/org/apache/maven/plugin/project/install/ProjectInstallerMojo.java
+++ b/src/it/maven-project-installer-plugin/src/main/java/org/apache/maven/plugin/project/install/ProjectInstallerMojo.java
@@ -31,12 +31,14 @@ import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProjectHelper;
 import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.transfer.artifact.TransferUtils;
 import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException;
 import org.apache.maven.shared.transfer.project.NoFileAssignedException;
 import org.apache.maven.shared.transfer.project.install.ProjectInstaller;
@@ -63,6 +65,9 @@ public class ProjectInstallerMojo
     @Parameter( defaultValue = "${session}", required = true, readonly = true )
     protected MavenSession session;
 
+    @Parameter( defaultValue = "${plugin}", required = true, readonly = true )
+    protected PluginDescriptor pluginDescriptor;
+
     @Component
     private ProjectInstaller installer;
 
@@ -108,6 +113,7 @@ public class ProjectInstallerMojo
             
             ProjectInstallerRequest pir = new ProjectInstallerRequest();
             pir.setProject( session.getCurrentProject());
+            TransferUtils.importAetherLibrary( pluginDescriptor );
             installer.install( pbr, pir );
         }
         catch ( ArtifactInstallerException e )
diff --git a/src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java b/src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java
index 83fa7e1..fc07b95 100644
--- a/src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java
+++ b/src/main/java/org/apache/maven/shared/transfer/artifact/TransferUtils.java
@@ -24,6 +24,9 @@ import org.apache.maven.model.Extension;
 import org.apache.maven.model.Parent;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
 
 /**
  * Utility class
@@ -122,4 +125,24 @@ public final class TransferUtils
         return coordinate;
     }
 
+    /**
+     * Import the core Aether library from the maven distribution.
+     * 
+     * @param pluginDescriptor the plugin descriptor where the operation will be executed.
+     * @throws MojoExecutionException if there is an error when importing the library.
+     * @since 0.11.1
+     */
+    public static void importAetherLibrary( PluginDescriptor pluginDescriptor )
+        throws MojoExecutionException
+    {
+        try
+        {
+            pluginDescriptor.getClassRealm().importFrom( "plexus.core", "org.eclipse.aether.util" );
+        }
+        catch ( NoSuchRealmException e )
+        {
+            throw new MojoExecutionException( "NoSuchRealmException", e );
+        }
+    }
+
 }