You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2016/01/12 22:37:01 UTC

svn commit: r1724329 - in /maven/plugins/trunk/maven-install-plugin/src: it/no-main-artifact-1/ it/no-main-artifact-2/ main/java/org/apache/maven/plugin/install/ test/java/org/apache/maven/plugin/install/ test/resources/unit/basic-install-test-with-att...

Author: rfscholte
Date: Tue Jan 12 21:37:00 2016
New Revision: 1724329

URL: http://svn.apache.org/viewvc?rev=1724329&view=rev
Log:
[MINSTALL-118] MavenProject with only attachments must have packaging "pom"

Added:
    maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/invoker.properties
    maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/verify.groovy
    maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/invoker.properties
    maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/verify.groovy
Removed:
    maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/verify.bsh
    maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/verify.bsh
Modified:
    maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
    maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
    maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java
    maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml

Added: maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/invoker.properties?rev=1724329&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/invoker.properties (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/invoker.properties Tue Jan 12 21:37:00 2016
@@ -0,0 +1,17 @@
+# 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.
+invoker.buildResult=failure
\ No newline at end of file

Added: maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/verify.groovy?rev=1724329&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/verify.groovy (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-1/verify.groovy Tue Jan 12 21:37:00 2016
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+def buildLog = new File ( basedir, "build.log")
+
+assert buildLog.text.contains( "The packaging plugin for this project did not assign "
+                                   + "a main file to the project but it has attachments. Change packaging to 'pom'." )
\ No newline at end of file

Added: maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/invoker.properties?rev=1724329&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/invoker.properties (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/invoker.properties Tue Jan 12 21:37:00 2016
@@ -0,0 +1,17 @@
+# 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.
+invoker.buildResult=failure
\ No newline at end of file

Added: maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/verify.groovy?rev=1724329&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/verify.groovy (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/no-main-artifact-2/verify.groovy Tue Jan 12 21:37:00 2016
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+def buildLog = new File ( basedir, "build.log")
+
+assert buildLog.text.contains( "The packaging plugin for this project did not assign "
+                                   + "a main file to the project but it has attachments. Change packaging to 'pom'." )
\ No newline at end of file

Modified: maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java?rev=1724329&r1=1724328&r2=1724329&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java (original)
+++ maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java Tue Jan 12 21:37:00 2016
@@ -274,7 +274,7 @@ public class InstallFileMojo
         }
 
         validateArtifactInformation();
-
+        
         Artifact artifact =
             artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, packaging, classifier );
 
@@ -526,24 +526,6 @@ public class InstallFileMojo
         }
     }
 
-    /**
-     * @return the localRepositoryPath
-     */
-    @SuppressWarnings( "UnusedDeclaration" )
-    public File getLocalRepositoryPath()
-    {
-        return this.localRepositoryPath;
-    }
-
-    /**
-     * @param theLocalRepositoryPath the localRepositoryPath to set
-     */
-    public void setLocalRepositoryPath( File theLocalRepositoryPath )
-    {
-        this.localRepositoryPath = theLocalRepositoryPath;
-    }
-
-    
     private static class InstallModelProblemCollector implements ModelProblemCollector
     {
         /** */

Modified: maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java?rev=1724329&r1=1724328&r2=1724329&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java (original)
+++ maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java Tue Jan 12 21:37:00 2016
@@ -182,21 +182,8 @@ public class InstallMojo
                 }
                 else if ( !attachedArtifacts.isEmpty() )
                 {
-                    getLog().info( "No primary artifact to install, installing attached artifacts instead." );
-
-                    Artifact pomArtifact =
-                        artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(),
-                                                               artifact.getBaseVersion() );
-                    pomArtifact.setFile( pomFile );
-                    if ( updateReleaseInfo )
-                    {
-                        pomArtifact.setRelease( true );
-                    }
-
-//                    installer.install( pomFile, pomArtifact, localRepository );
-                    installer.install( session.getProjectBuildingRequest(), Collections.singletonList( pomArtifact ) );
-                    installChecksums( pomArtifact, createChecksum );
-                    addMetaDataFilesForArtifact( pomArtifact, metadataFiles, createChecksum );
+                    throw new MojoExecutionException( "The packaging plugin for this project did not assign "
+                                   + "a main file to the project but it has attachments. Change packaging to 'pom'." );
                 }
                 else
                 {

Modified: maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java?rev=1724329&r1=1724328&r2=1724329&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java (original)
+++ maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java Tue Jan 12 21:37:00 2016
@@ -145,10 +145,10 @@ public class InstallMojoTest
                 attachedArtifact.getArtifactId() + "/" + attachedArtifact.getVersion() + "/" +
                 attachedArtifact.getArtifactId() + "-" + attachedArtifact.getVersion() + "." + packaging );
 
-            assertTrue( installedArtifact.exists() );
+            assertTrue( installedArtifact.getPath() + " does not exist", installedArtifact.exists() );
         }
         
-        assertEquals( 12, FileUtils.getFiles( new File( LOCAL_REPO ), null, null ).size() );
+        assertEquals( 13, FileUtils.getFiles( new File( LOCAL_REPO ), null, null ).size() );
     }
 
     public void testUpdateReleaseParamSetToTrue()

Modified: maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml?rev=1724329&r1=1724328&r2=1724329&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml (original)
+++ maven/plugins/trunk/maven-install-plugin/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml Tue Jan 12 21:37:00 2016
@@ -26,7 +26,9 @@ under the License.
           <project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub">
             <file>${basedir}/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml</file>
             <packaging>jar</packaging>
-            <artifact implementation="org.apache.maven.plugin.install.stubs.InstallArtifactStub"/>
+            <artifact implementation="org.apache.maven.plugin.install.stubs.InstallArtifactStub">
+              <file>${basedir}/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml</file>
+            </artifact>
             <attachedArtifacts>
               <attachedArtifact
                   implementation="org.apache.maven.plugin.install.stubs.AttachedArtifactStub0"/>