jvanzyl 2002/11/11 16:41:06
Modified: src/java/org/apache/maven/app App.java Maven.java
MavenJellyContext.java
Log:
o Getting rid of get/setProjectFileName(). Working toward just handing
Maven and instantiated Project and let it run with it. Let the wrappers
for the various environments like CLI and Continuum deal with retrieving
the instance using MavenUtils or whatever means the wrapper sees fit.
Revision Changes Path
1.27 +39 -19 jakarta-turbine-maven/src/java/org/apache/maven/app/App.java
Index: App.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/App.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- App.java 11 Nov 2002 23:17:41 -0000 1.26
+++ App.java 12 Nov 2002 00:41:05 -0000 1.27
@@ -106,34 +106,54 @@
*/
public class App
{
- /** Log. */
- private static final Log log = LogFactory.getLog(App.class);
-
+ // ------------------------------------------------------------
+ // C O N S T A N T S
+ // ------------------------------------------------------------
+
/** Default console width - for formatting output - 78 */
private static final int CONSOLE_WIDTH = 80;
+
/** return code for ok processing */
private static final int RC_OK = 0;
+
/** return code from command prompt when a bad argument is passed */
private static final int RC_BAD_ARG = 10;
+
/** return code from command prompt when initialization fails */
private static final int RC_INIT_ERROR = 20;
+
/** return code from command prompt when a goal isn't found */
private static final int RC_NO_GOAL = 30;
+
/** return code for bad repository configuration */
private static final int RC_BAD_REPO = 40;
+
/** return code for a goal with no actions */
private static final int RC_EMPTY_GOAL = 50;
+
/** return code for a goal that failed */
private static final int RC_GOAL_FAILED = 60;
+
/** return code for a goal failed from jelly exception being thrown */
private static final int RC_JELLY_FAILED = 70;
+
/** return code for a failure due to Jelly issues */
private static final int RC_BAD_JELLY = 80;
+
/** return code for a failure due to anything else */
private static final int RC_OTHER_FAILURE = 90;
+
+ /** Log. */
+ private static final Log log = LogFactory.getLog(App.class);
- private Maven maven;
+ // ------------------------------------------------------------
+ // I N S T A N C E M E M B E R S
+ // ------------------------------------------------------------
+ /** Maven instance. */
+ private Maven maven;
+
+ /** CLI Parser */
private CommandLine commandLine;
/** Saved original console System.out. */
@@ -144,17 +164,20 @@
/** Jelly's underlying writer. */
private Writer writer;
-
+
+ /** Constructor. */
public App(Maven maven)
{
this.maven = maven;
}
-
+
+ /** Get the Maven instance. */
public Maven getMaven()
{
return this.maven;
}
+ /** Get the CLI parser. */
protected CommandLine getCli()
{
return this.commandLine;
@@ -181,15 +204,15 @@
if (getCli().hasOption("f"))
{
File file = find (getCli().getOptionValue("f"));
- if (file != null) {
+ if (file != null)
+ {
getMaven().setDir (file.getParentFile());
- getMaven().setProjectFileName(file.getAbsolutePath());
+ getMaven().setProjectFile(file);
}
- else {
- getMaven().setProjectFileName(getCli().getOptionValue("f"));
+ else
+ {
+ getMaven().setProjectFile(new File(getCli().getOptionValue("f")));
}
- getMaven().setProjectFile(
- new File(getMaven().getProjectFileName()));
}
getMaven().addGoalNames(getCli().getArgList());
@@ -205,15 +228,12 @@
if (getCli().hasOption("p"))
{
- getMaven().setProjectFileName(getCli().getOptionValue("p"));
- getMaven().setProjectFile(
- new File(getMaven().getProjectFileName()));
+ getMaven().setProjectFile(new File(getCli().getOptionValue("p")));
}
else if (!getCli().hasOption("f"))
{
- getMaven().setProjectFileName(Maven.PROJECT_DESCRIPTOR_FILE_NAME);
- getMaven().setProjectFile(
- new File(getMaven().getDir(), getMaven().getProjectFileName()));
+ getMaven().setProjectFile( new File(getMaven().getDir(),
+ Maven.PROJECT_DESCRIPTOR_FILE_NAME));
}
if (getCli().hasOption("D"))
1.125 +9 -48 jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java
Index: Maven.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- Maven.java 11 Nov 2002 23:51:23 -0000 1.124
+++ Maven.java 12 Nov 2002 00:41:05 -0000 1.125
@@ -165,9 +165,6 @@
/** ${basedir}/project.xml file. */
private File projectFile;
- /** Project file name like project.xml or project-b5.xml */
- private String projectFileName;
-
/** ${basedir}/build.maven file (or null). */
private File projectBuildFile;
@@ -235,24 +232,6 @@
return this.projectFile;
}
- /** Set the project descriptor file name.
- *
- * @param projectFileName The project descriptor file name.
- */
- public void setProjectFileName(String projectFileName)
- {
- this.projectFileName = projectFileName;
- }
-
- /** Retrieve the project descriptor file name.
- *
- * @return The project descriptor file name.
- */
- public String getProjectFileName()
- {
- return this.projectFileName;
- }
-
/** Set the project-specific build file.
*
* @see #hasProjectBuildFile
@@ -339,12 +318,8 @@
public void setDir(File dir)
{
this.dir = dir;
-
- System.setProperty( "user.dir",
- dir.getPath() );
-
- setProjectBuildFile( new File( dir,
- PROJECT_BUILD_FILE_NAME ) );
+ System.setProperty( "user.dir", dir.getPath() );
+ setProjectBuildFile( new File( dir, PROJECT_BUILD_FILE_NAME ) );
}
/** Retrieve the project directory.
@@ -648,6 +623,7 @@
{
File parentProjectFile = new File(projectDir, parentProjectStr);
File parentProjectDir = parentProjectFile.getParentFile();
+
try
{
Project parentProject = MavenUtils.getProject(parentProjectFile);
@@ -730,9 +706,7 @@
*
* <ul>
* <li>maven.home</li>
- * <li>maven.bin</li>
* <li>maven.project.buildFile.url</li>
- * <li>projectFileName</li>
* </ul>
* </p>
*
@@ -751,15 +725,6 @@
getJellyContext().setVariable(MavenJellyContext.MAVEN_BUILD_FILE_URL,
getProjectBuildFile().toURL());
}
-
- //!! Can probably get rid of all this crap. jvz.
-
- getJellyContext().setVariable("projectFileName", getProjectFileName());
-
- HashMap toolbox = new HashMap();
- toolbox.put("StringUtils", new StringUtils());
-
- getJellyContext().setVariable("toolbox", toolbox);
}
/** Initialize the core <code>jeez</code> Jelly tag library.
@@ -835,18 +800,14 @@
listener.setEmacsMode( emacsMode );
getAntProject().addBuildListener( listener );
}
-
+
+ /** Return an InputStream found in the classpath. Used
+ * specifically to find resources stored in the maven.jar
+ */
private InputStream getResourceAsStream(String name)
throws Exception
{
- InputStream is = Maven.class.getClassLoader().getResourceAsStream(name);
-
- if (is == null)
- {
- System.out.println(name + " is null");
- }
-
- return is;
+ return Maven.class.getClassLoader().getResourceAsStream(name);
}
/**
1.29 +9 -3
jakarta-turbine-maven/src/java/org/apache/maven/app/MavenJellyContext.java
Index: MavenJellyContext.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/MavenJellyContext.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- MavenJellyContext.java 11 Nov 2002 23:17:41 -0000 1.28
+++ MavenJellyContext.java 12 Nov 2002 00:41:05 -0000 1.29
@@ -86,22 +86,28 @@
{
/** Maven object context tag **/
public static final String MAVEN_OBJECT = "maven.obj";
+
/** Maven home context tag **/
public static final String MAVEN_HOME = "maven.home";
- /** Maven bin context tag **/
- public static final String MAVEN_BIN = "maven.bin";
+
/** Maven build file url context tag **/
public static final String MAVEN_BUILD_FILE_URL = "maven.project.buildFile.url";
+
/** Maven ant project context tag **/
public static final String MAVEN_ANT_PROJECT = "maven.ant.project";
+
/** Maven POM context tag **/
public static final String MAVEN_POM = "pom";
+
/** Maven goals context tag **/
public static final String MAVEN_GOALS = "goals";
+
/** Maven project verifier context tag **/
public static final String MAVEN_PROJECT_VERIFIER = "maven.project.verifier";
+
/** Werkz project context tag **/
public static final String WERKZ_PROJECT =
"org.apache.commons.jelly.werkz.Project";
+
/** Reactor projects context tag **/
public static final String REACTOR_PROJECT = "reactorProjects";
--
To unsubscribe, e-mail: <mailto:turbine-maven-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-maven-dev-help@;jakarta.apache.org>