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 java.io.File;
22  
23  import org.apache.maven.project.MavenProject;
24  import org.apache.maven.shared.release.util.ReleaseUtil;
25  
26  /**
27   * <p>Abstract AbstractBackupPomsPhase class.</p>
28   *
29   * @author Edwin Punzalan
30   */
31  public abstract class AbstractBackupPomsPhase extends AbstractReleasePhase {
32      protected static final String BACKUP_SUFFIX = ".releaseBackup";
33  
34      /**
35       * <p>getPomBackup.</p>
36       *
37       * @param project a {@link org.apache.maven.project.MavenProject} object
38       * @return a {@link java.io.File} object
39       */
40      protected File getPomBackup(MavenProject project) {
41          File pomFile = ReleaseUtil.getStandardPom(project);
42  
43          if (pomFile != null) {
44              return new File(pomFile.getAbsolutePath() + BACKUP_SUFFIX);
45          } else {
46              return null;
47          }
48      }
49  
50      /**
51       * <p>deletePomBackup.</p>
52       *
53       * @param project a {@link org.apache.maven.project.MavenProject} object
54       */
55      protected void deletePomBackup(MavenProject project) {
56          File pomBackup = getPomBackup(project);
57  
58          if (pomBackup != null && pomBackup.exists()) {
59              pomBackup.delete();
60          }
61      }
62  }