smor 2002/07/07 23:06:04
Modified: src/java/org/apache/maven/jelly/tags/project
MavenTagLibrary.java
Added: src/plugins/graph goalstoxml.dvsl plugin.properties
plugin.jelly
src/java/org/apache/maven/jelly/tags/project GoalsToXML.java
Log:
Adding a plugin used to generate graphs from various sources : source code,
dependencies, goals.
Revision Changes Path
1.1 jakarta-turbine-maven/src/plugins/graph/goalstoxml.dvsl
Index: goalstoxml.dvsl
===================================================================
#set( $i = 0 )
#match("project")
digraph mavengenerated {
$context.applyTemplates("goal")
}
#end
#match("goal")
n$attrib.id [label="$attrib.name"];
#set( $i = $i + 1)
#foreach( $prereq in $goal.prerequisites )
#end
#end
1.1 jakarta-turbine-maven/src/plugins/graph/plugin.properties
Index: plugin.properties
===================================================================
maven.graph.viewer.executable = dotty
maven.graph.viewer.commandline = ${maven.build.dir}/graph/goals.dot
1.1 jakarta-turbine-maven/src/plugins/graph/plugin.jelly
Index: plugin.jelly
===================================================================
<project default="graph"
xmlns:maven="jelly:org.apache.maven.jelly.tags.project.MavenTagLibrary">
<goal name="graph:project-dependencies">
</goal>
<goal name="graph:goals">
<mkdir dir="${maven.build.dir}/graph"/>
<maven:goalsToXML file="${maven.build.dir}/graph/goals.xml"
project="${org.apache.commons.jelly.werkz.Project}"/>
<taskdef
name="dvsl"
classname="org.apache.tools.dvsl.DVSLTask">
<classpath refid="maven-classpath"/>
</taskdef>
<dvsl
basedir="${maven.build.dir}/graph"
destdir="${maven.build.dir}/graph"
extension=".dot"
force="true"
style="${plugin.dir}/goalstoxml.dvsl"
includes="**/goals.xml"
outputencoding="${maven.docs.outputencoding}">
<!-- Need to add the maven jar to load the toolbox -->
</dvsl>
<exec executable="${maven.graph.viewer.executable}">
<arg value="${maven.build.dir}/graph/goals.dot"/>
</exec>
</goal>
<goal name="graph" prereqs="graph:project-dependencies"/>
</project>
1.3 +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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MavenTagLibrary.java 3 Jul 2002 21:47:45 -0000 1.2
+++ MavenTagLibrary.java 8 Jul 2002 06:06:03 -0000 1.3
@@ -75,5 +75,6 @@
{
registerTag("pom", PomTag.class);
registerTag("directoryList", DirectoryList.class);
+ registerTag("goalsToXML", GoalsToXML.class);
}
}
1.1
jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/project/GoalsToXML.java
Index: GoalsToXML.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.io.FileOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
import com.werken.werkz.Project;
import com.werken.werkz.Goal;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
/**
* Maven Jelly tag that takes a Werkz Project and outputs its structure to
* an XML file.
*
* @author <a href="[EMAIL PROTECTED]">St�phane Mor</a>
*/
public class GoalsToXML
extends TagSupport
{
/**
* The file to write the output to
*/
private String file;
/**
* The Werkz <code>Project</code> that contains the <code>Goal</code>s
*/
private Project werkzProject;
/**
* Sets the <code>Project</code> used to write the goals.
* @param werkzProject an instance of a Werkz <code>Project</code>
*/
public void setProject(Project werkzProject)
{
this.werkzProject = werkzProject;
}
/**
* Sets the file to write to.
* @param file the name of the file
*/
public void setFile(String file)
{
this.file = file;
}
/**
* Perform functionality provided by the tag
* @param output the place to write output
* @throws Exception when the project or file attribute is missing, or
* another error occurs
*/
public void doTag(XMLOutput output)
throws Exception
{
if ( file == null ) {
throw new MissingAttributeException( "file" );
}
if ( werkzProject == null ) {
throw new MissingAttributeException( "project" );
}
try {
File f = new File(file);
PrintStream ps = new PrintStream( new FileOutputStream(f) );
Collection goals = werkzProject.getGoals();
List list = new ArrayList( goals );
Iterator goalIter = list.iterator();
Goal eachGoal = null;
int id = 0;
ps.print("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
ps.print("<project default=\"" + werkzProject.getDefaultGoalName() +
"\">");
while (goalIter.hasNext())
{
eachGoal = (Goal) goalIter.next();
ps.print(" <goal id=\"" + id + "\" name=\"" + eachGoal.getName() +
"\"");
ps.print(" description=\"" + eachGoal.getDescription() +
"\">");
Collection prerequisites = eachGoal.getPrerequisites();
List prereqslist = new ArrayList( prerequisites );
Iterator prereqIterator = prereqslist.iterator();
Goal prereq = null;
while (prereqIterator.hasNext())
{
prereq = (Goal) prereqIterator.next();
ps.print(" <prerequisite name=\"" + prereq.getName() +
"\"/>");
}
ps.print(" </goal>");
id++;
}
ps.print("</project>");
}
finally
{
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>