Author: pgier
Date: Thu Feb 24 17:23:43 2011
New Revision: 1074223

URL: http://svn.apache.org/viewvc?rev=1074223&view=rev
Log:
[MDEPLOY-106] Packaging should default to file extension if non is specified.

Added:
    maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/invoker.properties
   (with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/lib/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/lib/test-1.1.jar
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/pom.xml 
  (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/setup.bsh
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/test.properties
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/verify.bsh
   (with props)
Modified:
    
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/invoker.properties?rev=1074223&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/invoker.properties
 Thu Feb 24 17:23:43 2011
@@ -0,0 +1,2 @@
+# Clean build of the jars
+invoker.goals = 
${project.groupId}:${project.artifactId}:${project.version}:deploy-file 

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/lib/test-1.1.jar
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/lib/test-1.1.jar?rev=1074223&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/lib/test-1.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/pom.xml?rev=1074223&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/pom.xml 
(added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/pom.xml 
Thu Feb 24 17:23:43 2011
@@ -0,0 +1,85 @@
+<?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/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.deploy</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>deploy-attached-sources</name>
+  <description>sample jar project with attached sources</description>
+  <url>http://jira.codehaus.org/browse/MDEPLOY-106</url>
+
+  <distributionManagement>
+    <repository>
+      <id>repo1</id>
+      <name>Maven Central Repository</name>
+      <url>scp://foo.org/m2/release</url>
+    </repository>
+    <snapshotRepository>
+      <id>repo1</id>
+      <name>Maven Central Repository</name>
+      <url>scp://foo.org/m2/snapshot</url>
+    </snapshotRepository>
+  </distributionManagement>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <version>2.1.2</version>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <goals>
+              <goal>jar-no-fork</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <version>2.7</version>
+        <executions>
+          <execution>
+            <id>attach-javadoc</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <!-- Deployments will be written to ${basedir}/target -->
+          
<altDeploymentRepository>mine::default::file://${basedir}/target</altDeploymentRepository>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/setup.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/setup.bsh?rev=1074223&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/setup.bsh
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/setup.bsh
 Thu Feb 24 17:23:43 2011
@@ -0,0 +1,7 @@
+import java.io.*;
+import java.util.*;
+
+file = new File( basedir, "target/repo" );
+file.mkdirs();
+
+return true;

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/test.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/test.properties?rev=1074223&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/test.properties
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/test.properties
 Thu Feb 24 17:23:43 2011
@@ -0,0 +1,6 @@
+# Properties passed to invocations of the deploy plugin
+groupId = org.apache.maven.test
+artifactId = test
+version = 1.1
+file = ${basedir}/lib/test-1.1.jar
+url = file://${basedir}/target/repo

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/test.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/verify.bsh?rev=1074223&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/verify.bsh
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/verify.bsh
 Thu Feb 24 17:23:43 2011
@@ -0,0 +1,51 @@
+
+/*
+ * 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.jar.*;
+import org.codehaus.plexus.util.*;
+
+boolean result = true;
+
+try
+{
+    File target = new File( basedir, "target" );
+    if ( !target.exists() || !target.isDirectory() )
+    {
+        System.err.println( "target file is missing or not a directory." );
+        return false;
+    }
+    
+    File deployedFile = new File ( target, 
"repo/org/apache/maven/test/test/1.1/test-1.1.jar" );
+    if ( !deployedFile.isFile() )
+    {
+        System.err.println( "Deployed file is missing or is not a directory: " 
+ deployedFile);
+        return false;
+    }   
+        
+}
+catch( Throwable e )
+{
+    e.printStackTrace();
+    result = false;
+}
+
+return result;

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-default-packaging/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java?rev=1074223&r1=1074222&r2=1074223&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
 Thu Feb 24 17:23:43 2011
@@ -35,6 +35,7 @@ import org.apache.maven.project.MavenPro
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 import org.apache.maven.project.validation.ModelValidationResult;
 import org.apache.maven.project.validation.ModelValidator;
+import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
@@ -98,6 +99,7 @@ public class DeployFileMojo
 
     /**
      * Type of the artifact to be deployed.  Retrieved from POM file if 
specified.
+     * Defaults to file extension if not specified via command line or POM.
      *
      * @parameter expression="${packaging}"
      */
@@ -209,6 +211,11 @@ public class DeployFileMojo
 
             processModel( model );
         }
+        
+        if ( packaging == null && file != null )
+        {
+            packaging = FileUtils.getExtension( file.getName() );
+        }
     }
 
     public void execute()
@@ -216,15 +223,15 @@ public class DeployFileMojo
     {
         failIfOffline();
 
-        initProperties();
-
-        validateArtifactInformation();
-
         if ( !file.exists() )
         {
             throw new MojoExecutionException( file.getPath() + " not found." );
         }
 
+        initProperties();
+
+        validateArtifactInformation();
+
         ArtifactRepositoryLayout layout = getLayout( repositoryLayout );
 
         ArtifactRepository deploymentRepository =


Reply via email to