View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.shared.release.phase;
20  
21  import javax.inject.Inject;
22  import javax.inject.Named;
23  import javax.inject.Singleton;
24  
25  import java.util.List;
26  import java.util.Map;
27  
28  import org.apache.maven.project.MavenProject;
29  import org.apache.maven.shared.release.ReleaseExecutionException;
30  import org.apache.maven.shared.release.ReleaseResult;
31  import org.apache.maven.shared.release.config.ReleaseDescriptor;
32  import org.apache.maven.shared.release.env.ReleaseEnvironment;
33  import org.apache.maven.shared.release.exec.MavenExecutor;
34  
35  /**
36   * Run the completion goals for the project to before committing the continuing development stream.
37   *
38   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
39   * @author <a href="mailto:stephenc@apache.org">Stephen Connolly</a>
40   */
41  @Singleton
42  @Named("run-completion-goals")
43  public class RunCompleteGoalsPhase extends AbstractRunGoalsPhase {
44      @Inject
45      public RunCompleteGoalsPhase(Map<String, MavenExecutor> mavenExecutors) {
46          super(mavenExecutors);
47      }
48  
49      @Override
50      public ReleaseResult execute(
51              ReleaseDescriptor releaseDescriptor,
52              ReleaseEnvironment releaseEnvironment,
53              List<MavenProject> reactorProjects)
54              throws ReleaseExecutionException {
55          return execute(releaseDescriptor, releaseEnvironment, reactorProjects, false);
56      }
57  
58      @Override
59      public ReleaseResult simulate(
60              ReleaseDescriptor releaseDescriptor,
61              ReleaseEnvironment releaseEnvironment,
62              List<MavenProject> reactorProjects)
63              throws ReleaseExecutionException {
64          ReleaseResult result = new ReleaseResult();
65  
66          logInfo(
67                  result,
68                  "Executing completion goals - since this is simulation mode it is running against the "
69                          + "original project, not the rewritten ones");
70  
71          execute(releaseDescriptor, releaseEnvironment, reactorProjects, true);
72  
73          return result;
74      }
75  
76      @Override
77      protected String getGoals(ReleaseDescriptor releaseDescriptor) {
78          return releaseDescriptor.getCompletionGoals();
79      }
80  }