jvanzyl 2002/11/11 15:17:42
Modified: . build-bootstrap.xml maven.xml project.properties
project.xml
src/java/org/apache/maven/app App.java Maven.java
MavenJellyContext.java
src/java/org/apache/maven/jelly/tags/project MavenTag.java
src/java/org/apache/maven/util JellyUtils.java
src/plugins-build/reactor/src/java/org/apache/maven/reactor
ReactorTag.java
src/test/java/org/apache/maven/project
ProjectInheritanceTest.java
Log:
o First shot at trying to fully contain Maven's logic inside
the Maven bean. Got rid of the notion of ${maven.home}/bin
inside the Maven bean to start getting rid of filesystem
notions. Trying to embed Maven and also trying to make
a long-lived process and many things are getting in the way.
Revision Changes Path
1.174 +7 -4 jakarta-turbine-maven/build-bootstrap.xml
Index: build-bootstrap.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/build-bootstrap.xml,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -r1.173 -r1.174
--- build-bootstrap.xml 7 Nov 2002 16:23:05 -0000 1.173
+++ build-bootstrap.xml 11 Nov 2002 23:17:40 -0000 1.174
@@ -79,10 +79,12 @@
</src>
</javac>
- <copy
- todir="${maven.bootstrap.phase1.classes}"
- file="src/conf/log4j.properties"
- />
+ <copy todir="${maven.bootstrap.phase1.classes}">
+ <fileset dir="src/conf">
+ <include name="*.properties"/>
+ <include name="*.jelly"/>
+ </fileset>
+ </copy>
<echo>
+------------------------------------------------------------------+
@@ -96,6 +98,7 @@
<fileset dir="${maven.bootstrap.phase1.classes}">
<include name="**/*.class"/>
<include name="**/*.properties"/>
+ <include name="**/*.jelly"/>
<exclude name="**/package.html"/>
</fileset>
</jar>
1.55 +7 -0 jakarta-turbine-maven/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/maven.xml,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- maven.xml 30 Oct 2002 14:09:09 -0000 1.54
+++ maven.xml 11 Nov 2002 23:17:40 -0000 1.55
@@ -388,5 +388,12 @@
</j:if>
</postGoal>
-->
+
+ <!--
+ <preGoal name="java:jar">
+ <echo>!!!! ${pom.getDependencyPath('forehead')}</echo>
+ <copy todir="${maven.build.dest}" file="${pom.getDependencyPath('forehead')}"/>
+ </preGoal>
+ -->
</project>
1.30 +2 -0 jakarta-turbine-maven/project.properties
Index: project.properties
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/project.properties,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- project.properties 21 Sep 2002 14:58:36 -0000 1.29
+++ project.properties 11 Nov 2002 23:17:40 -0000 1.30
@@ -23,6 +23,8 @@
# Display the maven version the web site is documenting
maven.xdoc.version = ${pom.currentVersion}
+maven.jar.manifest = manifest.mf
+
# -------------------------------------------------------------------
# T E S T I N G
# -------------------------------------------------------------------
1.216 +2 -0 jakarta-turbine-maven/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/project.xml,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -r1.215 -r1.216
--- project.xml 6 Nov 2002 17:58:58 -0000 1.215
+++ project.xml 11 Nov 2002 23:17:40 -0000 1.216
@@ -557,6 +557,8 @@
<include>*.dtd</include>
<include>*.mod</include>
<include>log4j.properties</include>
+ <include>driver.jelly</include>
+ <include>driver.properties</include>
</includes>
</resources>
1.26 +3 -2 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.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- App.java 11 Nov 2002 02:42:10 -0000 1.25
+++ App.java 11 Nov 2002 23:17:41 -0000 1.26
@@ -889,7 +889,8 @@
{
Date start = new Date();
File mavenHome = new File(System.getProperty("maven.home"));
- Maven maven = new Maven(mavenHome);
+ Maven maven = new Maven();
+ maven.setMavenHome(mavenHome);
App app = new App(maven);
app.doMain(args, start);
}
1.123 +57 -51 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.122
retrieving revision 1.123
diff -u -r1.122 -r1.123
--- Maven.java 11 Nov 2002 03:45:36 -0000 1.122
+++ Maven.java 11 Nov 2002 23:17:41 -0000 1.123
@@ -58,6 +58,7 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
@@ -114,6 +115,8 @@
*
* @todo filter the Maven version number into a Java constant that will change
* during compilation
+ * @todo Remove any notions of the filesystem. This should strictly be
+ * a logical entity for building projects.
*/
public class Maven
{
@@ -133,6 +136,9 @@
/** Initialization jellyscript name. */
public static final String DRIVER_SCRIPT_NAME = "driver.jelly";
+ /** Driver properties */
+ public static final String DRIVER_PROPERTIES = "driver.properties";
+
/** The current Maven version id */
public static final String APP_VERSION = "1.0-beta-8";
@@ -142,7 +148,8 @@
/** Log. */
private static final Log log = LogFactory.getLog(Maven.class);
-
+
+ /** Instances of Maven objects. Used by the reactor. */
private static final Stack INSTANCES = new Stack();
// ------------------------------------------------------------
@@ -152,9 +159,6 @@
/** ${maven.home}/ directory. */
private File mavenHome;
- /** ${maven.home}/bin/ directory. */
- private File mavenBin;
-
/** Project directory. */
private File dir;
@@ -185,6 +189,7 @@
/** Jelly's output. */
private XMLOutput output;
+ /** Set debugging. */
private boolean isDebug;
/** Plugin Manager */
@@ -199,12 +204,10 @@
// ------------------------------------------------------------
// C O N S T R U C T O R S
// ------------------------------------------------------------
-
- /** Construct.
- */
- public Maven(File mavenHome)
+
+ /** Default Constructor. */
+ public Maven()
{
- setMavenHome( mavenHome );
this.werkzProject = new com.werken.werkz.Project();
this.pluginManager = new PluginManager();
this.goalNames = new ArrayList( 3 );
@@ -365,15 +368,6 @@
public void setMavenHome(File mavenHome)
{
this.mavenHome = mavenHome;
- this.mavenBin = new File(mavenHome, "bin");
- }
-
- /**
- * @return the {@link File} used to drive the build process
- */
- public File getDriverFile()
- {
- return new File(getMavenBin(),DRIVER_SCRIPT_NAME);
}
/** Retrieve the ${maven.home} directory.
@@ -385,15 +379,6 @@
return this.mavenHome;
}
- /** Retrieve the ${maven.home}/bin directory.
- *
- * @return The ${maven.home}/bin directory.
- */
- public File getMavenBin()
- {
- return this.mavenBin;
- }
-
/** Retrieve the list of goal names.
*
* @return The list of goal names.
@@ -588,7 +573,7 @@
* </p>
*
* <ol>
- * <li>$MAVEN_HOME/bin/driver.properties</li>
+ * <li>driver.properties from the maven.jar</li>
* <li>$PARENT_PROJECTS/project.properties if project has
* an extend property
* </li>
@@ -608,9 +593,9 @@
private void loadProperties()
{
File props = null;
-
- props = new File(mavenBin, "driver.properties");
- loadProperties(props);
+
+ InputStream is =
Maven.class.getClassLoader().getResourceAsStream(DRIVER_PROPERTIES);
+ loadProperties(is);
// loadProjectProperties(getDir(), project);
@@ -654,6 +639,7 @@
* @param projectDir directory of project
*/
private void loadProjectProperties(File projectDir, Project currentProject)
+ throws Exception
{
File props = null;
@@ -726,7 +712,7 @@
}
try
{
- jellyContext = new MavenJellyContext(getMavenBin().toURL());
+ jellyContext = new MavenJellyContext();
initializeJellyVariables();
}
@@ -757,7 +743,7 @@
{
getJellyContext().setVariable("maven.obj", this);
getJellyContext().setVariable("maven.home", getMavenHome());
- getJellyContext().setVariable("maven.bin",getMavenBin());
+ //getJellyContext().setVariable("maven.bin",getMavenBin());
getJellyContext().setVariable(
"org.apache.commons.jelly.werkz.Project", getWerkzProject());
@@ -821,7 +807,8 @@
* @throws Exception If an error occurs while performing
* runtime initialization.
*/
- public void runtimeInitialization() throws Exception
+ public void runtimeInitialization()
+ throws Exception
{
initializeJelly();
initializeAnt();
@@ -833,8 +820,6 @@
createProjectVerifier();
initializePlugins();
loadProjectBuildFile();
-
- // verifyProject();
}
/**
@@ -851,6 +836,19 @@
getAntProject().addBuildListener( listener );
}
+ 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;
+ }
+
/**
* Initialise the jelly script that drives the build
*
@@ -860,17 +858,12 @@
{
getJellyContext().setVariable("pom", getProject());
- File driver = getDriverFile();
+ InputStream driverInputStream = getResourceAsStream(DRIVER_SCRIPT_NAME);
- if (!driver.exists())
- {
- return;
- }
-
- JellyUtils.runScript(driver,
- getMavenBin().toURL(),
- getJellyContext(),
- getXMLOutput());
+ JellyUtils.runScript(driverInputStream,
+ null,
+ getJellyContext(),
+ getXMLOutput());
}
/** Initialize all plugins.
@@ -1034,13 +1027,26 @@
{
log.debug("Properties file: " + propsFile);
}
-
- FileInputStream in = null;
-
+
try
{
- in = new FileInputStream(propsFile);
+ loadProperties(new FileInputStream(propsFile));
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ }
+ /** Load the specified properties file into the aggregate
+ * properties.
+ *
+ * @param propsFile The properties file to load.
+ */
+ private void loadProperties(InputStream in)
+ {
+ try
+ {
Properties props = new Properties();
props.load(in);
1.28 +8 -1
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.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- MavenJellyContext.java 24 Oct 2002 07:18:25 -0000 1.27
+++ MavenJellyContext.java 11 Nov 2002 23:17:41 -0000 1.28
@@ -114,6 +114,13 @@
/** Lazy taglib uris. */
private Set lazyTagLibs;
+ public MavenJellyContext()
+ {
+ super();
+ this.tagLibUris = new HashSet();
+ this.lazyTagLibs = new HashSet();
+ }
+
/** Construct.
*
* @param rootContext The root context.
1.8 +2 -2
jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/project/MavenTag.java
Index: MavenTag.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/project/MavenTag.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MavenTag.java 27 Aug 2002 17:57:16 -0000 1.7
+++ MavenTag.java 11 Nov 2002 23:17:41 -0000 1.8
@@ -136,8 +136,8 @@
*/
private Maven getMaven(XMLOutput output, Maven parent) throws Exception
{
- Maven maven = new Maven(parent.getMavenHome());
-
+ Maven maven = new Maven();
+ maven.setMavenHome(parent.getMavenHome());
maven.setDir(getBasedir());
maven.setProjectFile(getDescriptor());
maven.setXMLOutput(output, parent.isDebug());
1.4 +31 -12
jakarta-turbine-maven/src/java/org/apache/maven/util/JellyUtils.java
Index: JellyUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/util/JellyUtils.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JellyUtils.java 5 Nov 2002 16:52:42 -0000 1.3
+++ JellyUtils.java 11 Nov 2002 23:17:41 -0000 1.4
@@ -87,27 +87,19 @@
/**
* Run a jelly script.
*
- * @param scriptFile Location of the script to run.
+ * @param scriptInputStream Script input stream.
* @param rootUrl Root explicit context of the script.
* @param context Jelly context.
* @param output Output sink.
* @throws Exception If an error occurs while locating, compiling or
* executing the script.
*/
- public static void runScript(File scriptFile,
+ public static void runScript(InputStream scriptInputStream,
URL rootUrl,
JellyContext context,
XMLOutput output)
throws Exception
{
-
- // System.err.println( "runScript " + scriptFile );
- // if the scriptFile is not readable or is empty, just ignore it
- if (!scriptFile.canRead() || scriptFile.length() < 1)
- {
- return;
- }
-
URL oldRoot = context.getRootURL();
URL oldCurrent = context.getCurrentURL();
@@ -117,11 +109,38 @@
context.setCurrentURL(rootUrl);
}
- Script script = compileScript(scriptFile, context);
+ Script script = compileScript(scriptInputStream, context);
script.run(context,output);
context.setRootURL(oldRoot);
context.setCurrentURL(oldCurrent);
+ }
+
+ /**
+ * Run a jelly script.
+ *
+ * @param scriptFile Location of the script to run.
+ * @param rootUrl Root explicit context of the script.
+ * @param context Jelly context.
+ * @param output Output sink.
+ * @throws Exception If an error occurs while locating, compiling or
+ * executing the script.
+ */
+ public static void runScript(File scriptFile,
+ URL rootUrl,
+ JellyContext context,
+ XMLOutput output)
+ throws Exception
+ {
+ if (!scriptFile.canRead() || scriptFile.length() < 1)
+ {
+ return;
+ }
+
+ runScript( new FileInputStream(scriptFile),
+ rootUrl,
+ context,
+ output);
}
/**
1.7 +4 -3
jakarta-turbine-maven/src/plugins-build/reactor/src/java/org/apache/maven/reactor/ReactorTag.java
Index: ReactorTag.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/plugins-build/reactor/src/java/org/apache/maven/reactor/ReactorTag.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ReactorTag.java 19 Oct 2002 09:37:39 -0000 1.6
+++ ReactorTag.java 11 Nov 2002 23:17:41 -0000 1.7
@@ -152,8 +152,9 @@
ProjectStatus status = new ProjectStatus(getName());
Project p = (Project) i.next();
- Maven maven = new Maven(parent.getMavenHome());
-
+ Maven maven = new Maven();
+ maven.setMavenHome(parent.getMavenHome());
+
try
{
System.out.println("+----------------------------------------");
1.18 +3 -1
jakarta-turbine-maven/src/test/java/org/apache/maven/project/ProjectInheritanceTest.java
Index: ProjectInheritanceTest.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/test/java/org/apache/maven/project/ProjectInheritanceTest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ProjectInheritanceTest.java 4 Nov 2002 14:59:38 -0000 1.17
+++ ProjectInheritanceTest.java 11 Nov 2002 23:17:42 -0000 1.18
@@ -197,7 +197,9 @@
{
Project p = MavenUtils.getProject(new File(TEST_DOCUMENT2),
new
File(System.getProperty("basedir")+"/src/test/extend/child_project"));
- Maven maven = new Maven(new File(System.getProperty("maven.home")));
+
+ Maven maven = new Maven();
+ maven.setMavenHome(new File(System.getProperty("maven.home")));
maven.setProject(p);
maven.setDir(p.getFile().getParentFile());
maven.runtimeInitialization();
--
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>