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 ev...@apache.org on 2005/02/18 15:32:27 UTC

cvs commit: maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy AbstractDeployMojo.java DeployMojo.java DeployPomMojo.java

evenisse    2005/02/18 06:32:27

  Modified:    maven-mboot2/src/main/java MBoot.java
  Added:       maven-plugins/maven-deploy-plugin .cvsignore pom.xml
               maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy
                        AbstractDeployMojo.java DeployMojo.java
                        DeployPomMojo.java
  Log:
  Add a little deploy plugin
  
  Revision  Changes    Path
  1.44      +1 -0      maven-components/maven-mboot2/src/main/java/MBoot.java
  
  Index: MBoot.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-mboot2/src/main/java/MBoot.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- MBoot.java	9 Jan 2005 22:38:43 -0000	1.43
  +++ MBoot.java	18 Feb 2005 14:32:27 -0000	1.44
  @@ -89,6 +89,7 @@
       {
           "maven-plugins/maven-clean-plugin",
           "maven-plugins/maven-compiler-plugin",
  +        "maven-plugins/maven-deploy-plugin",
           "maven-plugins/maven-install-plugin",
           "maven-plugins/maven-jar-plugin",
           "maven-plugins/maven-plugin-plugin",
  
  
  
  1.1                  maven-components/maven-plugins/maven-deploy-plugin/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  target
  *~
  *.log
  .classpath
  .project
  *.ipr
  *.iws
  *.iml
  
  
  
  1.1                  maven-components/maven-plugins/maven-deploy-plugin/pom.xml
  
  Index: pom.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <project>
    <modelVersion>4.0.0</modelVersion>
    <parent>
      <groupId>maven</groupId>
      <artifactId>maven-plugin-parent</artifactId>
      <version>2.0-SNAPSHOT</version>
    </parent>
    <groupId>maven</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <type>plugin</type>  
    <name>Maven Deploy Plugin</name>
    <version>1.0-SNAPSHOT</version>
    <inceptionYear>2004</inceptionYear>
    <package>org.apache.maven.plugin.deploy</package>
    <dependencies>
      <dependency>
        <groupId>maven</groupId>
        <artifactId>maven-core</artifactId>
        <version>2.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>maven</groupId>
        <artifactId>maven-model</artifactId>
        <version>2.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>maven</groupId>
        <artifactId>maven-artifact</artifactId>
        <version>2.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>maven</groupId>
        <artifactId>wagon-api</artifactId>
        <version>1.0-alpha-1-SNAPSHOT</version>
      </dependency>
    </dependencies>
  </project>
  
  
  
  1.1                  maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
  
  Index: AbstractDeployMojo.java
  ===================================================================
  package org.apache.maven.plugin.deploy;
  
  /*
   * Copyright 2001-2005 The Apache Software Foundation.
   *
   * Licensed 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.plugin.AbstractPlugin;
  import org.apache.maven.plugin.PluginExecutionRequest;
  import org.apache.maven.plugin.PluginExecutionResponse;
  import org.apache.maven.project.MavenProject;
  import org.apache.maven.artifact.deployer.ArtifactDeployer;
  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 java.io.File;
  
  /**
   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
   * @version $Id: AbstractDeployMojo.java,v 1.1 2005/02/18 14:32:27 evenisse Exp $
   */
  public abstract class AbstractDeployMojo
      extends AbstractPlugin
  {
  
      protected boolean isPom()
      {
          return false;
      }
  
      public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
          throws Exception
      {
          MavenProject project = (MavenProject) request.getParameter( "project" );
  
          ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" );
  
          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( repository );
  
          if ( isPom() )
          {
              Artifact artifact = new DefaultArtifact( project.getGroupId(),
                                                       project.getArtifactId(),
                                                       project.getVersion(),
                                                       "pom" );
  
              File pom = new File( project.getFile().getParentFile(), "pom.xml" );
  
              artifactDeployer.deploy( pom, artifact, deploymentRepository );
          }
          else
          {
              Artifact artifact = new DefaultArtifact( project.getGroupId(),
                                                       project.getArtifactId(),
                                                       project.getVersion(),
                                                       project.getType() );
  
              artifactDeployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository );
          }
      }
  }
  
  
  
  1.1                  maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
  
  Index: DeployMojo.java
  ===================================================================
  package org.apache.maven.plugin.deploy;
  
  /*
   * Copyright 2001-2005 The Apache Software Foundation.
   *
   * Licensed 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.
   */
  
  /**
   * @goal deploy
   *
   * @description deploys an artifact to remote repository
   *
   * @parameter
   *  name="project"
   *  type="org.apache.maven.project.MavenProject"
   *  required="true"
   *  validator=""
   *  expression="#project"
   *  description=""
   *
   * @parameter
   *  name="deployer"
   *  type="org.apache.maven.artifact.deployer.ArtifactDeployer"
   *  required="true"
   *  validator=""
   *  expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
   *  description=""
   *
   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
   * @version $Id: DeployMojo.java,v 1.1 2005/02/18 14:32:27 evenisse Exp $
   */
  public class DeployMojo
      extends AbstractDeployMojo
  {
  }
  
  
  
  1.1                  maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployPomMojo.java
  
  Index: DeployPomMojo.java
  ===================================================================
  package org.apache.maven.plugin.deploy;
  
  /*
   * Copyright 2001-2005 The Apache Software Foundation.
   *
   * Licensed 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.
   */
  
  /**
   * @goal pom
   *
   * @description deploys an artifact to remote repository
   *
   * @parameter
   *  name="project"
   *  type="org.apache.maven.project.MavenProject"
   *  required="true"
   *  validator=""
   *  expression="#project"
   *  description=""
   *
   * @parameter
   *  name="deployer"
   *  type="org.apache.maven.artifact.deployer.ArtifactDeployer"
   *  required="true"
   *  validator=""
   *  expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
   *  description=""
   *
   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
   * @version $Id: DeployPomMojo.java,v 1.1 2005/02/18 14:32:27 evenisse Exp $
   */
  public class DeployPomMojo
      extends AbstractDeployMojo
  {
      protected boolean isPom()
      {
          return true;
      }
  }