You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2010/09/09 00:38:20 UTC

svn commit: r995270 - in /maven/core-integration-testing/trunk: core-it-suite/src/test/java/org/apache/maven/it/ core-it-suite/src/test/resources/mng-4788/ core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/c...

Author: bentmann
Date: Wed Sep  8 22:38:20 2010
New Revision: 995270

URL: http://svn.apache.org/viewvc?rev=995270&view=rev
Log:
[MNG-4788] [regression] Appassembler Maven Plugin doesn't work like as it should

o Added IT

Added:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4788InstallationToCustomLocalRepoTest.java   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4788/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4788/pom.xml   (with props)
    maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java   (with props)
    maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallCustomMojo.java   (with props)
Modified:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
    maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java
    maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java

Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java?rev=995270&r1=995269&r2=995270&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java Wed Sep  8 22:38:20 2010
@@ -85,6 +85,7 @@ public class IntegrationTestSuite
         suite.addTestSuite( MavenITmng4795DepResolutionInReactorProjectForkedByLifecycleTest.class );
         suite.addTestSuite( MavenITmng4791ProjectBuilderResolvesRemotePomArtifactTest.class );
         suite.addTestSuite( MavenITmng4789ScopeInheritanceMeetsConflictTest.class );
+        suite.addTestSuite( MavenITmng4788InstallationToCustomLocalRepoTest.class );
         suite.addTestSuite( MavenITmng4786AntBased21xMojoSupportTest.class );
         suite.addTestSuite( MavenITmng4781DeploymentToNexusStagingRepoTest.class );
         suite.addTestSuite( MavenITmng4779MultipleDepsWithVersionRangeFromLocalRepoTest.class );

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4788InstallationToCustomLocalRepoTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4788InstallationToCustomLocalRepoTest.java?rev=995270&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4788InstallationToCustomLocalRepoTest.java (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4788InstallationToCustomLocalRepoTest.java Wed Sep  8 22:38:20 2010
@@ -0,0 +1,62 @@
+package org.apache.maven.it;
+
+/*
+ * 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 org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4788">MNG-4788</a>.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class MavenITmng4788InstallationToCustomLocalRepoTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng4788InstallationToCustomLocalRepoTest()
+    {
+        super( "[2.0.3,3.0-alpha-1),[3.0-beta-4,)" );
+    }
+
+    /**
+     * Verify that plugins can install artifacts to a custom local repo (i.e. custom base dir and custom layout).
+     */
+    public void testit()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4788" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        verifier.assertFilePresent( "target/local-repo/test-0.1-SNAPSHOT.jar" );
+        verifier.assertFileNotPresent( "target/local-repo/org/apache/maven/its/mng4788/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT.jar" );
+    }
+
+}

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4788InstallationToCustomLocalRepoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4788InstallationToCustomLocalRepoTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4788/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4788/pom.xml?rev=995270&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4788/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4788/pom.xml Wed Sep  8 22:38:20 2010
@@ -0,0 +1,58 @@
+<?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>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng4788</groupId>
+  <version>0.1-SNAPSHOT</version>
+  <artifactId>test</artifactId>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-4788</name>
+  <description>
+    Verify that plugins can install artifacts to a custom local repo (i.e. custom base dir and custom layout).
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-artifact</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>deploy</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>set</goal>
+              <goal>install-custom</goal>
+            </goals>
+            <configuration>
+              <mainFile>pom.xml</mainFile>
+              <localRepoDir>target/local-repo</localRepoDir>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4788/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4788/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java?rev=995270&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java Wed Sep  8 22:38:20 2010
@@ -0,0 +1,66 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+
+/**
+ * @author Benjamin Bentmann
+ */
+public class CustomRepositoryLayout
+    implements ArtifactRepositoryLayout
+{
+
+    public String pathOf( Artifact artifact )
+    {
+        ArtifactHandler artifactHandler = artifact.getArtifactHandler();
+
+        StringBuffer path = new StringBuffer();
+
+        path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
+
+        if ( artifact.hasClassifier() )
+        {
+            path.append( '-' ).append( artifact.getClassifier() );
+        }
+
+        if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
+        {
+            path.append( '.' ).append( artifactHandler.getExtension() );
+        }
+
+        return path.toString();
+    }
+
+    public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
+    {
+        return metadata.getLocalFilename( repository );
+    }
+
+    public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
+    {
+        return metadata.getRemoteFilename();
+    }
+
+}

Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java?rev=995270&r1=995269&r2=995270&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java Wed Sep  8 22:38:20 2010
@@ -23,7 +23,6 @@ import org.apache.maven.artifact.Artifac
 import org.apache.maven.artifact.deployer.ArtifactDeployer;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
 
 import java.util.Iterator;
 
@@ -62,7 +61,7 @@ public class DeployMojo
      * @throws MojoExecutionException If any artifact could not be installed.
      */
     public void execute()
-        throws MojoExecutionException, MojoFailureException
+        throws MojoExecutionException
     {
         getLog().info( "[MAVEN-CORE-IT-LOG] Deploying project artifacts" );
 

Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallCustomMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallCustomMojo.java?rev=995270&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallCustomMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallCustomMojo.java Wed Sep  8 22:38:20 2010
@@ -0,0 +1,76 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.File;
+
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Installs the project artifacts into a local repository with a custom base directory and a custom layout.
+ * 
+ * @goal install-custom
+ * 
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class InstallCustomMojo
+    extends InstallMojo
+{
+
+    /**
+     * @component
+     */
+    private ArtifactRepositoryFactory repositoryFactory;
+
+    /**
+     * The base directory of the local repository to install to.
+     * 
+     * @parameter expression="${install.localRepoDir}"
+     */
+    private String localRepoDir;
+
+    /**
+     * Runs this mojo.
+     * 
+     * @throws MojoExecutionException If any artifact could not be installed.
+     */
+    public void execute()
+        throws MojoExecutionException
+    {
+        try
+        {
+            String url = "file://" + new File( localRepoDir ).toURL().getPath();
+
+            localRepository =
+                repositoryFactory.createArtifactRepository( localRepository.getId(), url, new CustomRepositoryLayout(),
+                                                            localRepository.getSnapshots(),
+                                                            localRepository.getReleases() );
+        }
+        catch ( Exception e )
+        {
+            throw new MojoExecutionException( "Failed to create custom local repository", e );
+        }
+
+        super.execute();
+    }
+
+}

Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallCustomMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallCustomMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java?rev=995270&r1=995269&r2=995270&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java Wed Sep  8 22:38:20 2010
@@ -22,7 +22,6 @@ package org.apache.maven.plugin.coreit;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.installer.ArtifactInstaller;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
 
 import java.util.Iterator;
 
@@ -52,7 +51,7 @@ public class InstallMojo
      * @throws MojoExecutionException If any artifact could not be installed.
      */
     public void execute()
-        throws MojoExecutionException, MojoFailureException
+        throws MojoExecutionException
     {
         getLog().info( "[MAVEN-CORE-IT-LOG] Installing project artifacts" );