jvanzyl 02/02/23 21:23:48
Modified: src/java/org/apache/maven Reactor.java
src/java/org/apache/maven/jxr CodeTransform.java
Added: src/java/org/apache/maven ChangeLog.java
Log:
- cleaning up more code
- stealing more bits of alexandria, adapt the changelog task to work
with a project descriptor
Revision Changes Path
1.3 +39 -38 jakarta-turbine-maven/src/java/org/apache/maven/Reactor.java
Index: Reactor.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/Reactor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Reactor.java 21 Feb 2002 14:10:18 -0000 1.2
+++ Reactor.java 24 Feb 2002 05:23:47 -0000 1.3
@@ -1,4 +1,5 @@
package org.apache.maven;
+
/* ====================================================================
* The Apache Software License, Version 1.1
*
@@ -88,7 +89,7 @@
* can be used in many interfaces: ant, command line, servlet ...
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Reactor.java,v 1.2 2002/02/21 14:10:18 jvanzyl Exp $
+ * @version $Id: Reactor.java,v 1.3 2002/02/24 05:23:47 jvanzyl Exp $
*/
public class Reactor
extends Task
@@ -98,7 +99,7 @@
* in Maven.
*/
private File workspace;
-
+
/**
* Log4j category used for logging.
*/
@@ -119,8 +120,8 @@
public void setWorkspace(File workspace)
{
this.workspace = workspace;
- }
-
+ }
+
/**
* Get the workspace descriptor being used with
* this Maven build.
@@ -130,9 +131,9 @@
public File getWorkspace()
{
return workspace;
- }
-
- /**
+ }
+
+ /**
* Set the directory where all the Maven descriptors
* are stored.
*
@@ -143,8 +144,8 @@
{
this.descriptorDir = descriptorDir;
}
-
- /**
+
+ /**
* Get the directory where all the Maven descriptors
* are stored.
*
@@ -154,13 +155,13 @@
public File getDescriptorDir()
{
return descriptorDir;
- }
+ }
/**
* The build type: source, binary.
*/
private String buildType;
-
+
/**
* Set the build type: source, binary.
*/
@@ -168,14 +169,14 @@
{
this.buildType = buildType;
}
-
+
/**
* Get the build type: source, binary.
*/
public String getBuildType()
{
return buildType;
- }
+ }
/**
* Project to build. This can be an individual project or
@@ -187,26 +188,26 @@
{
this.javaProject = javaProject;
}
-
+
public String getJavaProject()
{
return javaProject;
- }
+ }
/**
* Execute the the overall maven opertion.
*
* @throws BuildException
*/
- public void execute()
+ public void execute()
throws BuildException
{
// Setup log4j with a standard properties file.
PropertyConfigurator.configure("log4j.properties");
checkPrerequisites();
-
+
category.debug("Workspace file: " + workspace);
-
+
try
{
// Now the workspace only deals with projects stating
@@ -216,28 +217,28 @@
// and indirectly.
List profiles = mapProjectDescriptors();
DependencyResolver dr = new DependencyResolver();
-
+
if (javaProject.equals("all") == false)
{
dr.setTraverseAll(false);
- }
-
+ }
+
for (Iterator i = profiles.iterator(); i.hasNext();)
{
Graphable g = (Graphable) i.next();
dr.addGraphable(g, ((Project)g).getDependencies());
}
-
+
// We need special workspace for all the projects
// for the typical gump build.
-
+
// Everything starts with a workspace.
Mapper m = new Mapper();
m.setDebug(false);
m.setInclusionRule("profile", "../profile");
m.setInclusionRule("project", "../project");
m.setInclusionRule("repository", "../repository");
-
+
Workspace w = (Workspace) m.map(workspace.toString(),
"org.apache.maven.project.Workspace");
@@ -245,26 +246,26 @@
Graphable gg = (Graphable) w.getProfile().getProjects().get(1);
dr.printGraph("graph.xml", (Graphable)gg);
List deps = dr.getSortedDependencies(gg.getName());
-
+
category.info("< " + gg.getName() + " >");
-
+
for (Iterator i = deps.iterator(); i.hasNext();)
{
category.info(i.next());
}
-
+
Velocity.init();
-
+
VelocityContext context = new VelocityContext();
context.put("workspace", w);
-
+
//!! Make the name of the build file configurable. Make
// it an option in the workspace descriptor.
- FileOutputStream fos =
+ FileOutputStream fos =
new FileOutputStream(new File("work","build.xml"));
-
+
Writer writer = new BufferedWriter(new OutputStreamWriter(fos));
-
+
//!! Make this configurable.
Velocity.mergeTemplate("src/templates/build.vm", context, writer);
writer.flush();
@@ -287,7 +288,7 @@
if (workspace == null)
{
throw new BuildException(
- "workspace attribute must be set!");
+ "workspace attribute must be set!");
}
}
@@ -302,19 +303,19 @@
public List mapProjectDescriptors()
{
DirectoryScanner directoryScanner = new DirectoryScanner();
-
+
File baseDir = new File(getDescriptorDir(),"project");
directoryScanner.setBasedir(baseDir);
String[] includes = { "**/*.xml" };
directoryScanner.setIncludes(includes);
directoryScanner.scan();
String[] files = directoryScanner.getIncludedFiles();
-
+
List projects = new ArrayList();
Mapper projectMapper = new Mapper();
projectMapper.setInclusionRule("project", "../project");
projectMapper.setInclusionRule("repository", "../repository");
-
+
for (int i = 0; i < files.length; i++)
{
try
@@ -323,7 +324,7 @@
category.debug("Processing module -> " + project);
Project p = (Project) projectMapper.map(
project.toString(), "org.apache.maven.project.Project");
-
+
projects.add(p);
}
catch (Exception e)
@@ -331,7 +332,7 @@
category.error("Error processing " + files[i], e);
}
}
-
+
return projects;
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/ChangeLog.java
Index: ChangeLog.java
===================================================================
package org.apache.maven;
/*
*
* Copyright (c) 1998 The Java Apache Project. 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. Every modification must be notified to the Java Apache Project
* and redistribution of the modified code without prior notification
* is not permitted in any form.
*
* 4. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Java Apache Project
* (http://java.apache.org/)."
*
* 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria
* Project" must not be used to endorse or promote products
* derived from this software without prior written permission.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Java Apache Project
* (http://java.apache.org/)."
*
* THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "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 JAVA APACHE PROJECT 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.
*
* License version 1.0
*
*/
import java.io.*;
import java.util.*;
import java.text.*;
import org.apache.tools.ant.*;
import org.apache.tools.ant.taskdefs.*;
import org.apache.tools.ant.types.*;
/**
* Change log task. The task will examine the output of cvs log and group
* related changes together. It produces an XML output representing the list of
* changes.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jeff Martin</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: ChangeLog.java,v 1.1 2002/02/24 05:23:47 jvanzyl Exp $
*/
public class ChangeLog
extends Task
implements ExecuteStreamHandler
{
/**
* User list
*/
private File users = null;
/**
* User list
*/
private Properties userList = new Properties();
/**
* User list
*/
private Vector ulist = new Vector();
/**
* Input dir
*/
private File base = null;
/**
* Output file
*/
private File output = null;
/**
* input stream read in from cvs
*/
private BufferedReader in = null;
/**
* output file stream
*/
private PrintWriter out = null;
private final static int GET_ENTRY = 0;
private final static int GET_FILE = 1;
private final static int GET_DATE = 2;
private final static int GET_COMMENT = 3;
private final static int GET_REVISION = 4;
private final static int GET_PREVIOUS_REV = 5;
private int status = GET_FILE;
/**
* rcs entries
*/
private Hashtable entries = new Hashtable();
/**
* input format for dates read in from cvs log
*/
private final static SimpleDateFormat inputDate = new
SimpleDateFormat("yyyy/MM/dd");
/**
* output format for dates writtn to xml file
*/
private final static SimpleDateFormat outputDate = new
SimpleDateFormat("yyyy-MM-dd");
/**
* output format for times writtn to xml file
*/
private final static SimpleDateFormat outputTime = new SimpleDateFormat("hh:mm");
/**
* Set the input stream for the cvs process. cvs requires no input so this
* is not used.
*/
public void setProcessInputStream(OutputStream os)
throws IOException
{
}
/**
* Set the error stream for reading from cvs log.
*/
public void setProcessErrorStream(InputStream is)
throws IOException
{
}
/**
* Set the input stream used to read from cvs log
*/
public void setProcessOutputStream(InputStream is)
throws IOException
{
in = new BufferedReader(new InputStreamReader(is));
}
/**
* Stop the process
*/
public void stop()
{
}
/**
* Set the base dir for cvs.
*/
public void setBasedir(File base)
{
this.base = base;
}
/**
* Set the output file for the log.
*/
public void setOutput(File output)
{
this.output = output;
}
/**
* Execute task
*/
public void execute()
throws BuildException
{
if (base == null)
{
throw new BuildException("basedir must be set");
}
if (output == null)
{
throw new BuildException("output must be set");
}
if (!users.exists())
{
throw new BuildException("Cannot find user lookup file " +
users.getAbsolutePath());
}
if (!base.exists())
{
throw new BuildException("Cannot find base dir " +
base.getAbsolutePath());
}
if (users != null)
{
if (!users.exists())
{
throw new BuildException("Cannot find user list " +
users.getAbsolutePath());
}
userList = new Properties();
try
{
userList.load(new FileInputStream(users));
}
catch (IOException e)
{
throw new BuildException(e);
}
for (Enumeration e = ulist.elements(); e.hasMoreElements(); )
{
User user = (User) e.nextElement();
userList.put(user.getUsername(), user.getDisplayname());
}
}
Commandline toExecute = new Commandline();
toExecute.setExecutable("cvs");
toExecute.createArgument().setValue("log");
Execute exe = new Execute(this);
exe.setCommandline(toExecute.getCommandline());
exe.setAntRun(project);
exe.setWorkingDirectory(base);
try
{
exe.execute();
}
catch (IOException e)
{
throw new BuildException(e);
}
}
/**
* Set a lookup list of user names & addresses
*/
public void setUserlist(File users)
{
this.users = users;
}
/**
* Start read from the cvs log
*/
public void start()
throws IOException
{
String file = null;
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output),
"UTF-8"));
String line;
String date = null;
String author = null;
String comment = null;
String revision = null;
String previousRev = null;
while ((line = in.readLine()) != null)
{
switch (status)
{
case GET_FILE:
if (line.startsWith("Working file:"))
{
file = line.substring(14, line.length());
status = GET_REVISION;
}
break;
case GET_REVISION:
if (line.startsWith("revision"))
{
revision = line.substring(9);
status = GET_DATE;
}
case GET_DATE:
if (line.startsWith("date:"))
{
date = line.substring(6, 16);
line = line.substring(line.indexOf(";") + 1);
author = line.substring(10, line.indexOf(";"));
if (userList.containsKey(author))
{
author = "<![CDATA[" + userList.getProperty(author) +
"]]>";
}
status = GET_COMMENT;
}
break;
case GET_COMMENT:
comment = "";
while (line != null && !line.startsWith("======") &&
!line.startsWith("------"))
{
comment += line + "\n";
line = in.readLine();
}
comment = "<![CDATA[" + comment.substring(0, comment.length() -
1) + "]]>";
status = GET_PREVIOUS_REV;
break;
case GET_PREVIOUS_REV:
if (line.startsWith("revision"))
{
previousRev = line.substring(9);
status = GET_FILE;
Entry entry;
if (!entries.containsKey(date + author + comment))
{
entry = new Entry(date, author, comment);
entries.put(date + author + comment, entry);
}
else
{
entry = (Entry) entries.get(date + author + comment);
}
entry.addFile(file, revision, previousRev);
}
if (line.startsWith("======"))
{
status = GET_FILE;
Entry entry;
if (!entries.containsKey(date + author + comment))
{
entry = new Entry(date, author, comment);
entries.put(date + author + comment, entry);
}
else
{
entry = (Entry) entries.get(date + author + comment);
}
entry.addFile(file, revision);
}
}
}
out.println("<changelog>");
for (Enumeration en = entries.elements(); en.hasMoreElements(); )
{
((Entry) en.nextElement()).print();
}
out.println("</changelog>");
out.flush();
out.close();
}
/**
* CVS Entry
*/
private class Entry
{
private Date date = null;
private final String author;
private final String comment;
private final Vector files = new Vector();
/**
* Constructor for the Entry object
*
* @param date
* @param author
* @param comment
*/
public Entry(String date, String author, String comment)
{
try
{
this.date = inputDate.parse(date);
}
catch (ParseException e)
{
log("I don't understand this date -> " + date);
}
this.author = author;
this.comment = comment;
}
/**
* Adds a feature to the File attribute of the Entry object
*/
public void addFile(String file, String revision)
{
files.addElement(new RCSFile(file, revision));
}
/**
* Adds a feature to the File attribute of the Entry object
*/
public void addFile(String file, String revision, String previousRev)
{
files.addElement(new RCSFile(file, revision, previousRev));
}
/**
* Description of the Method
*/
public String toString()
{
return author + "\n" + date + "\n" + files + "\n" + comment;
}
/**
* Description of the Method
*/
public void print()
{
out.println("\t<entry>");
out.println("\t\t<date>" + outputDate.format(date) + "</date>");
out.println("\t\t<time>" + outputTime.format(date) + "</time>");
out.println("\t\t<author>" + author + "</author>");
for (Enumeration e = files.elements(); e.hasMoreElements(); )
{
RCSFile file = (RCSFile) e.nextElement();
out.println("\t\t<file>");
out.println("\t\t\t<name>" + file.getName() + "</name>");
out.println("\t\t\t<revision>" + file.getRevision() + "</revision>");
if (file.getPreviousRev() != null)
{
out.println("\t\t\t<prevrevision>" + file.getPreviousRev() +
"</prevrevision>");
}
out.println("\t\t</file>");
}
out.println("\t\t<msg>" + comment + "</msg>");
out.println("\t</entry>");
}
/**
* Description of the Class
*/
private class RCSFile
{
private String name;
private String rev;
private String previousRev;
/**
* Constructor for the RCSFile object
*
* @param name
* @param rev
*/
private RCSFile(String name, String rev)
{
this(name, rev, null);
}
/**
* Constructor for the RCSFile object
*
* @param name
* @param rev
* @param previousRev
*/
private RCSFile(String name, String rev, String previousRev)
{
this.name = name;
this.rev = rev;
if (!rev.equals(previousRev))
{
this.previousRev = previousRev;
}
}
/**
* Gets the name attribute of the RCSFile object
*/
public String getName()
{
return name;
}
/**
* Gets the revision attribute of the RCSFile object
*/
public String getRevision()
{
return rev;
}
/**
* Gets the previousRev attribute of the RCSFile object
*/
public String getPreviousRev()
{
return previousRev;
}
}
}
/**
* Description of the Method
*/
public User createUser()
{
User user = new User();
ulist.addElement(user);
return user;
}
/**
* Description of the Class
*/
public class User
{
private String user;
private String name;
/**
* Sets the displayname attribute of the User object
*/
public void setDisplayname(String name)
{
this.name = name;
}
/**
* Sets the username attribute of the User object
*/
public void setUsername(String user)
{
this.user = user;
}
/**
* Gets the username attribute of the User object
*/
public String getUsername()
throws BuildException
{
if (name == null)
{
throw new BuildException("username attribute must be set");
}
return user;
}
/**
* Gets the displayname attribute of the User object
*/
public String getDisplayname()
throws BuildException
{
if (name == null)
{
throw new BuildException("displayname attribute must be set");
}
return name;
}
}
}
1.4 +2 -1
jakarta-turbine-maven/src/java/org/apache/maven/jxr/CodeTransform.java
Index: CodeTransform.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jxr/CodeTransform.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CodeTransform.java 24 Feb 2002 03:01:40 -0000 1.3
+++ CodeTransform.java 24 Feb 2002 05:23:48 -0000 1.4
@@ -1,3 +1,5 @@
+package org.apache.maven.jxr;
+
/*
* CodeViewer.java
* CoolServlets.com
@@ -27,7 +29,6 @@
* 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.
*/
-package org.apache.maven.jxr;
import org.apache.maven.jxr.util.*;
import org.apache.maven.jxr.pacman.*;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>