jvanzyl 2002/11/24 09:58:20
Modified: src/java/org/apache/maven/cli App.java
Log:
refactoring
Revision Changes Path
1.3 +36 -99 jakarta-turbine-maven/src/java/org/apache/maven/cli/App.java
Index: App.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/cli/App.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- App.java 15 Nov 2002 23:56:26 -0000 1.2
+++ App.java 24 Nov 2002 17:58:20 -0000 1.3
@@ -206,11 +206,16 @@
private File descriptorDirectory;
/** Constructor. */
- public App(Maven maven)
+ public App()
{
- this.maven = maven;
}
-
+
+ /** Set the Maven instance. */
+ public void setMaven(Maven maven)
+ {
+ this.maven = maven;
+ }
+
/** Get the Maven instance. */
public Maven getMaven()
{
@@ -252,7 +257,7 @@
log.debug("Initializing core.");
commandLine = CLIManager.parse(args);
-
+
if (getCli().hasOption(FIND_POM_DESCRIPTOR))
{
File file = find (getCli().getOptionValue(FIND_POM_DESCRIPTOR));
@@ -299,7 +304,10 @@
setCliProperty(defStrs[i]);
}
}
-
+
+ // Create the MavenJellyContext
+ getMaven().setContext(MavenUtils.createContext(getDescriptorDirectory()));
+
initializeIO();
System.setProperty("user.dir", getDescriptorDirectory().getPath());
@@ -356,7 +364,7 @@
private void checkOnline()
{
- if (getMaven().getProperty(MavenConstants.ONLINE) != null)
+ if (getMaven().getVariable(MavenConstants.ONLINE) != null)
{
return;
}
@@ -466,7 +474,6 @@
try
{
- getMaven().initializeJelly();
checkOnline();
getMaven().runtimeInitialization();
@@ -586,7 +593,7 @@
System.err.println(msg);
- if (getCli().hasOption("X"))
+ if (getCli().hasOption(DEBUG_X))
{
e.printStackTrace();
}
@@ -630,18 +637,33 @@
System.out.println("");
System.exit(returnCode);
}
-
+
+ /**
+ * From the CWD search through the directory hierarchy for
+ * an XML-based POM.
+ *
+ * @param filename
+ */
private File find (String filename)
{
// An empty string should resolve to the current directory (user.dir)
return find (new File (""), filename);
}
+ /**
+ * From the CWD search through the directory hierarchy for
+ * an XML-based POM.
+ *
+ * @param filename
+ * @param suffix
+ */
private File find (File start, String suffix)
{
- if (start == null) {
+ if (start == null)
+ {
return null;
}
+
File dir = start.getAbsoluteFile();
File file = new File(dir, suffix);
@@ -972,100 +994,15 @@
// P R O P E R T I E S M E T H O D S
// ------------------------------------------------------------
- /**
- * Process properties in dominant order.
- */
- private MavenJellyContext createMavenJellyContext()
- {
- // We are listing the properties in the dominant order.
-
- Properties systemProperties = System.getProperties();
-
- Properties userBuildProperties = loadProperties(
- new File( System.getProperty("user.home"), "build.properties" ));
-
- Properties projectBuildProperties = loadProperties(
- new File( getDescriptorDirectory(), "build.properties" ));
-
- Properties projectProperties = loadProperties(
- new File( getDescriptorDirectory(), "project.properties" ));
-
- Properties driverProperties = loadProperties(
- App.class.getClassLoader().getResourceAsStream(
- MavenConstants.DRIVER_PROPERTIES));
-
- Map result = MavenUtils.mergeMaps( new Map[]
- {
- systemProperties,
- userBuildProperties,
- projectBuildProperties,
- projectProperties,
- driverProperties
- });
-
- MavenJellyContext context = new MavenJellyContext();
- MavenUtils.integrateMapInContext(result, context);
-
- return context;
- }
-
- /**
- * Load properties from a <code>File</code>.
- */
- private Properties loadProperties(File file)
- {
- try
- {
- return loadProperties(new FileInputStream(file));
- }
- catch(Exception e)
- {
- // ignore
- }
-
- return null;
- }
-
- /**
- * Load properties from an <code>InputStream</code>.
- */
- private Properties loadProperties(InputStream is)
- {
- try
- {
- Properties properties = new Properties();
- properties.load(is);
- return properties;
- }
- catch (IOException e)
- {
- // ignore
- }
- finally
- {
- try
- {
- if (is != null)
- {
- is.close();
- }
- }
- catch (IOException e)
- {
- // ignore
- }
- }
-
- return null;
- }
-
public static void main(String[] args)
{
Date start = new Date();
File mavenHome = new File(System.getProperty(MavenConstants.HOME));
Maven maven = new Maven();
maven.setMavenHome(mavenHome);
- App app = new App(maven);
+
+ App app = new App();
+ app.setMaven(maven);
app.doMain(args, start);
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>