werken 2002/06/10 08:43:58
Modified: . build.xml project.xml
src/bin maven maven-bootstrap.jelly maven-scripts.jelly
src/java/org/apache/maven/jelly AntBuildTag.java
MavenInitTag.java
Added: src/bin maven-ng.jelly
src/java/org/apache/maven/jelly JellyAntProject.java
JellyAntProps.java
Log:
Hacks to allow ant tasks in a build.xml directly access data
within the POM.
Revision Changes Path
1.40 +22 -1 jakarta-turbine-maven/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/build.xml,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- build.xml 6 Jun 2002 06:54:36 -0000 1.39
+++ build.xml 10 Jun 2002 15:43:58 -0000 1.40
@@ -13,8 +13,29 @@
<property file="project.properties" />
<target
- name="jelly-jar">
+ name="jelly-jar">
<antcall target="maven:jar"/>
+ </target>
+
+ <target
+ name="bob-pom">
+ <echo>
+ =======================================
+ =======================================
+ =======================================
+ =======================================
+ =======================================
+ ${maven}
+ ${maven.distributionDirectory}
+ ${maven.distributionDirectory.length()}
+ =======================================
+ =======================================
+ =======================================
+ =======================================
+ =======================================
+ =======================================
+ =======================================
+ </echo>
</target>
1.105 +6 -0 jakarta-turbine-maven/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/project.xml,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- project.xml 10 Jun 2002 10:24:40 -0000 1.104
+++ project.xml 10 Jun 2002 15:43:58 -0000 1.105
@@ -317,6 +317,12 @@
</dependency>
<dependency>
+ <id>commons-jexl</id>
+ <version>1.0-dev</version>
+ <url>http://jakarta.apache.org/commons/sandbox/jelly/</url>
+ </dependency>
+
+ <dependency>
<id>commons-logging</id>
<version>1.0</version>
<url>http://jakarta.apache.org/commons/logging.html</url>
1.2 +1 -1 jakarta-turbine-maven/src/bin/maven
Index: maven
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/bin/maven,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- maven 5 Jun 2002 22:08:22 -0000 1.1
+++ maven 10 Jun 2002 15:43:58 -0000 1.2
@@ -147,4 +147,4 @@
echo $LOCALCLASSPATH
$JAVACMD -classpath "$LOCALCLASSPATH" -Dmaven.home="${MAVEN_HOME}" $MAVEN_OPTS \
- org.apache.commons.jelly.Jelly ${MAVEN_HOME}/bin/maven-bootstrap.jelly
$MAVEN_ARGS "$@"
+ org.apache.commons.jelly.Jelly file://${MAVEN_HOME}/bin/maven-ng.jelly
$MAVEN_ARGS "$@"
1.5 +1 -0 jakarta-turbine-maven/src/bin/maven-bootstrap.jelly
Index: maven-bootstrap.jelly
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/bin/maven-bootstrap.jelly,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- maven-bootstrap.jelly 6 Jun 2002 05:03:55 -0000 1.4
+++ maven-bootstrap.jelly 10 Jun 2002 15:43:58 -0000 1.5
@@ -2,6 +2,7 @@
|| This file lives in ${maven.home}
-->
<jelly:jelly
+ preserveWhitespace="false"
trim="true"
xmlns:jelly="jelly:core"
xmlns:def="jelly:define"
1.4 +2 -1 jakarta-turbine-maven/src/bin/maven-scripts.jelly
Index: maven-scripts.jelly
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/bin/maven-scripts.jelly,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- maven-scripts.jelly 6 Jun 2002 18:09:25 -0000 1.3
+++ maven-scripts.jelly 10 Jun 2002 15:43:58 -0000 1.4
@@ -3,6 +3,7 @@
-->
<jelly:jelly
trim="true"
+ preserveWhitespace="false"
xmlns:ant="jelly:ant"
xmlns:jelly="jelly:core"
xmlns:def="jelly:define"
@@ -32,7 +33,7 @@
<!--
|| user-defined target
-->
- <def:script var="target_user">
+ <def:script var="target_user" preserveWhitespace="false">
<maven:build target="${target}"/> <!-- ignore="true"/> -->
<jelly:choose>
<jelly:when test='${target_status == "unknown_target"}'>
1.1 jakarta-turbine-maven/src/bin/maven-ng.jelly
Index: maven-ng.jelly
===================================================================
<j:jelly
trim="true"
xmlns:j="jelly:core"
xmlns:maven="jelly:org.apache.maven.jelly.MavenTagLibrary">
<maven:init/>
<maven:build target="bob-pom"/>
</j:jelly>
1.6 +10 -6
jakarta-turbine-maven/src/java/org/apache/maven/jelly/AntBuildTag.java
Index: AntBuildTag.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/AntBuildTag.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AntBuildTag.java 6 Jun 2002 18:09:25 -0000 1.5
+++ AntBuildTag.java 10 Jun 2002 15:43:58 -0000 1.6
@@ -199,11 +199,11 @@
try
{
- Project project = null;
+ JellyAntProject project = null;
if (getBuildFile() != null )
{
- project = new Project();
+ project = new JellyAntProject();
File buildFile = new File( getBuildFile() );
@@ -216,7 +216,7 @@
ProjectHelper.configureProject( project,
buildFile );
- Project parentProj = (Project) context.getVariable( "ant-project" );
+ JellyAntProject parentProj = (JellyAntProject) context.getVariable(
"ant-project" );
if ( parentProj != null )
{
@@ -243,8 +243,10 @@
}
else
{
- project = (Project) context.getVariable( "ant-project" );
+ project = (JellyAntProject) context.getVariable( "ant-project" );
}
+
+ System.err.println( "----> PROJECT IS " + project );
Hashtable projTargets = project.getTargets();
String target = getTarget();
@@ -300,9 +302,11 @@
* the ones specified as user properties to the current project,
* depending on inheritall).
*/
- private void initializeProject(Project project,
- Project newProject)
+ private void initializeProject(JellyAntProject project,
+ JellyAntProject newProject)
{
+
+ newProject.setJexlContext( project.getJexlContext() );
System.err.println( "########## initializeProject()" );
Vector listeners = project.getBuildListeners();
1.8 +9 -6
jakarta-turbine-maven/src/java/org/apache/maven/jelly/MavenInitTag.java
Index: MavenInitTag.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/MavenInitTag.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MavenInitTag.java 6 Jun 2002 18:09:26 -0000 1.7
+++ MavenInitTag.java 10 Jun 2002 15:43:58 -0000 1.8
@@ -64,6 +64,7 @@
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.tags.ant.AntTagLibrary;
+import org.apache.commons.jexl.JexlContext;
import org.apache.maven.MavenUtils;
import org.apache.maven.ProjectProperties;
@@ -76,6 +77,8 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
public class MavenInitTag
extends TagSupport
@@ -90,14 +93,14 @@
public void doTag(XMLOutput output)
throws Exception
{
- org.apache.tools.ant.Project antProject = initAntProject();
+ JellyAntProject antProject = initAntProject();
initMavenProject( antProject );
getBody().run(context, output);
}
- private void initMavenProject(org.apache.tools.ant.Project antProject) throws
Exception
+ private void initMavenProject(JellyAntProject antProject) throws Exception
{
String dir = System.getProperty( "user.dir" );
@@ -108,17 +111,17 @@
projProps.setProjectDescriptor( projDesc );
projProps.setProject( antProject );
- // org.apache.maven.project.Project project = MavenUtils.getProject(
projDesc.getPath() );
-
projProps.execute();
context.setVariable( "maven-project",
projProps.getMavenProject() );
+
+ antProject.setMavenProject( projProps.getMavenProject() );
}
- private org.apache.tools.ant.Project initAntProject() throws Exception
+ private JellyAntProject initAntProject() throws Exception
{
- org.apache.tools.ant.Project project = new org.apache.tools.ant.Project();
+ JellyAntProject project = new JellyAntProject();
BuildLogger logger = new NoBannerLogger();
1.1
jakarta-turbine-maven/src/java/org/apache/maven/jelly/JellyAntProject.java
Index: JellyAntProject.java
===================================================================
package org.apache.maven.jelly;
import org.apache.maven.project.Project;
import org.apache.commons.jexl.Expression;
import org.apache.commons.jexl.ExpressionFactory;
import org.apache.commons.jexl.JexlContext;
import org.apache.commons.jexl.context.HashMapContext;
import java.util.Hashtable;
public class JellyAntProject extends org.apache.tools.ant.Project
{
private HashMapContext jexlContext;
public JellyAntProject()
{
this.jexlContext = new HashMapContext();
}
public JellyAntProject(JexlContext jexlContext)
{
setJexlContext( jexlContext );
}
public String getProperty(String name)
{
System.err.println( "################### getProperty(" + name + ")" );
String value = super.getProperty( name );
if ( value == null )
{
value = getMavenProperty( name );
}
return value;
}
public String getUserProperty(String name)
{
System.err.println( "################### getUserProperty(" + name + ")" );
String value = super.getUserProperty( name );
if ( value == null )
{
value = getMavenProperty( name );
}
return value;
}
public Hashtable getProperties()
{
System.err.println( "##### getProperties()" );
return new JellyAntProps( this );
}
public String getMavenProperty(String name)
{
String value = null;
try
{
System.err.println( name + " CCCC" );
Expression expr = ExpressionFactory.createExpression( name );
System.err.println( name + " DDD: " + expr );
Object result = expr.evaluate( getJexlContext() );
if ( result != null )
{
value = result.toString();
}
System.err.println( name + " EEE: " + value );
}
catch (Exception e)
{
e.printStackTrace();
value = null;
}
return value;
}
public void setMavenProject(Project project)
{
this.jexlContext.put( "maven",
project );
}
public void setJexlContext(JexlContext jexlContext)
{
this.jexlContext = new HashMapContext();
this.jexlContext.putAll( jexlContext.getVars() );
}
public JexlContext getJexlContext()
{
return this.jexlContext;
}
}
1.1
jakarta-turbine-maven/src/java/org/apache/maven/jelly/JellyAntProps.java
Index: JellyAntProps.java
===================================================================
package org.apache.maven.jelly;
import java.util.Hashtable;
public class JellyAntProps extends Hashtable
{
private JellyAntProject project;
public JellyAntProps(JellyAntProject project)
{
System.err.println( "##### JellyAntProps.ctor()" );
this.project = project;
}
public JellyAntProject getProject()
{
return this.project;
}
public boolean containsKey(Object key)
{
System.err.println( "##### JellyAntProps.containsKey(" + key + ")" );
return ( getProject().getProperty( (String) key ) != null );
}
public Object get(Object key)
{
System.err.println( "##### JellyAntProps.get(" + key + ")" );
return getProject().getProperty( (String) key );
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>