View Javadoc
1   package org.apache.maven.plugins.release;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.plugins.annotations.Mojo;
23  import org.apache.maven.plugins.annotations.Parameter;
24  import org.codehaus.plexus.util.StringUtils;
25  
26  /**
27   * Perform a release from SCM to a staging repository.
28   *
29   * If no goals are given, these default to <code>deploy</code> or <code>deploy site:stage-deploy</code>,
30   * if the project has a &lt;distributionManagement&gt;/&lt;site&gt; element.
31   *
32   * If the goals contain <code>site-deploy</code> or <code>site:deploy</code>, these
33   * are overridden with <code>site:stage-deploy</code>.
34   * 
35   * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
36   * @version $Id: StageReleaseMojo.java 1672754 2015-04-10 20:27:09Z mfriedenhagen $
37   * @since 2.0-beta-8
38   */
39  @Mojo( name = "stage", aggregator = true, requiresProject = false )
40  public class StageReleaseMojo
41      extends PerformReleaseMojo
42  {
43      /**
44       * URL of the staging repository to use.
45       * 
46       * @since 2.0-beta-8
47       */
48      @Parameter( property = "stagingRepository", required = true )
49      private String stagingRepository;
50  
51      @Override
52      void createGoals()
53      {
54          if ( goals == null )
55          {
56              // set default
57              goals = "deploy";
58              if ( project.getDistributionManagement() != null
59                  && project.getDistributionManagement().getSite() != null )
60              {
61                  goals += " site:stage-deploy";
62              }
63          }
64  
65          goals = StringUtils.replace( goals, "site-deploy", "site:stage-deploy" );
66          goals = StringUtils.replace( goals, "site:deploy", "site:stage-deploy" );
67      }
68  
69      @Override
70      void setDeploymentRepository()
71      {
72          addArgument( "-DaltDeploymentRepository=\"" + stagingRepository + "\"" );
73      }
74  }