You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/06/28 15:20:18 UTC

[GitHub] [maven-install-plugin] mthmulders commented on a diff in pull request #31: [MINSTALL-175] Drop MAT

mthmulders commented on code in PR #31:
URL: https://github.com/apache/maven-install-plugin/pull/31#discussion_r908614592


##########
src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java:
##########
@@ -170,36 +173,37 @@
     @Component
     private ProjectBuilder projectBuilder;
 
-    /**
-     * Used to install the project created.
-     */
-    @Component
-    private ProjectInstaller installer;
-
     /**
      * @see org.apache.maven.plugin.Mojo#execute()
      */
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-
         if ( !file.exists() )
         {
             String message = "The specified file '" + file.getPath() + "' does not exist";
             getLog().error( message );
             throw new MojoFailureException( message );
         }
 
-        ProjectBuildingRequest buildingRequest = session.getProjectBuildingRequest();
-
-        // ----------------------------------------------------------------------
-        // Override the default localRepository variable
-        // ----------------------------------------------------------------------
         if ( localRepositoryPath != null )
         {
-            buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, localRepositoryPath );
-
-            getLog().debug( "localRepoPath: " + repositoryManager.getLocalRepositoryBasedir( buildingRequest ) );
+            // "clone" session and replace localRepository

Review Comment:
   ```suggestion
               // "clone" Maven session and replace localRepository
   ```



##########
src/main/java/org/apache/maven/plugins/install/AbstractInstallMojo.java:
##########
@@ -49,28 +56,98 @@
      * Gets the path of the specified artifact within the local repository. Note that the returned path need not exist
      * (yet).
      *
-     * @param buildingRequest {@link ProjectBuildingRequest}.
      * @param artifact The artifact whose local repo path should be determined, must not be <code>null</code>.
      * @return The absolute path to the artifact when installed, never <code>null</code>.
      */
-    protected File getLocalRepoFile( ProjectBuildingRequest buildingRequest, Artifact artifact )
+    protected File getLocalRepoFile( Artifact artifact )
     {
-        String path = repositoryManager.getPathForLocalArtifact( buildingRequest, artifact );
-        return new File( repositoryManager.getLocalRepositoryBasedir( buildingRequest ), path );
+        String path = session.getRepositorySession().getLocalRepositoryManager()
+                .getPathForLocalArtifact( RepositoryUtils.toArtifact( artifact ) );
+        return new File( session.getRepositorySession().getLocalRepository().getBasedir(), path );
     }
 
     /**
      * Gets the path of the specified artifact metadata within the local repository. Note that the returned path need
      * not exist (yet).
      *
-     * @param buildingRequest {@link ProjectBuildingRequest}.
      * @param metadata The artifact metadata whose local repo path should be determined, must not be <code>null</code>.
      * @return The absolute path to the artifact metadata when installed, never <code>null</code>.
      */
-    protected File getLocalRepoFile( ProjectBuildingRequest buildingRequest, ProjectArtifactMetadata metadata )
+    protected File getLocalRepoFile( ProjectArtifactMetadata metadata )
     {
-        String path = repositoryManager.getPathForLocalMetadata( buildingRequest, metadata );
-        return new File( repositoryManager.getLocalRepositoryBasedir( buildingRequest ), path );
+        DefaultArtifact pomArtifact = new DefaultArtifact(
+                metadata.getGroupId(),
+                metadata.getArtifactId(),
+                "",
+                "pom",
+                metadata.getBaseVersion() );
+
+        String path = session.getRepositorySession().getLocalRepositoryManager().getPathForLocalArtifact(
+                pomArtifact );
+        return new File( session.getRepositorySession().getLocalRepository().getBasedir(), path );
     }
 
+    protected void installProject( MavenProject project )
+            throws MojoFailureException, MojoExecutionException
+    {
+        try
+        {
+            InstallRequest request = new InstallRequest();
+            Artifact artifact = project.getArtifact();
+            String packaging = project.getPackaging();
+            File pomFile = project.getFile();
+            boolean isPomArtifact = "pom".equals( packaging );
+
+            if ( pomFile != null )
+            {
+                request.addArtifact( RepositoryUtils.toArtifact( new ProjectArtifact( project ) ) );
+            }
+
+            if ( !isPomArtifact )
+            {
+                File file = artifact.getFile();
+
+                // Here, we have a temporary solution to MINSTALL-3 (isDirectory() is true if it went through compile

Review Comment:
   This looks odd. We build against Maven 3.2.5 (see pom.xml) but this comment suggests a "proper solution" will be in place with Maven 2.1?



##########
pom.xml:
##########
@@ -63,10 +63,10 @@
   </distributionManagement>
 
   <properties>
-    <mavenVersion>3.2.5</mavenVersion>
-    <slf4jVersion>1.7.32</slf4jVersion>
-    <aetherVersion>1.1.0</aetherVersion>
     <javaVersion>7</javaVersion>
+    <mavenVersion>3.2.5</mavenVersion>
+    <aetherVersion>1.0.0.v20140518</aetherVersion> <!-- Maven bound -->

Review Comment:
   This is effectively a downgrade? From 1.1.0 to 1.0.0.v20140518?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org