Author: khmarbaise
Date: Sun Sep 18 17:18:53 2016
New Revision: 1761342

URL: http://svn.apache.org/viewvc?rev=1761342&view=rev
Log:
 o Using NoFileAssignedException instead of IllegalArgumentException
   ProjectDeployer, DefaultProjectDeployer, ProjectInstaller,
   DefaultProjectInstaller.
 o made protected methods private.

Added:
    
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/NoFileAssignedException.java
Modified:
    
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
    
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
    
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
    
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java

Added: 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/NoFileAssignedException.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/NoFileAssignedException.java?rev=1761342&view=auto
==============================================================================
--- 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/NoFileAssignedException.java
 (added)
+++ 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/NoFileAssignedException.java
 Sun Sep 18 17:18:53 2016
@@ -0,0 +1,51 @@
+package org.apache.maven.shared.project;
+
+/*
+ * 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.
+ */
+
+/**
+ * This exception will be thrown if no file has been assigned to artifact.
+ * 
+ */
+public class NoFileAssignedException
+    extends Exception
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -3466983009427148332L;
+
+    /**
+     * @param message The message of the error.
+     * @param e {@link Exception}
+     */
+    public NoFileAssignedException( String message, Exception e )
+    {
+        super( message, e );
+    }
+
+    /**
+     * @param message The message.
+     */
+    public NoFileAssignedException( String message )
+    {
+        super( message );
+    }
+}

Modified: 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java?rev=1761342&r1=1761341&r2=1761342&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
 (original)
+++ 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/ProjectDeployer.java
 Sun Sep 18 17:18:53 2016
@@ -19,8 +19,30 @@ package org.apache.maven.shared.project.
  * under the License.
  */
 
+import java.io.IOException;
+
+/*
+ * 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.repository.ArtifactRepository;
 import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.project.NoFileAssignedException;
 
 /**
  * This defines the interface to deploy a single Maven Project.
@@ -47,14 +69,16 @@ public interface ProjectDeployer
      *    .setUpdateReleaseInfo( true );
      *    
      *  deployer.deploy (session.getProjectBuildingRequest(), pbr, 
artifactRepository);
-     *  
      * </pre>
      * 
      * @param buildingRequest {@link ProjectBuildingRequest}
      * @param request {@link ProjectDeployerRequest}
      * @param artifactRepository {@link ArtifactRepository}
+     * @throws IOException In case of problems related to checksums.
+     * @throws NoFileAssignedException In case of missing file which has not 
been assigned to project.
      */
     void deployProject( ProjectBuildingRequest buildingRequest, 
ProjectDeployerRequest request,
-                        ArtifactRepository artifactRepository );
+                        ArtifactRepository artifactRepository )
+        throws IOException, NoFileAssignedException;
 
 }

Modified: 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java?rev=1761342&r1=1761341&r2=1761342&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
 (original)
+++ 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/deploy/internal/DefaultProjectDeployer.java
 Sun Sep 18 17:18:53 2016
@@ -20,6 +20,7 @@ package org.apache.maven.shared.project.
  */
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -30,6 +31,7 @@ import org.apache.maven.project.ProjectB
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 import org.apache.maven.shared.artifact.deploy.ArtifactDeployer;
 import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException;
+import org.apache.maven.shared.project.NoFileAssignedException;
 import org.apache.maven.shared.project.deploy.ProjectDeployer;
 import org.apache.maven.shared.project.deploy.ProjectDeployerRequest;
 import org.codehaus.plexus.component.annotations.Component;
@@ -40,13 +42,12 @@ import org.slf4j.LoggerFactory;
 /**
  * This will deploy a whole project into the appropriate remote repository.
  * 
- * @author Karl Heinz Marbaise <a 
href="mailto:khmarba...@apache.org";>khmarba...@apache.org</a>
- *
- * Most of the code is taken from maven-dependency-plugin.
- * 
+ * @author Karl Heinz Marbaise <a 
href="mailto:khmarba...@apache.org";>khmarba...@apache.org</a> Most of the code 
is
+ *         taken from maven-dependency-plugin.
  */
 @Component( role = ProjectDeployer.class )
-public class DefaultProjectDeployer implements ProjectDeployer
+public class DefaultProjectDeployer
+    implements ProjectDeployer
 {
     private static final Logger LOGGER = LoggerFactory.getLogger( 
DefaultProjectDeployer.class );
 
@@ -54,15 +55,17 @@ public class DefaultProjectDeployer impl
     private ArtifactDeployer deployer;
 
     /**
-     * This will deploy a single project which may contain several artifacts
-     * into the appropriate remote repository.
+     * This will deploy a single project which may contain several artifacts 
into the appropriate remote repository.
      * 
      * @param buildingRequest {@link ProjectBuildingRequest}
      * @param request {@link ProjectDeployerRequest}
      * @param artifactRepository {@link ArtifactRepository}
+     * @throws IllegalArgumentException in case of artifact is not correctly 
assigned.
+     * @throws NoFileAssignedException 
      */
     public void deployProject( ProjectBuildingRequest buildingRequest, 
ProjectDeployerRequest request,
                                ArtifactRepository artifactRepository )
+        throws IOException, NoFileAssignedException
     {
         List<Artifact> deployableArtifacts = new ArrayList<Artifact>();
 
@@ -109,14 +112,14 @@ public class DefaultProjectDeployer impl
                 }
                 else if ( !attachedArtifacts.isEmpty() )
                 {
-                    //TODO: Reconsider this exception? Better Exception type?
-                    throw new IllegalArgumentException( "The packaging plugin 
for this project did not assign "
+                    // TODO: Reconsider this exception? Better Exception type?
+                    throw new NoFileAssignedException( "The packaging plugin 
for this project did not assign "
                         + "a main file to the project but it has attachments. 
Change packaging to 'pom'." );
                 }
                 else
                 {
-                    //TODO: Reconsider this exception? Better Exception type?
-                    throw new IllegalArgumentException( "The packaging for 
this project did not assign "
+                    // TODO: Reconsider this exception? Better Exception type?
+                    throw new NoFileAssignedException( "The packaging for this 
project did not assign "
                         + "a file to the build artifact" );
                 }
             }

Modified: 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java?rev=1761342&r1=1761341&r2=1761342&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
 (original)
+++ 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/ProjectInstaller.java
 Sun Sep 18 17:18:53 2016
@@ -24,6 +24,7 @@ import java.io.IOException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.shared.artifact.install.ArtifactInstallerException;
+import org.apache.maven.shared.project.NoFileAssignedException;
 
 /**
  * This defines the interface to install a single Maven Project.
@@ -39,12 +40,12 @@ public interface ProjectInstaller
      * @param projectBuildingRequest {@link ProjectBuildingRequest}
      * @param projectInstallerRequest {@link ProjectInstallerRequest}
      * @param artifactRepository {@link ArtifactRepository}
-     * @throws IOException In case of problem to install project.
+     * @throws IOException In case of problems related to checksums.
      * @throws ArtifactInstallerException In case of problems to install 
artifacts.
-     * @throws IllegalArgumentException In case of no file has been assigned. 
+     * @throws NoFileAssignedException If no file has been assigned to the 
project.
      */
     void installProject( ProjectBuildingRequest projectBuildingRequest, 
ProjectInstallerRequest projectInstallerRequest,
                          ArtifactRepository artifactRepository )
-        throws IOException, ArtifactInstallerException, 
IllegalArgumentException; 
+        throws IOException, ArtifactInstallerException, 
NoFileAssignedException;
 
 }

Modified: 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java?rev=1761342&r1=1761341&r2=1761342&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
 (original)
+++ 
maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/project/install/internal/DefaultProjectInstaller.java
 Sun Sep 18 17:18:53 2016
@@ -35,6 +35,7 @@ import org.apache.maven.project.artifact
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 import org.apache.maven.shared.artifact.install.ArtifactInstaller;
 import org.apache.maven.shared.artifact.install.ArtifactInstallerException;
+import org.apache.maven.shared.project.NoFileAssignedException;
 import org.apache.maven.shared.project.install.ProjectInstaller;
 import org.apache.maven.shared.project.install.ProjectInstallerRequest;
 import org.apache.maven.shared.repository.RepositoryManager;
@@ -64,9 +65,12 @@ public class DefaultProjectInstaller
 
     private final DualDigester digester = new DualDigester();
 
+    /**
+     * {@inheritDoc}
+     */
     public void installProject( ProjectBuildingRequest buildingRequest, 
ProjectInstallerRequest request,
                                 ArtifactRepository artifactRepository )
-        throws IOException, ArtifactInstallerException, 
IllegalArgumentException
+        throws IOException, ArtifactInstallerException, NoFileAssignedException
     {
 
         MavenProject project = request.getProject();
@@ -93,7 +97,6 @@ public class DefaultProjectInstaller
 
         if ( isPomArtifact )
         {
-            // installer.install( pomFile, artifact, localRepository );
             installer.install( buildingRequest, 
Collections.<Artifact>singletonList( new ProjectArtifact( project ) ) );
             installChecksums( buildingRequest, artifactRepository, artifact, 
createChecksum );
             addMetaDataFilesForArtifact( artifactRepository, artifact, 
metadataFiles, createChecksum );
@@ -115,20 +118,19 @@ public class DefaultProjectInstaller
             }
             else if ( !attachedArtifacts.isEmpty() )
             {
-                throw new IllegalArgumentException( "The packaging plugin for 
this project did not assign "
+                throw new NoFileAssignedException( "The packaging plugin for 
this project did not assign "
                     + "a main file to the project but it has attachments. 
Change packaging to 'pom'." );
             }
             else
             {
                 // CHECKSTYLE_OFF: LineLength
-                throw new IllegalArgumentException( "The packaging for this 
project did not assign a file to the build artifact" );
+                throw new NoFileAssignedException( "The packaging for this 
project did not assign a file to the build artifact" );
                 // CHECKSTYLE_ON: LineLength
             }
         }
 
         for ( Artifact attached : attachedArtifacts )
         {
-            // installer.install( attached.getFile(), attached, 
localRepository );
             installer.install( buildingRequest, Collections.singletonList( 
attached ) );
             installChecksums( buildingRequest, artifactRepository, attached, 
createChecksum );
             addMetaDataFilesForArtifact( artifactRepository, attached, 
metadataFiles, createChecksum );
@@ -162,8 +164,8 @@ public class DefaultProjectInstaller
     }
 
     // CHECKSTYLE_OFF: LineLength
-    protected void addMetaDataFilesForArtifact( ArtifactRepository 
artifactRepository, Artifact artifact,
-                                                Collection<File> 
targetMetadataFiles, boolean createChecksum )
+    private void addMetaDataFilesForArtifact( ArtifactRepository 
artifactRepository, Artifact artifact,
+                                              Collection<File> 
targetMetadataFiles, boolean createChecksum )
     // CHECKSTYLE_ON: LineLength
     {
         if ( !createChecksum )
@@ -188,7 +190,7 @@ public class DefaultProjectInstaller
      * @param metadataFiles The collection of metadata files to install 
checksums for, must not be <code>null</code>.
      * @throws IOException If the checksums could not be installed.
      */
-    protected void installChecksums( Collection<File> metadataFiles )
+    private void installChecksums( Collection<File> metadataFiles )
         throws IOException
     {
         for ( File metadataFile : metadataFiles )


Reply via email to