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 a build of the project (eventually with the integration tests) to verify that it builds before committing.
37   *
38   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
39   */
40  @Singleton
41  @Named("run-preparation-goals")
42  public class RunPrepareGoalsPhase extends AbstractRunGoalsPhase {
43      @Inject
44      public RunPrepareGoalsPhase(Map<String, MavenExecutor> mavenExecutors) {
45          super(mavenExecutors);
46      }
47  
48      @Override
49      public ReleaseResult execute(
50              ReleaseDescriptor releaseDescriptor,
51              ReleaseEnvironment releaseEnvironment,
52              List<MavenProject> reactorProjects)
53              throws ReleaseExecutionException {
54          return execute(releaseDescriptor, releaseEnvironment, reactorProjects, false);
55      }
56  
57      @Override
58      public ReleaseResult simulate(
59              ReleaseDescriptor releaseDescriptor,
60              ReleaseEnvironment releaseEnvironment,
61              List<MavenProject> reactorProjects)
62              throws ReleaseExecutionException {
63          ReleaseResult result = new ReleaseResult();
64  
65          logInfo(
66                  result,
67                  "Executing preparation goals - since this is simulation mode it is running against the "
68                          + "original project, not the rewritten ones");
69  
70          execute(releaseDescriptor, releaseEnvironment, reactorProjects, true);
71  
72          return result;
73      }
74  
75      @Override
76      protected String getGoals(ReleaseDescriptor releaseDescriptor) {
77          return releaseDescriptor.getPreparationGoals();
78      }
79  }