[MDEPLOY-207] Remove @Deprecated marked code
authorKarl Heinz Marbaise <khmarbaise@apache.org>
Sun, 16 Apr 2017 11:20:59 +0000 (11:20 +0000)
committerKarl Heinz Marbaise <khmarbaise@apache.org>
Sun, 16 Apr 2017 11:20:59 +0000 (11:20 +0000)
 o Removed the repositoryLayout parameter of deploy-file goal
   and the configuration part layout in altDeploymentRepository
   cause we are in Maven 3 and not Maven 2 and before anymore.

git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1791602 13f79535-47bb-0310-9956-ffa450edef68

src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java
src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java

index 504806e..77e811f 100644 (file)
@@ -19,17 +19,13 @@ package org.apache.maven.plugins.deploy;
  * under the License.
  */
 
-import java.util.Map;
-
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
 import org.apache.maven.artifact.repository.MavenArtifactRepository;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 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.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
 
 /**
@@ -40,12 +36,6 @@ public abstract class AbstractDeployMojo
 {
 
     /**
-     * Map that contains the layouts.
-     */
-    @Component( role = ArtifactRepositoryLayout.class )
-    private Map<String, ArtifactRepositoryLayout> repositoryLayouts;
-
-    /**
      * Flag whether Maven is currently in online/offline mode.
      */
     @Parameter( defaultValue = "${settings.offline}", readonly = true )
@@ -80,19 +70,6 @@ public abstract class AbstractDeployMojo
         }
     }
 
-    ArtifactRepositoryLayout getLayout( String id )
-        throws MojoExecutionException
-    {
-        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
-
-        if ( layout == null )
-        {
-            throw new MojoExecutionException( "Invalid repository layout: " + id );
-        }
-
-        return layout;
-    }
-
     boolean isUpdateReleaseInfo()
     {
         return updateReleaseInfo;
@@ -103,10 +80,9 @@ public abstract class AbstractDeployMojo
         return retryFailedDeploymentCount;
     }
 
-    protected ArtifactRepository createDeploymentArtifactRepository( String id, String url,
-                                                                     ArtifactRepositoryLayout layout )
+    protected ArtifactRepository createDeploymentArtifactRepository( String id, String url )
     {
-        return new MavenArtifactRepository( id, url, layout, new ArtifactRepositoryPolicy(),
+        return new MavenArtifactRepository( id, url, new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(),
                                             new ArtifactRepositoryPolicy() );
     }
     
index 1c493d3..140e589 100644 (file)
@@ -36,7 +36,6 @@ import java.util.regex.Pattern;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Parent;
 import org.apache.maven.model.building.ModelBuildingException;
@@ -155,13 +154,6 @@ public class DeployFileMojo
     private String repositoryId;
 
     /**
-     * The type of remote repository layout to deploy to. Try <i>legacy</i> for a Maven 1.x-style repository layout.
-     */
-    @Deprecated
-    @Parameter( property = "repositoryLayout", defaultValue = "default" )
-    private String repositoryLayout;
-
-    /**
      * URL where the artifact will be deployed. <br/>
      * ie ( file:///C:/m2-repo or scp://host.com/path/to/repo )
      */
@@ -341,9 +333,7 @@ public class DeployFileMojo
 
         initProperties();
 
-        ArtifactRepositoryLayout layout = getLayout( repositoryLayout );
-
-        ArtifactRepository deploymentRepository = createDeploymentArtifactRepository( repositoryId, url, layout );
+        ArtifactRepository deploymentRepository = createDeploymentArtifactRepository( repositoryId, url );
 
         String protocol = deploymentRepository.getProtocol();
 
index b626d31..11dca7c 100644 (file)
@@ -30,7 +30,6 @@ import java.util.regex.Pattern;
 
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Component;
@@ -55,7 +54,7 @@ public class DeployMojo
     extends AbstractDeployMojo
 {
 
-    private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.+)::(.+)" );
+    private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.+)" );
 
     /**
      * When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready
@@ -91,12 +90,10 @@ public class DeployMojo
      * <dl>
      * <dt>id</dt>
      * <dd>The id can be used to pick up the correct credentials from the settings.xml</dd>
-     * <dt>layout</dt>
-     * <dd>Either <code>default</code> for the Maven2 layout or <code>legacy</code> for the Maven1 layout. Maven3 also
-     * uses the <code>default</code> layout.</dd>
      * <dt>url</dt>
      * <dd>The location of the repository</dd>
      * </dl>
+     * <b>Note: Since 3.0.0 the layout part has been removed.</b>
      */
     @Parameter( property = "altDeploymentRepository" )
     private String altDeploymentRepository;
@@ -247,12 +244,9 @@ public class DeployMojo
             else
             {
                 String id = matcher.group( 1 ).trim();
-                String layout = matcher.group( 2 ).trim();
-                String url = matcher.group( 3 ).trim();
+                String url = matcher.group( 2 ).trim();
 
-                ArtifactRepositoryLayout repoLayout = getLayout( layout );
-
-                repo = createDeploymentArtifactRepository( id, url, repoLayout );
+                repo = createDeploymentArtifactRepository( id, url );
             }
         }
 
index fff8676..2ebd83c 100644 (file)
@@ -267,31 +267,31 @@ public class DeployFileMojoTest
         assertTrue( file.exists() );
     }
 
-    public void testDeployIfRepositoryLayoutIsLegacy()
-        throws Exception
-    {
-        File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-legacy-repository-layout/plugin-config.xml" );
-
-        AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo( "deploy-file", testPom );
-
-        assertNotNull( mojo );
-
-        String repositoryLayout = (String) getVariableValueFromObject(  mojo, "repositoryLayout" );
-
-        assertEquals( "legacy", repositoryLayout );
-
-        try
-        {
-            mojo.execute();
-            fail( "legacy is not supported anymore" );
-        }
-        catch ( MojoExecutionException e )
-        {
-            assertEquals( "Invalid repository layout: legacy", e.getMessage() );
-        }
-
-    }
-
+//    public void testDeployIfRepositoryLayoutIsLegacy()
+//        throws Exception
+//    {
+//        File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-legacy-repository-layout/plugin-config.xml" );
+//
+//        AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo( "deploy-file", testPom );
+//
+//        assertNotNull( mojo );
+//
+//        String repositoryLayout = (String) getVariableValueFromObject(  mojo, "repositoryLayout" );
+//
+//        assertEquals( "legacy", repositoryLayout );
+//
+//        try
+//        {
+//            mojo.execute();
+//            fail( "legacy is not supported anymore" );
+//        }
+//        catch ( MojoExecutionException e )
+//        {
+//            assertEquals( "Invalid repository layout: legacy", e.getMessage() );
+//        }
+//
+//    }
+//
     private void addFileToList( File file, List<String> fileList )
     {
         if ( !file.isDirectory() )
index e88bfb5..4db5b2d 100644 (file)
@@ -30,7 +30,6 @@ import java.util.List;
 import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
@@ -596,19 +595,16 @@ public class DeployMojoTest
     {
         DeployMojo mojo = spy( new DeployMojo() );
 
-        ArtifactRepositoryLayout repositoryLayout = mock( ArtifactRepositoryLayout.class );
-        setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) );
-
         ArtifactRepository repository = mock( ArtifactRepository.class );
-        when( mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost",
-                                                       repositoryLayout ) ).thenReturn( repository );
+        when( mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost"
+                                                       ) ).thenReturn( repository );
 
         project.setVersion( "1.0-SNAPSHOT" );
 
         ProjectDeployerRequest pdr =
                         new ProjectDeployerRequest()
                             .setProject( project )
-                            .setAltDeploymentRepository( "altSnapshotDeploymentRepository::default::http://localhost" );
+                            .setAltDeploymentRepository( "altSnapshotDeploymentRepository::http://localhost" );
         assertEquals( repository,
                       mojo.getDeploymentRepository( pdr ));
     }
@@ -618,19 +614,15 @@ public class DeployMojoTest
     {
         DeployMojo mojo = spy( new DeployMojo() );
 
-        ArtifactRepositoryLayout repositoryLayout = mock( ArtifactRepositoryLayout.class );
-        setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) );
-
         ArtifactRepository repository = mock( ArtifactRepository.class );
-        when( mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost",
-                                                       repositoryLayout ) ).thenReturn( repository );
+        when( mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost" ) ).thenReturn( repository );
 
         project.setVersion( "1.0" );
 
         ProjectDeployerRequest pdr =
                         new ProjectDeployerRequest()
                             .setProject( project )
-                            .setAltReleaseDeploymentRepository( "altReleaseDeploymentRepository::default::http://localhost" );
+                            .setAltReleaseDeploymentRepository( "altReleaseDeploymentRepository::http://localhost" );
 
         assertEquals( repository,
                       mojo.getDeploymentRepository( pdr ));