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 javax.inject.Inject;
23  import javax.inject.Named;
24  import javax.inject.Singleton;
25  
26  import java.util.List;
27  import java.util.Map;
28  
29  import org.apache.maven.project.MavenProject;
30  import org.apache.maven.shared.release.ReleaseExecutionException;
31  import org.apache.maven.shared.release.ReleaseResult;
32  import org.apache.maven.shared.release.config.ReleaseDescriptor;
33  import org.apache.maven.shared.release.env.ReleaseEnvironment;
34  import org.apache.maven.shared.release.exec.MavenExecutor;
35  
36  /**
37   * Run a build of the project (eventually with the integration tests) to verify that it builds before committing.
38   *
39   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
40   */
41  @Singleton
42  @Named( "run-preparation-goals" )
43  public class RunPrepareGoalsPhase
44          extends AbstractRunGoalsPhase
45  {
46      @Inject
47      public RunPrepareGoalsPhase( Map<String, MavenExecutor> mavenExecutors )
48      {
49          super( mavenExecutors );
50      }
51  
52      @Override
53      public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment,
54                                    List<MavenProject> reactorProjects )
55              throws ReleaseExecutionException
56      {
57          return execute( releaseDescriptor, releaseEnvironment, reactorProjects, false );
58      }
59  
60      @Override
61      public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment,
62                                     List<MavenProject> reactorProjects )
63              throws ReleaseExecutionException
64      {
65          ReleaseResult result = new ReleaseResult();
66  
67          logInfo( result, "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      {
78          return releaseDescriptor.getPreparationGoals();
79      }
80  }