werken 2002/07/22 15:21:52
Modified: . build-bootstrap.xml maven.xml
src/java/org/apache/maven/app App.java Maven.java
src/java/org/apache/maven/jelly/tags/project
MavenTagLibrary.java
Added: src/java/org/apache/maven/jelly/tags/project MavenTag.java
Log:
created <maven> tag.
use it for plugins-build.
Revision Changes Path
1.137 +3 -0 jakarta-turbine-maven/build-bootstrap.xml
Index: build-bootstrap.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/build-bootstrap.xml,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -r1.136 -r1.137
--- build-bootstrap.xml 21 Jul 2002 04:04:39 -0000 1.136
+++ build-bootstrap.xml 22 Jul 2002 22:21:51 -0000 1.137
@@ -144,6 +144,9 @@
<exec executable="${maven.home}/bin/${maven.script}"
failonerror="true">
<arg line="maven:plugins-build"/>
+<!--
+ <arg line="-X"/>
+-->
<env key="MAVEN_HOME" value="${maven.home}"/>
</exec>
1.27 +5 -5 jakarta-turbine-maven/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/maven.xml,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- maven.xml 22 Jul 2002 19:04:33 -0000 1.26
+++ maven.xml 22 Jul 2002 22:21:51 -0000 1.27
@@ -1,6 +1,7 @@
<project default="java:jar"
xmlns:j="jelly:core"
xmlns:m="maven"
+ xmlns:maven="jelly:org.apache.maven.jelly.tags.project.MavenTagLibrary"
xmlns:interaction="jelly:org.apache.commons.jelly.tags.interaction.InteractionTagLibrary">
<goal name="maven:init">
@@ -33,11 +34,10 @@
| Building ${mavenPlugin.parentFile.name}
+----------------------------------------
</echo>
- <exec executable="${maven.bin.script}">
- <arg line="--nobanner"/>
- <arg line="-d ${mavenPlugin.parent}"/>
- <arg line="-p ${mavenPlugin}"/>
- </exec>
+
+ <maven:maven dir="${mavenPlugin.parentFile}"
+ descriptor="${mavenPlugin}"
+ ignoreFailures="true"/>
</j:forEach>
</goal>
1.2 +25 -81 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- App.java 22 Jul 2002 20:10:43 -0000 1.1
+++ App.java 22 Jul 2002 22:21:51 -0000 1.2
@@ -100,14 +100,6 @@
getMaven().setProjectFile(new File( getMaven().getDir(),
getMaven().getProjectFileName()));
}
- File projectBuildFile = new File( getMaven().getDir(),
- Maven.PROJECT_BUILD_FILE_NAME);
-
- if (projectBuildFile.exists())
- {
- getMaven().setProjectBuildFile( projectBuildFile );
- }
-
getMaven().addGoalNames( getCli().getArgList() );
}
@@ -127,7 +119,18 @@
{
parseCommandLine(args);
- loadProperties();
+
+ getMaven().loadProperties();
+
+ if (getCli().hasOption('D'))
+ {
+ String[] defStrs = getCli().getOptionValues('D');
+
+ for (int i = 0; i < defStrs.length; ++i)
+ {
+ setCliProperty(defStrs[i]);
+ }
+ }
checkOnline();
@@ -149,21 +152,11 @@
this.consoleErr = System.err;
this.writer = new OutputStreamWriter(this.consoleOut);
+
XMLOutput output = XMLOutput.createXMLOutput(writer, false);
org.apache.tools.ant.Project project = getMaven().getBaseAntProject();
- JellyBuildListener listener = new JellyBuildListener(output);
-
- project.addBuildListener(listener);
-
- if (getCli().hasOption('x')
- ||
- getCli().hasOption('X'))
- {
- listener.isDebug(true);
- }
-
PrintStream demuxOut = new PrintStream(new DemuxOutputStream(project,
false));
@@ -173,7 +166,18 @@
System.setOut(demuxOut);
System.setErr(demuxErr);
- getMaven().setXMLOutput( output );
+ if (getCli().hasOption('x')
+ ||
+ getCli().hasOption('X'))
+ {
+ getMaven().setXMLOutput( output,
+ true );
+ }
+ else
+ {
+ getMaven().setXMLOutput( output,
+ false );
+ }
}
private void checkOnline()
@@ -195,67 +199,7 @@
}
}
- /** Load the properties chain.
- *
- * @task Fix the hardcoded maven.repo.remote
- *
- * <p>
- * This loads properties files with the following priority:
- * <ol>
- * <li>$PROJECT/build.properties</li>
- * <li>$HOME/build.properties</li>
- * <li>$PROJECT/project.properties</li>
- * <li>--system properties--</li>
- * </ol>
- */
- private void loadProperties()
- {
- //!! FIXME: the value for the remote repo shouldn't be hard-coded.
-
- getMaven().setProperty("maven.repo.remote",
- "http://jakarta.apache.org/turbine/jars2/");
-
- Enumeration propNames = System.getProperties().propertyNames();
- String eachName = null;
-
- while (propNames.hasMoreElements())
- {
- eachName = (String) propNames.nextElement();
-
- getMaven().setProperty( eachName,
- System.getProperty( eachName ) );
- }
-
- String propsFileName = null;
-
- File propsFile = null;
-
- propsFile = new File( getMaven().getDir(),
- "project.properties" );
-
- getMaven().loadProperties( propsFile );
-
- propsFile = new File( System.getProperty("user.home"),
- "build.properties" );
-
- getMaven().loadProperties( propsFile );
-
- propsFile = new File( getMaven().getDir(),
- "build.properties" );
-
- getMaven().loadProperties( propsFile );
-
- if (getCli().hasOption('D'))
- {
- String[] defStrs = getCli().getOptionValues('D');
-
- for (int i = 0; i < defStrs.length; ++i)
- {
- setCliProperty(defStrs[i]);
- }
- }
- }
/** Set a property based upon a commandline
* <code>name=value</code> string.
1.76 +77 -7 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.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- Maven.java 22 Jul 2002 20:10:43 -0000 1.75
+++ Maven.java 22 Jul 2002 22:21:51 -0000 1.76
@@ -187,6 +187,8 @@
/** Jelly's output. */
private XMLOutput output;
+ private boolean isDebug;
+
/** Plugin Manager */
private PluginManager pluginManager;
@@ -328,6 +330,12 @@
public void setDir(File dir)
{
this.dir = dir;
+
+ System.setProperty( "user.dir",
+ dir.getPath() );
+
+ setProjectBuildFile( new File( dir,
+ PROJECT_BUILD_FILE_NAME ) );
}
/** Retrieve the project directory.
@@ -429,9 +437,22 @@
return this.output;
}
- public void setXMLOutput(XMLOutput output)
+ public void setXMLOutput(XMLOutput output,
+ boolean isDebug)
{
this.output = output;
+
+ JellyBuildListener listener = new JellyBuildListener( output );
+
+ this.isDebug = isDebug;
+ listener.isDebug( isDebug );
+
+ getAntProject().addBuildListener( listener );
+ }
+
+ public boolean isDebug()
+ {
+ return this.isDebug;
}
/**
@@ -473,6 +494,57 @@
return val.toString();
}
+ /** Load the properties chain.
+ *
+ * @task Fix the hardcoded maven.repo.remote
+ *
+ * <p>
+ * This loads properties files with the following priority:
+ * <ol>
+ * <li>$PROJECT/build.properties</li>
+ * <li>$HOME/build.properties</li>
+ * <li>$PROJECT/project.properties</li>
+ * <li>--system properties--</li>
+ * </ol>
+ */
+ public void loadProperties()
+ {
+ //!! FIXME: the value for the remote repo shouldn't be hard-coded.
+
+ setProperty("maven.repo.remote",
+ "http://jakarta.apache.org/turbine/jars2/");
+
+ Enumeration propNames = System.getProperties().propertyNames();
+ String eachName = null;
+
+ while (propNames.hasMoreElements())
+ {
+ eachName = (String) propNames.nextElement();
+
+ setProperty( eachName,
+ System.getProperty( eachName ) );
+ }
+
+ String propsFileName = null;
+
+ File propsFile = null;
+
+ propsFile = new File( getDir(),
+ "project.properties" );
+
+ loadProperties( propsFile );
+
+ propsFile = new File( System.getProperty("user.home"),
+ "build.properties" );
+
+ loadProperties( propsFile );
+
+ propsFile = new File( getDir(),
+ "build.properties" );
+
+ loadProperties( propsFile );
+ }
+
/** Produce a string representation, suitable for debugging.
*
* @return A debug string.
@@ -531,6 +603,9 @@
*/
private void initializeJellyVariables() throws MalformedURLException
{
+ this.jellyContext.setVariable("maven.obj",
+ this);
+
this.jellyContext.setVariable("maven.home",
getMavenHome());
@@ -587,7 +662,7 @@
* @throws Exception If an error occurs while performing
* runtime initialization.
*/
- void runtimeInitialization() throws Exception
+ public void runtimeInitialization() throws Exception
{
initializeDriver();
createProjectVerifier();
@@ -775,11 +850,6 @@
*/
private void loadProjectBuildFile() throws Exception
{
- if (!(hasProjectBuildFile()))
- {
- return;
- }
-
File projectBuildFile = getProjectBuildFile();
if (!projectBuildFile.exists())
1.8 +2 -1
jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/project/MavenTagLibrary.java
Index: MavenTagLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/project/MavenTagLibrary.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MavenTagLibrary.java 13 Jul 2002 14:59:33 -0000 1.7
+++ MavenTagLibrary.java 22 Jul 2002 22:21:52 -0000 1.8
@@ -78,5 +78,6 @@
registerTag("goalsToXML", GoalsToXML.class);
registerTag("snapshot", SnapshotSignature.class);
registerTag("addPath", AddPathTag.class);
+ registerTag("maven", MavenTag.class);
}
}
1.1
jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/project/MavenTag.java
Index: MavenTag.java
===================================================================
package org.apache.maven.jelly.tags.project;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import java.io.File;
import java.util.ArrayList;
import org.apache.maven.app.Maven;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
import java.util.StringTokenizer;
public class MavenTag
extends TagSupport
{
private File descriptor;
private File dir;
private String goals;
private boolean ignore;
public void doTag(XMLOutput output)
throws Exception
{
if ( this.dir == null )
{
throw new MissingAttributeException( "dir" );
}
if ( this.descriptor == null )
{
throw new MissingAttributeException( "descriptor" );
}
Maven parent = (Maven) getContext().getVariable( "maven.obj" );
Maven maven = new Maven( parent.getMavenHome() );
maven.setDir( getDir() );
maven.setProjectFile( getDescriptor() );
maven.setXMLOutput( output,
parent.isDebug() );
maven.loadProperties();
if ( this.goals != null )
{
StringTokenizer tokens = new StringTokenizer( this.goals,
"," );
while ( tokens.hasMoreTokens() )
{
maven.addGoalName( tokens.nextToken().trim() );
}
}
maven.runtimeInitialization();
try
{
maven.attainGoals();
}
catch (Exception e)
{
if ( ignore )
{
return;
}
e.fillInStackTrace();
throw e;
}
}
public void setDescriptor(File descriptor)
{
this.descriptor = descriptor;
}
public File getDescriptor()
{
return this.descriptor;
}
public void setDir(File dir)
{
this.dir = dir;
}
public File getDir()
{
return this.dir;
}
public void setGoals(String goals)
{
this.goals = goals;
}
public String getGoals()
{
return this.goals;
}
public void setIgnoreFailures(boolean ignore)
{
this.ignore = ignore;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>