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.env;
20  
21  import java.io.File;
22  
23  import org.apache.maven.settings.Settings;
24  
25  /**
26   * <p>DefaultReleaseEnvironment class.</p>
27   */
28  public class DefaultReleaseEnvironment implements ReleaseEnvironment {
29      private File mavenHome;
30  
31      private File javaHome;
32  
33      private File localRepositoryDirectory;
34  
35      private Settings settings;
36  
37      private String mavenExecutorId = DEFAULT_MAVEN_EXECUTOR_ID;
38  
39      @Override
40      public File getMavenHome() {
41          return mavenHome;
42      }
43  
44      @Override
45      public Settings getSettings() {
46          return settings;
47      }
48  
49      /**
50       * <p>Setter for the field <code>mavenHome</code>.</p>
51       *
52       * @param mavenHome a {@link java.io.File} object
53       * @return a {@link org.apache.maven.shared.release.env.DefaultReleaseEnvironment} object
54       */
55      public DefaultReleaseEnvironment setMavenHome(File mavenHome) {
56          this.mavenHome = mavenHome;
57          return this;
58      }
59  
60      /**
61       * <p>Setter for the field <code>settings</code>.</p>
62       *
63       * @param settings a {@link org.apache.maven.settings.Settings} object
64       * @return a {@link org.apache.maven.shared.release.env.DefaultReleaseEnvironment} object
65       */
66      public DefaultReleaseEnvironment setSettings(Settings settings) {
67          this.settings = settings;
68          return this;
69      }
70  
71      @Override
72      public String getMavenExecutorId() {
73          return mavenExecutorId;
74      }
75  
76      /**
77       * <p>Setter for the field <code>mavenExecutorId</code>.</p>
78       *
79       * @param mavenExecutorId a {@link java.lang.String} object
80       * @return a {@link org.apache.maven.shared.release.env.DefaultReleaseEnvironment} object
81       */
82      public DefaultReleaseEnvironment setMavenExecutorId(String mavenExecutorId) {
83          this.mavenExecutorId = mavenExecutorId;
84          return this;
85      }
86  
87      @Override
88      public File getJavaHome() {
89          return javaHome;
90      }
91  
92      /**
93       * <p>Setter for the field <code>javaHome</code>.</p>
94       *
95       * @param javaHome a {@link java.io.File} object
96       * @return a {@link org.apache.maven.shared.release.env.DefaultReleaseEnvironment} object
97       */
98      public DefaultReleaseEnvironment setJavaHome(File javaHome) {
99          this.javaHome = javaHome;
100         return this;
101     }
102 
103     @Override
104     public File getLocalRepositoryDirectory() {
105         File localRepo = localRepositoryDirectory;
106 
107         if (localRepo == null && settings != null && settings.getLocalRepository() != null) {
108             localRepo = new File(settings.getLocalRepository()).getAbsoluteFile();
109         }
110 
111         return localRepo;
112     }
113 
114     /**
115      * <p>Setter for the field <code>localRepositoryDirectory</code>.</p>
116      *
117      * @param localRepositoryDirectory a {@link java.io.File} object
118      * @return a {@link org.apache.maven.shared.release.env.DefaultReleaseEnvironment} object
119      */
120     public DefaultReleaseEnvironment setLocalRepositoryDirectory(File localRepositoryDirectory) {
121         this.localRepositoryDirectory = localRepositoryDirectory;
122         return this;
123     }
124 }