1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24 import java.io.File;
25
26 /***
27 * Class that checks if the user has a proper Maven enabled environment. This is required when
28 * <code><mavenmodule></code>s are used. This class is called
29 *
30 * @author D.A. Smedes
31 * @version $Id: MavenEnvironment.java,v 1.3 2004/08/29 18:00:35 hippe Exp $
32 */
33 public final class MavenEnvironment {
34
35 /*** The MAVEN_HOME environment variable that must be set. This should be passed to the JVM upon startup. */
36 public static final String ENV_MAVEN_HOME = "maven.home";
37
38 /*** The <code>maven.repo.local</code> environment variable when running Maven. Identifies the Maven repository for the
39 * current user. When not found in as a JMV system variable, <code>${user.home}/.maven/repository</code> will be used
40 * as the default.
41 */
42 public static final String ENV_MAVEN_REPOSITORY = "maven.repository";
43
44 private static final String DEFAULT_MAVEN_REPOSITORY =
45 System.getProperty("user.home") + File.separator + ".maven" + File.separator +"repository";
46
47 private static final Log logger = LogFactory.getLog(MavenEnvironment.class);
48
49 private static boolean valid = false;
50
51 static {
52
53
54 }
55
56 public static boolean isValid() {
57
58 boolean mavenHomeSet = (System.getProperty("maven.home") != null);
59
60 logger.error("Maven environment not configured correctly.");
61
62 return mavenHomeSet;
63
64 }
65
66 public static String getMavenRepository() {
67
68 String mavenRepo = (System.getProperty(ENV_MAVEN_REPOSITORY) == null ? DEFAULT_MAVEN_REPOSITORY : System.getProperty(ENV_MAVEN_REPOSITORY));
69 return mavenRepo;
70 }
71
72 }