You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by mi...@apache.org on 2005/01/18 21:44:53 UTC

cvs commit: maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar JarDeployMojo.java

michal      2005/01/18 12:44:53

  Modified:    maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar
                        JarDeployMojo.java
  Log:
  better error handling
  
  Revision  Changes    Path
  1.4       +26 -1     maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarDeployMojo.java
  
  Index: JarDeployMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarDeployMojo.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JarDeployMojo.java	9 Aug 2004 19:10:10 -0000	1.3
  +++ JarDeployMojo.java	18 Jan 2005 20:44:53 -0000	1.4
  @@ -25,6 +25,8 @@
   import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.artifact.Artifact;
   import org.apache.maven.artifact.DefaultArtifact;
  +import org.apache.maven.model.Repository;
  +import org.apache.maven.model.DistributionManagement;
   import org.apache.maven.repository.RepositoryUtils;
   import org.codehaus.plexus.util.FileUtils;
   
  @@ -61,8 +63,31 @@
   
           ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" );
   
  +        
  +        //@todo this will be duplicated in case of every mojo which implements deploy goal
  +        // this should be pushed into the ArtifactDeployer component
  +        DistributionManagement distributionManagement = project.getDistributionManagement();
  +        
  +        if ( distributionManagement == null )
  +        {
  +            String msg = "Deployment failed: distributionManagement element" + 
  +                            " was not specified in the pom";
  +            throw new Exception( msg );
  +        }
  +        
  +        Repository repository = distributionManagement.getRepository();
  +        
  +        if ( repository == null )
  +        {
  +            String msg = "Deployment failed: repository element" + 
  +                            " was not specified in the pom inside" + 
  +                            " distributionManagement element";
  +            throw new Exception( msg );
  +         }
  +        
  +        
           ArtifactRepository deploymentRepository =
  -            RepositoryUtils.mavenRepositoryToWagonRepository( project.getDistributionManagement().getRepository() );
  +            RepositoryUtils.mavenRepositoryToWagonRepository( repository );
   
           Artifact artifact = new DefaultArtifact( project.getGroupId(),
                                                    project.getArtifactId(),