View Javadoc
1   package org.apache.maven.shared.release.phase;
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 java.util.List;
23  
24  import org.apache.maven.project.MavenProject;
25  import org.apache.maven.shared.release.ReleaseExecutionException;
26  import org.apache.maven.shared.release.ReleaseFailureException;
27  import org.apache.maven.shared.release.ReleaseResult;
28  import org.apache.maven.shared.release.config.ReleaseDescriptor;
29  import org.apache.maven.shared.release.env.ReleaseEnvironment;
30  
31  /**
32   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
33   * @version $Id: CheckCompletedPreparePhasesPhase.java 1643023 2014-12-02 23:42:32Z hboutemy $
34   * @plexus.component role="org.apache.maven.shared.release.phase.ReleasePhase"
35   *                   role-hint="verify-completed-prepare-phases"
36   */
37  public class CheckCompletedPreparePhasesPhase
38      extends AbstractReleasePhase
39  {
40      public ReleaseResult execute( ReleaseDescriptor releaseDescriptor,
41                                    ReleaseEnvironment releaseEnvironment,
42                                    List<MavenProject> reactorProjects )
43          throws ReleaseExecutionException, ReleaseFailureException
44      {
45          ReleaseResult result = new ReleaseResult();
46  
47          // if we stopped mid-way through preparation - don't perform
48          if ( releaseDescriptor.getCompletedPhase() != null
49               && !"end-release".equals( releaseDescriptor.getCompletedPhase() ) )
50          {
51              String message = "Cannot perform release - the preparation step was stopped mid-way. Please re-run "
52                               + "release:prepare to continue, or perform the release from an SCM tag.";
53  
54              result.setResultCode( ReleaseResult.ERROR );
55  
56              logError( result, message );
57  
58              throw new ReleaseFailureException( message );
59          }
60  
61          if ( releaseDescriptor.getScmSourceUrl() == null )
62          {
63              String message = "No SCM URL was provided to perform the release from";
64  
65              result.setResultCode( ReleaseResult.ERROR );
66  
67              logError( result, message );
68  
69              throw new ReleaseFailureException( message );
70          }
71  
72          result.setResultCode( ReleaseResult.SUCCESS );
73  
74          return result;
75      }
76  
77      public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor,
78                                     ReleaseEnvironment releaseEnvironment,
79                                     List<MavenProject> reactorProjects )
80          throws ReleaseExecutionException, ReleaseFailureException
81      {
82          return execute( releaseDescriptor, releaseEnvironment, reactorProjects );
83      }
84  }