werken 2002/06/22 11:07:09
Modified: . maven.xml project-ng.xml project.xml
src/bin/plugins/core plugin.jelly
src/java/org/apache/maven/app Maven.java
Log:
Adding goal listing to the cli.
Revision Changes Path
1.2 +1 -1 jakarta-turbine-maven/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/maven.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- maven.xml 19 Jun 2002 17:21:52 -0000 1.1
+++ maven.xml 22 Jun 2002 18:07:09 -0000 1.2
@@ -1,5 +1,5 @@
-<project xmlns:j="jelly:core">
+<project xmlns:j="jelly:core" default="maven:jar">
<preGoal name="maven:compile">
<echo>
1.2 +1 -1 jakarta-turbine-maven/project-ng.xml
Index: project-ng.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/project-ng.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- project-ng.xml 19 Jun 2002 17:21:52 -0000 1.1
+++ project-ng.xml 22 Jun 2002 18:07:09 -0000 1.2
@@ -355,7 +355,7 @@
<dependency>
<id>werkz</id>
- <version>1.0-dev.20020613.091536</version>
+ <version>1.0-beta-1</version>
</dependency>
<!-- Runtime dependencies -->
1.120 +1 -1 jakarta-turbine-maven/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/project.xml,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -r1.119 -r1.120
--- project.xml 19 Jun 2002 17:21:52 -0000 1.119
+++ project.xml 22 Jun 2002 18:07:09 -0000 1.120
@@ -360,7 +360,7 @@
<dependency>
<id>werkz</id>
- <version>1.0-dev.20020613.091536</version>
+ <version>1.0-beta-1</version>
</dependency>
<!-- Runtime dependencies -->
1.2 +3 -1 jakarta-turbine-maven/src/bin/plugins/core/plugin.jelly
Index: plugin.jelly
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/bin/plugins/core/plugin.jelly,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- plugin.jelly 19 Jun 2002 17:21:53 -0000 1.1
+++ plugin.jelly 22 Jun 2002 18:07:09 -0000 1.2
@@ -37,7 +37,8 @@
<!-- update-jars -->
<!-- ================================================================== -->
- <goal name="maven:update-jars">
+ <goal name="maven:update-jars"
+ description="Update the jars this project depends upon.">
<httpget
projectDescriptor="project.xml"
baseUrl="${maven.repo.remote}"
@@ -96,6 +97,7 @@
<!-- ================================================================== -->
<goal name="maven:jar"
+ description="Create the deliverable jar file."
prereqs="maven:test,maven:jar-resources">
<jar
jarfile="${maven.build.dir}/${maven.final.name}.jar"
1.10 +102 -9 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Maven.java 21 Jun 2002 21:42:41 -0000 1.9
+++ Maven.java 22 Jun 2002 18:07:09 -0000 1.10
@@ -92,6 +92,7 @@
import java.net.URL;
import java.util.List;
import java.util.Properties;
+import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
@@ -590,13 +591,15 @@
*
* @throws Exception If an error occurs.
*/
- void run() throws Exception {
+ void attainGoals() throws Exception {
+ /*
List goalNames = getGoalNames();
if ( goalNames.isEmpty() ) {
return;
}
+ */
JellyContext context = getJellyContext();
context.setVariable("goals", getGoalNames() );
@@ -611,8 +614,68 @@
runGoals( goalNames );
- writer.flush();
- writer.close();
+ }
+
+
+ void displayGoals() throws Exception {
+
+ JellyContext context = getJellyContext();
+
+ runDriver();
+
+ loadPlugins();
+
+ loadProjectScript();
+
+ com.werken.werkz.Project werkzProject =
+ (com.werken.werkz.Project) getJellyContext().getVariable(
"org.apache.commons.jelly.werkz.Project" );
+
+ Collection goals = werkzProject.getGoals();
+
+ Iterator goalIter = goals.iterator();
+ Goal eachGoal = null;
+
+ String description = null;
+
+ boolean hadDesc = false;
+
+ while ( goalIter.hasNext() ) {
+ eachGoal = (Goal) goalIter.next();
+ description = eachGoal.getDescription();
+
+ if ( description == null ) {
+ continue;
+ }
+
+ hadDesc = true;
+
+ System.out.println( " " + format( eachGoal.getName() + " ",
+ 30,
+ '.' ) + " " +
eachGoal.getDescription() );
+ }
+
+ if ( !hadDesc ) {
+ System.out.println( " No documented goals." );
+ }
+
+ }
+
+ private String format(String orig, int width, char pad) {
+
+ if ( orig.length() > width ) {
+ return orig;
+ }
+
+ StringBuffer buf = new StringBuffer().append( orig );
+
+ int diff = width - orig.length();
+
+ for ( int i = 0 ; i < diff ; ++i ) {
+ buf.append( pad );
+ }
+
+ return buf.toString();
+
}
/** Load the project's maven script.
@@ -636,6 +699,16 @@
com.werken.werkz.Project werkzProject =
(com.werken.werkz.Project) getJellyContext().getVariable(
"org.apache.commons.jelly.werkz.Project" );
+ if ( goalNames.isEmpty() ) {
+ String defaultGoalName = werkzProject.getDefaultGoalName();
+
+ if ( defaultGoalName != null ) {
+ goalNames.add( defaultGoalName );
+ } else {
+ return;
+ }
+ }
+
Iterator goalNameIter = goalNames.iterator();
String eachGoalName = null;
Goal eachGoal = null;
@@ -948,7 +1021,7 @@
}
} catch (Exception e) {
System.err.println( "Error initializing: " + e.getLocalizedMessage() );
- e.printStackTrace();
+ // e.printStackTrace();
return;
}
@@ -967,19 +1040,39 @@
System.out.println( " current-version: "
+ mavenProject.getCurrentVersion() );
- System.out.println( "" );
-
try {
- run();
+
+ if ( this.cli.hasOption( 'g' ) ) {
+ displayGoals();
+ } else {
+ attainGoals();
+ }
+
+ System.out.println( "" );
+
+ writer.flush();
+ writer.close();
+
} catch (UnknownGoalException e) {
System.err.println( "BUILD FAILED" );
System.err.println( "Goal \"" + e.getGoalName() + "\" does not exist in
this project." );
- System.err.println( "" );
+ System.out.println( "" );
+
+ try
+ {
+ writer.flush();
+ writer.close();
+ }catch (Exception i) {
+ // ignore
+ }
+
return;
} catch (Exception e) {
- e.printStackTrace();
+ // System.err.println( e.getLocalizedMessage() );
+ System.out.println( "" );
}
}
+
// ------------------------------------------------------------
// Class methods
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>