ow-util-ant-tasks-1.3.2/0000755000175000017500000000000010643716622014013 5ustar mkochmkochow-util-ant-tasks-1.3.2/build.xml0000644000175000017500000000357110415436572015642 0ustar mkochmkoch ow-util-ant-tasks-1.3.2/doc/0000755000175000017500000000000010415430150014542 5ustar mkochmkochow-util-ant-tasks-1.3.2/doc/DependencyAnalyzer.html0000644000175000017500000000626510334334720021233 0ustar mkochmkoch Ant Task

Dependency-analyzer

Description

This task analyzes dependencies between groups of classes and produces a report. Group of class is defined with include/exclude declaration. The report format can be a simple ASCII text printed on screen, or an xml files. This task is based on ASM 2.x.

Here is an exemple of xml report ( the dtd).

The task class is DependencyAnalyser.

Parameters

Attribute Description Required
dir the root directory of classes No
output the report file. If the file extension is xml, the report format is XML, otherwise simple indented text. No (by default the report is on screen)
showContent indicates if the report must list groups content. No (default is false)

Parameters Specified as Nested Elements

group

The group nested element is a fileset. All includes files must be .class file. This nested element has a dir attribute for the root of the fileset. By default the root directory is the one specified at task level.

Examples

This first example analyzes dependencies classes from the directory output/build. There is 3 groups (ejb, jdo and common). The xml report file is output/build/dependency.xml :

<taskdef resource="ow.tasks" classpath="lib/ow_util_ant_tasks.jar">
...
<dependency dir="output/build" showContent="true" 
	output="output/build/dependency.xml">
	<group name="ejb">
		<include name="**/EJB*.class"/>
		<include name="**/ejb/*.class"/>
		<include name="**/ejb/*/*.class"/>
		<include name="javax/persistence/**/*.class"/>
	</group>
	<group name="jdo">
		<include name="**/JDO*.class"/>
		<include name="**/jdo/*.class"/>
		<include name="**/jdo/*/*.class"/>
		<include name="javax/jdo/**/*.class"/>
	</group>
	<group name="common">
		<include name="**/*.class"/>
		<exclude name="**/EJB*.class"/>
		<exclude name="**/JDO*.class"/>
		<exclude name="**/ejb/*.class"/>
		<exclude name="**/ejb/*/*.class"/>
		<exclude name="**/jdo/*.class"/>
		<exclude name="**/jdo/*/*.class"/>
	</group>
</dependency>

Copyright © 2000-2005 France Telecom. All rights Reserved.

ow-util-ant-tasks-1.3.2/doc/JUnitTestReportAggregator.html0000644000175000017500000000432510415430150022524 0ustar mkochmkoch Ant Task

JUnitTestReportAggregator

Description

This task aggregates several JUnit reports localiazed in a hierarchy. It produces an index.html page referencing specified JUnit reports. In addition the index.html contains a summary of each sub JUnit reports.

To use this task, you have to specify at least the 'srcdir' attribute which defines the root location of JUnit report to aggregate. With include/exclude xml node it is possible to specify more precisely which reports must be managed.

The task class is JUnitTestReportAggregator.

Parameters

Attribute Description Required
srcdir the root directory to find JUnit report Yes
destdir the root directory to find JUnit report No (default is the srcdir value)

Examples

This first example creates a report in 'output/test' of all JUnit reports found from this root location:

<taskdef resource="ow.tasks" classpath="lib/ow_util_ant_tasks.jar">
...
<junit-report-aggregator srcdir="output/test"/>


This second example creates a report in 'output' of JUnit reports found from in 'output/test/reports/foo' and 'output/test/reports/bar':

<taskdef resource="ow.tasks" classpath="lib/ow_util_ant_tasks.jar">
...
<junit-report-aggregator srcdir="output/test/reports" destdir="output>
    <include name="foo"/>
    <include name="bar"/>
</junit-report-aggregator>

Copyright © 2000-2005 France Telecom. All rights Reserved.

ow-util-ant-tasks-1.3.2/doc/MultipleAnt.html0000644000175000017500000000477210415430150017700 0ustar mkochmkoch Ant Task

MultipleAnt

Description

This task is an extention of the ant task. It permits to invoke several build.xml file in a same time. This task supports include and exclude node based on the

The task class is MultipleAnt.

Parameters

Attribute Description Required
dir The root location used for include and exclude condition. Yes
antfile the buildfile to use. Defaults to "build.xml". This file is expected to be a filename relative to the dir attribute given. No
target The name of the target to execute in found ant files. If no target is specified the default target of the ant file is run. No

Parameters specified as nested elements

Examples

This first example calls default target of all ant files found in the directory 'foo':

<taskdef resource="ow.tasks" classpath="lib/ow_util_ant_tasks.jar">
...
<multipleant dir="foo"/>


This second example calls default target of ant files found in the directory 'foo' and which the name starts with 'ow_myproject':

<taskdef resource="ow.tasks" classpath="lib/ow_util_ant_tasks.jar">
...
<multipleant dir="foo"/> includes="**/ow_myproject*"


This third example calls the target 'test1' of ant files found in the directory 'foo'':

<taskdef resource="ow.tasks" classpath="lib/ow_util_ant_tasks.jar">
...
<multipleant dir="foo"/> target="test1"

When an ant file does not contains the specified target no error is generated. If no ant file contains the target, then a warning message is printed


Copyright © 2000-2005 France Telecom. All rights Reserved.

ow-util-ant-tasks-1.3.2/doc/antmanual.css0000644000175000017500000000160610415430150017237 0ustar mkochmkoch/* * Copyright 2003-2004 Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ body { background-image:url(/images/beta.png) } code, pre { font-family : "Courier New", Courier, monospace; font-size : 13px; background : #F2F7F2; color : #000000; padding: 4px; white-space: pre; border: 1px black solid; margin: 0px 30px 10px 10px; }ow-util-ant-tasks-1.3.2/doc/index.html0000644000175000017500000000066710415430150016550 0ustar mkochmkoch Objectweb Ant Tasks Documentation <H2>Objectweb Ant Tasks Documentation</H2> <a href="toc.html">Objectweb Ant Tasks Documentation</a> ow-util-ant-tasks-1.3.2/doc/speedo-dependency.xml0000644000175000017500000032427610334333724020706 0ustar mkochmkoch ow-util-ant-tasks-1.3.2/doc/toc.html0000644000175000017500000000136510415430150016222 0ustar mkochmkoch Apache Ant User Manual

Objectweb Tasks

Dependency
Jar2packageList
JavadocMultipleLink
Junit-report-aggregator
Ls
MultipleAnt
MultipleCopy
TokenizedAntCall
Xalan2Liason
Zip
ow-util-ant-tasks-1.3.2/doc/welcome.html0000644000175000017500000000035210334333724017074 0ustar mkochmkoch Objectweb Ant Task documentation ow-util-ant-tasks-1.3.2/src/0000755000175000017500000000000010327703340014572 5ustar mkochmkochow-util-ant-tasks-1.3.2/src/org/0000755000175000017500000000000010267714176015375 5ustar mkochmkochow-util-ant-tasks-1.3.2/src/org/objectweb/0000755000175000017500000000000010267714176017341 5ustar mkochmkochow-util-ant-tasks-1.3.2/src/org/objectweb/util/0000755000175000017500000000000010267714176020316 5ustar mkochmkochow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/0000755000175000017500000000000010415430326021063 5ustar mkochmkochow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/DependencyAnalyzer.java0000644000175000017500000005032510332625546025527 0ustar mkochmkoch/** * Copyright (C) 2001-2005 France Telecom R&D * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) any * later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.objectweb.util.ant; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.util.DOMElementWriter; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Type; import org.objectweb.asm.signature.SignatureReader; import org.objectweb.asm.signature.SignatureVisitor; import org.w3c.dom.Document; import org.w3c.dom.Element; import java.io.BufferedWriter; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; /** * Is an Ant task analyzing a set of java classes for extracting dependencies * between groups of classes. Group is composed with a set of classes. * This task produces report on screen or in a file. The format can be xml * or indented text. * Example: * * * * * * * * * * * * * * * @author S.Chassande-Barrioz */ public class DependencyAnalyzer extends Task { public final static String TAB = "\t"; public interface ClassFilter { boolean accept(File f); } public class Group extends MatchingTask { public String name; private String filterClassName; private ClassFilter filter; private List selectedFiles; private File groupDir; /** * Map>> */ public Map dependencies = new HashMap(); public void setName(String n) { this.name = n; } public void setFilter(String filterClass) { this.filterClassName = filterClass; } public void setDir(File d) { this.groupDir = d; } public Collection getSelectedFiles() { if (selectedFiles == null) { selectedFiles = Arrays.asList(getDirectoryScanner(groupDir) .getIncludedFiles()); Collection toDeselct = Arrays.asList(getDirectoryScanner(groupDir) .getExcludedFiles()); log(toDeselct.toString(), Project.MSG_DEBUG); selectedFiles.removeAll(toDeselct); if (filterClassName != null) { try { filter = (ClassFilter) Class.forName(filterClassName).newInstance(); } catch (Exception e) { throw new BuildException(e.getMessage(), e); } for (Iterator it = selectedFiles.iterator(); it.hasNext();) { String fn = (String) it.next(); if (!filter.accept(new File(dir, fn))) { it.remove(); } } } Collections.sort(selectedFiles); } return selectedFiles; } public void toString(StringBuffer sb, String t0) { final String t1 = t0 + TAB; final String t2 = t1 + TAB; final String t3 = t2 + TAB; sb.append(t0).append("Group: ").append(name).append("\n"); if (showGroupContent) { sb.append(t1).append("contains: \n"); for (Iterator it = getSelectedFiles().iterator(); it.hasNext();) { String fn = (String) it.next(); sb.append(t2).append(fn).append("\n"); } } for (Iterator it = dependencies.entrySet().iterator(); it.hasNext();) { Map.Entry me = (Map.Entry) it.next(); Group cg = (Group) me.getKey(); Map realDep = (Map) me.getValue(); sb.append(t1).append("depends on ").append(cg.name).append( ": \n"); for (Iterator it2 = realDep.entrySet().iterator(); it2 .hasNext();) { Map.Entry me2 = (Map.Entry) it2.next(); String cn = (String) me2.getKey(); List cdeps = (List) me2.getValue(); sb.append(t2).append("class: ").append(cn).append( " depends on:\n"); for (Iterator it3 = cdeps.iterator(); it3.hasNext();) { sb.append(t3).append(it3.next()).append("\n"); } } } } public void toXml(Document doc, Element parent) { Element group = doc.createElement("group"); group.setAttribute("name", name); parent.appendChild(group); if (showGroupContent) { Element gc = doc.createElement("group-content"); gc.setAttribute("size", "" + getSelectedFiles().size()); group.appendChild(gc); for (Iterator it = getSelectedFiles().iterator(); it.hasNext();) { String fn = (String) it.next(); Element c = doc.createElement("class"); c.setAttribute("name", fn); gc.appendChild(c); } } List grouplist = new ArrayList(dependencies.keySet()); Collections.sort(grouplist, new Comparator() { public int compare(Object o1, Object o2) { return ((Group) o1).name.compareTo(((Group) o2).name); } }); for (Iterator it = grouplist.iterator(); it.hasNext();) { Group cg = (Group) it.next(); Map realDep = (Map) dependencies.get(cg); Element gd = doc.createElement("group-dependency"); gd.setAttribute("group-name", cg.name); gd.setAttribute("size", "" + realDep.size()); group.appendChild(gd); List classlist = new ArrayList(realDep.keySet()); Collections.sort(classlist); for (Iterator it2 = classlist.iterator(); it2.hasNext();) { String cn = (String) it2.next(); List cdeps = (List) realDep.get(cn); Collections.sort(cdeps); Element c = doc.createElement("class"); c.setAttribute("name", cn); c.setAttribute("size", "" + cdeps.size()); gd.appendChild(c); for (Iterator it3 = cdeps.iterator(); it3.hasNext();) { Element cd = doc.createElement("class-dependency"); cd.setAttribute("name", (String) it3.next()); c.appendChild(cd); } } } } } /** * Group of classes */ List groups = new ArrayList(); /** * The root location of the file to analyze */ File dir = null; /** * The report file */ File output = null; /** * Indicates if the content of the groups must be included into the report */ boolean showGroupContent = false; /** * map associating a analysed class name to its group */ Map className2group; /** * The list of dependencies which do not belong any defined group */ Set otherClasses = new HashSet(); public void setDir(File d) { this.dir = d; } public void setOutput(File o) { this.output = o; } public void setShowContent(boolean v) { this.showGroupContent = v; } public Group createGroup() { Group group = new Group(); group.setProject(getProject()); groups.add(group); return group; } /** * Produces a report with a simple text format, using tab for indentation * @param out is output stream to use. This OutputStream is not closed at * the end of the method, but only flushed. */ private void toTxt(OutputStream out) throws IOException { StringBuffer sb = new StringBuffer(); for (Iterator it = groups.iterator(); it.hasNext();) { Group cg = (Group) it.next(); cg.toString(sb, ""); } DataOutputStream dos = new DataOutputStream(out); dos.writeUTF(sb.toString()); dos.flush(); } /** * Produces an xml report. * @param out is output stream to use. This OutputStream is not closed at * the end of the method, but only flushed. */ private void toXml(OutputStream out) throws IOException { DocumentBuilder builder; try { builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e1) { throw new IOException(e1.getMessage()); } Document doc = builder.newDocument(); Element rootElement = doc.createElement("dependency"); doc.appendChild(rootElement); for (Iterator it = groups.iterator(); it.hasNext();) { Group cg = (Group) it.next(); cg.toXml(doc, rootElement); } Element gd = doc.createElement("otherClasses"); gd.setAttribute("size", "" + otherClasses.size()); rootElement.appendChild(gd); List classes = new ArrayList(otherClasses); Collections.sort(classes); for (Iterator it = classes.iterator(); it.hasNext();) { Element c = doc.createElement("class"); c.setAttribute("name", (String) it.next()); gd.appendChild(c); } Writer wri = null; wri = new BufferedWriter(new OutputStreamWriter(out, "UTF8")); wri.write("\n"); (new DOMElementWriter()).write(rootElement, wri, 0, " "); wri.flush(); } public void execute() throws BuildException { // build data structure className2group = new HashMap(); for (Iterator itg = groups.iterator(); itg.hasNext();) { Group group = (Group) itg.next(); if (group.groupDir == null) { group.groupDir = dir; } for (Iterator itc = group.getSelectedFiles().iterator(); itc .hasNext();) { String fn = (String) itc.next(); className2group.put(fn, group); } } // analyze dependencies of all classes from all group using an ASM // visitor (inner class below) DependencyVisitor dv = new DependencyVisitor(); for (Iterator itg = groups.iterator(); itg.hasNext();) { Group group = (Group) itg.next(); log("Visit the group: " + group.name, Project.MSG_DEBUG); for (Iterator itc = group.getSelectedFiles().iterator(); itc .hasNext();) { String fn = (String) itc.next(); dv.className = fn; dv.group = group; log("Visit the class: " + fn, Project.MSG_DEBUG); try { File f = new File(group.groupDir, fn); new ClassReader(new FileInputStream(f)).accept(dv, false); } catch (FileNotFoundException e) { log(e.getMessage(), Project.MSG_ERR); } catch (IOException e) { log(e.getMessage(), Project.MSG_ERR); } } } //build the report OutputStream out = null; try { boolean isXmlOutput = false; if (output == null) { //on screen out = System.out; } else { //on file log("Dependency analyse report: " + output.getAbsolutePath()); out = new FileOutputStream(output); //check the file extension if the report must be XML isXmlOutput = output.getName().endsWith(".xml"); } if (isXmlOutput) { toXml(out); } else { toTxt(out); } out.flush(); } catch (IOException exc) { throw new BuildException("Unable to write log file", exc); } finally { if (out != System.out && out != System.err) { if (out != null) { try { out.close(); } catch (IOException e) { // ignore } } } } } private class DependencyVisitor implements AnnotationVisitor, SignatureVisitor, ClassVisitor, FieldVisitor, MethodVisitor { /** * The group of the current analyzed class */ public Group group; /** * The file name of the analyzed class */ public String className; private boolean addDependency(String dep) { if (dep == null) { return false; } dep = dep.replace('/', File.separatorChar) + ".class"; log("has dependency: " + dep, Project.MSG_DEBUG); Group depGroup = (Group) className2group.get(dep); if (depGroup == null) { // depends on a class which belong any group (ex: java.lang.Integer) log("no group: " + dep, Project.MSG_DEBUG); otherClasses.add(dep); return false; } if (depGroup == group) { // both classes belong the same group log("same group", Project.MSG_DEBUG); return false; } // new dependency between classes from different groups Map classDep = (Map) group.dependencies.get(depGroup); if (classDep == null) { // the first group has no existing dependency to the second one log("first dependency on the group: " + depGroup.name, Project.MSG_DEBUG); classDep = new HashMap(); group.dependencies.put(depGroup, classDep); } List cns = (List) classDep.get(className); if (cns == null) { // This class has no dependency to another class log("first dependency for the class: " + className, Project.MSG_DEBUG); cns = new ArrayList(); classDep.put(className, cns); cns.add(dep); return true; } else if (cns.contains(dep)) { log("existing dependency", Project.MSG_DEBUG); return false; } else { cns.add(dep); log("new dependency", Project.MSG_DEBUG); return true; } } // ClassVisitor public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { if (signature == null) { addDependency(superName); addNames(interfaces); } else { addSignature(signature); } } public AnnotationVisitor visitAnnotation(String desc, boolean visible) { addDesc(desc); return this; } public void visitAttribute(Attribute attr) { } public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { if (signature == null) { addDesc(desc); } else { addTypeSignature(signature); } if (value instanceof Type) addType((Type) value); return this; } public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (signature == null) { addMethodDesc(desc); } else { addSignature(signature); } addNames(exceptions); return this; } public void visitSource(String source, String debug) { } public void visitInnerClass(String name, String outerName, String innerName, int access) { // addName( outerName); // addName( innerName); } public void visitOuterClass(String owner, String name, String desc) { // addName(owner); // addMethodDesc(desc); } // MethodVisitor public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { addDesc(desc); return this; } public void visitTypeInsn(int opcode, String desc) { if (desc.charAt(0) == '[') addDesc(desc); else addDependency(desc); } public void visitFieldInsn(int opcode, String owner, String name, String desc) { addDependency(owner); addDesc(desc); } public void visitMethodInsn(int opcode, String owner, String name, String desc) { addDependency(owner); addMethodDesc(desc); } public void visitLdcInsn(Object cst) { if (cst instanceof Type) addType((Type) cst); } public void visitMultiANewArrayInsn(String desc, int dims) { addDesc(desc); } public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) { addTypeSignature(signature); } public AnnotationVisitor visitAnnotationDefault() { return this; } public void visitCode() { } public void visitInsn(int opcode) { } public void visitIntInsn(int opcode, int operand) { } public void visitVarInsn(int opcode, int var) { } public void visitJumpInsn(int opcode, Label label) { } public void visitLabel(Label label) { } public void visitIincInsn(int var, int increment) { } public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) { } public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) { } public void visitTryCatchBlock(Label start, Label end, Label handler, String type) { addDependency(type); } public void visitLineNumber(int line, Label start) { } public void visitMaxs(int maxStack, int maxLocals) { } // AnnotationVisitor public void visit(String name, Object value) { if (value instanceof Type) addType((Type) value); } public void visitEnum(String name, String desc, String value) { addDesc(desc); } public AnnotationVisitor visitAnnotation(String name, String desc) { addDesc(desc); return this; } public AnnotationVisitor visitArray(String name) { return this; } // SignatureVisitor public void visitFormalTypeParameter(String name) { } public SignatureVisitor visitClassBound() { return this; } public SignatureVisitor visitInterfaceBound() { return this; } public SignatureVisitor visitSuperclass() { return this; } public SignatureVisitor visitInterface() { return this; } public SignatureVisitor visitParameterType() { return this; } public SignatureVisitor visitReturnType() { return this; } public SignatureVisitor visitExceptionType() { return this; } public void visitBaseType(char descriptor) { } public void visitTypeVariable(String name) { // TODO verify } public SignatureVisitor visitArrayType() { return this; } public void visitClassType(String name) { addDependency(name); } public void visitInnerClassType(String name) { addDependency(name); } public void visitTypeArgument() { } public SignatureVisitor visitTypeArgument(char wildcard) { return this; } // common public void visitEnd() { } private void addNames(String[] names) { for (int i = 0; names != null && i < names.length; i++) addDependency(names[i]); } private void addDesc(String desc) { addType(Type.getType(desc)); } private void addMethodDesc(String desc) { addType(Type.getReturnType(desc)); Type[] types = Type.getArgumentTypes(desc); for (int i = 0; i < types.length; i++) addType(types[i]); } private void addType(Type t) { switch (t.getSort()) { case Type.ARRAY: addType(t.getElementType()); break; case Type.OBJECT: addDependency(t.getClassName().replace('.', '/')); break; } } private void addSignature(String signature) { if (signature != null) new SignatureReader(signature).accept(this); } private void addTypeSignature(String signature) { if (signature != null) new SignatureReader(signature).acceptType(this); } } } ow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/DirectoryScannerHelper.java0000644000175000017500000000567010415432210026346 0ustar mkochmkoch/** * Copyright (C) 2001-2005 France Telecom R&D */ package org.objectweb.util.ant; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import java.util.Arrays; import java.util.List; /** * This tool class helps the use of DirectoryScanner. * * @author S.Chassande-Barrioz */ public class DirectoryScannerHelper { /** * Extract selected files from a matching task. * @param mt is the matching task * @param root is the file descriptor of the root directory * @return a collection of String corresponding to selected files */ public static List getSelectedFiles(DirectoryScanner ds, Project project) { List result = Arrays.asList(ds.getIncludedFiles()); if (project != null) { project.log("includes=" + result.toString(), Project.MSG_DEBUG); } List toDeselect = Arrays.asList(ds.getExcludedFiles()); if (project != null) { project.log("excludes=" + toDeselect.toString(), Project.MSG_DEBUG); } result.removeAll(toDeselect); if (project != null) { project.log("selected=" + toDeselect.toString(), Project.MSG_DEBUG); } return result; } /** * Extract selected files from a matching task. * @param mt is the matching task * @param root is the file descriptor of the root directory * @return an array of String corresponding to selected files */ public static String[] getSelectedFilesAsString(DirectoryScanner ds, Project project) { return (String[]) getSelectedFiles(ds, project).toArray(new String[0]); } /** * Extract selected directories from a matching task. * @param mt is the matching task * @param root is the file descriptor of the root directory * @return a collection of String corresponding to selected directories */ public static List getSelectedDirectories(DirectoryScanner ds, Project project) { List result = Arrays.asList(ds.getIncludedDirectories()); if (project != null) { project.log("includes=" + result.toString(), Project.MSG_DEBUG); } List toDeselect = Arrays.asList(ds.getExcludedDirectories()); if (project != null) { project.log("excludes=" + toDeselect.toString(), Project.MSG_DEBUG); } result.removeAll(toDeselect); if (project != null) { project.log("selected=" + toDeselect.toString(), Project.MSG_DEBUG); } return result; } /** * Extract selected directories from a matching task. * @param mt is the matching task * @param root is the file descriptor of the root directory * @return an array of String corresponding to selected directories */ public static String[] getSelectedDirectoriesAsString(DirectoryScanner ds, Project project) { return (String[]) getSelectedDirectories(ds, project).toArray(new String[0]); } } ow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/JUnitTestReportAggregator.java0000644000175000017500000003145510330127034027021 0ustar mkochmkoch/** * Copyright (C) 2001-2005 France Telecom R&D */ package org.objectweb.util.ant; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.types.DirSet; import org.apache.tools.ant.types.selectors.SelectSelector; import org.apache.tools.ant.types.selectors.TypeSelector; import org.apache.tools.ant.types.selectors.TypeSelector.FileType; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.io.PushbackReader; import java.io.Reader; import java.math.BigDecimal; /** * This task aggregate JUnit reports by creating an index.html page referencing * existing JUnit reports. In addition it computes statistics of these sub * JUnit reports. * * @author P.Dechamboux * @author S.Chassande-Barrioz */ public class JUnitTestReportAggregator extends MatchingTask { /** * Is the name of the tested area for the JUnit report without sub directory */ private String commonTest = "Common Tests"; /** * the location of each JUnit reports (overview-summary.html file for * instance). */ private File srcdir = null; private File destdir = null; DirSet dirset = new DirSet(); /** * It assigns the directory name where the include and exclude clause has * been based. (REQUIRED) */ public void setsrcdir(File d) { srcdir = d; } /** * It assigns the directory name where the report files are going to be * produced. Default value is the srcdir * @see #srcdir */ public void setdestdir(File d) { destdir = d; } public String getcommonTest() { return commonTest; } public void setcommonTest(String commonTest) { this.commonTest = commonTest; } /** * execute method of the Ant task */ public void execute() throws BuildException { log("Begin of JUnitTestReportAggregator task ", Project.MSG_DEBUG); if (srcdir == null) { throw new BuildException("'srcdir' parameter is not defined in the task JUnitTestReportAggregator"); } log("Source dir=" + srcdir, Project.MSG_DEBUG); if (destdir == null) { log("no dest dir, use the src dir", Project.MSG_DEBUG); destdir = srcdir; } log("Dest dir=" + destdir, Project.MSG_DEBUG); TypeSelector ts = new TypeSelector(); FileType type = new FileType(); type.setValue(FileType.DIR); ts.setType(type); SelectSelector ss = new SelectSelector(); ss.appendSelector(ts); super.addSelector(ss); String[] in_files = super.getDirectoryScanner(srcdir).getIncludedFiles(); if (in_files == null || in_files.length == 0) { super.createInclude().setName("**"); in_files = super.getDirectoryScanner(srcdir).getIncludedFiles(); } //Compute global statistics for summary TestInfo[] infos = new TestInfo[in_files.length + 1]; //The last element is the summary of the n first. infos[in_files.length] = new TestInfo(); infos[in_files.length].time = new BigDecimal(0); infos[in_files.length].time.setScale(3, BigDecimal.ROUND_FLOOR); for (int i = 0; i < in_files.length; i++) { log("Extract info from " + in_files[i], Project.MSG_DEBUG); //Compute meta data for each element infos[i] = extractInfos(in_files[i]); //update statistics infos[in_files.length].nbTests += infos[i].nbTests; infos[in_files.length].nbErrors += infos[i].nbErrors; infos[in_files.length].nbFailures += infos[i].nbFailures; infos[in_files.length].time = infos[in_files.length].time.add(infos[i].time); if (!infos[i].parsingOK) { log("Parsing of " + in_files[i] + " failed", Project.MSG_WARN); } } PrintWriter pw; //create the index.html File destfile = new File(destdir, "index.html"); log("Creating the file " + destfile, Project.MSG_INFO); try { pw = new PrintWriter(new FileOutputStream(destfile)); } catch (FileNotFoundException e) { log(e.getMessage(), Project.MSG_ERR); throw new BuildException(e.getMessage(), e); } log("Writing HTML code", Project.MSG_DEBUG); //Write the HTML code printHeader(pw); pw.println(""); pw.println("" + infos[in_files.length].nbTests + "" + infos[in_files.length].nbFailures + "" + infos[in_files.length].nbErrors + "" + infos[in_files.length].getRate() + "%" + infos[in_files.length].time.toString() + ""); pw.println(""); printMiddle(pw); for (int i = 0; i < in_files.length; i++) { pw.println(""); if (infos[i].parsingOK) { pw.println("" + infos[i].testName + "" + infos[i].nbTests + "" + infos[i].nbErrors + "" + infos[i].nbFailures + "" + infos[i].time.toString() + ""); } else { pw.println("Parsing of " + infos[i].indexhtml + " failed"); } pw.println(""); } printTrailer(pw); pw.flush(); pw.close(); log("End of JUnitTestReportAggregator task", Project.MSG_DEBUG); } /** * Represents meta data about a summary of test */ private static class TestInfo { //the path to the index.html page public String indexhtml; //the name of the test to print in the generated page public String testName; //The number of test public int nbTests = 0; //the number of tests which cause an error public int nbErrors = 0; //the number of tests which cause an failure public int nbFailures = 0; //the duration of tests public BigDecimal time; public boolean parsingOK = true; public BigDecimal getRate() { BigDecimal cent = new BigDecimal(100); BigDecimal rate = new BigDecimal(nbErrors + nbFailures); rate.setScale(2); rate = rate.divide(new BigDecimal(nbTests), 2, BigDecimal.ROUND_FLOOR); rate = cent.multiply(rate); rate = cent.subtract(rate); return rate; } } /** * Parse the index.html page corresponding to the specified file * (has to be in the same directory) in order to compute statistics about * the test summurazing by the index.html page. */ private TestInfo extractInfos(String fn) { TestInfo res = new TestInfo(); if (fn.length() == 0 || ".".equals(fn)) { //no sub directory res.testName = commonTest; } else { // one sub directory at least // test name is computed from the path res.testName = fn.replace('/', '.').replace('\\', '.'); } res.indexhtml = fn + File.separatorChar + "index.html"; //Parse the index.html page to find test statistics try { PushbackReader fr = new PushbackReader( new FileReader(srcdir + File.separator + fn), 10); locateNextString(fr, ""); // now positioned on the number of tests res.nbTests = Integer.parseInt(getString2ClosingTag(fr)); locateNextString(fr, ""); // now positioned on the number of errors res.nbFailures = Integer.parseInt(getString2ClosingTag(fr)); locateNextString(fr, ""); // now positioned on the number of failures res.nbErrors = Integer.parseInt(getString2ClosingTag(fr)); locateNextString(fr, ""); // now positioned on the success rate locateNextString(fr, ""); // now positioned on the execution time res.time = new BigDecimal(getString2ClosingTag(fr)); res.time.setScale(3); } catch (FileNotFoundException e) { res.parsingOK = false; } catch (IOException e) { res.parsingOK = false; } return res; } /** * Search a string in a PushbackReader */ private void locateNextString(PushbackReader fr, String s) throws IOException { int next = fr.read(); char buf[] = null; while (next != -1) { if (next == s.charAt(0)) { if (buf == null) { buf = new char[s.length() - 1]; } int next2 = fr.read(), pos = 1; while ((next2 != -1) && (pos < s.length())) { buf[pos - 1] = (char) next2; if (next2 == s.charAt(pos)) { pos++; next2 = fr.read(); } else { fr.unread(buf, 0, pos); break; } } if (pos == s.length()) { buf[0] = (char) next2; fr.unread(buf, 0, 1); return; } } next = fr.read(); } throw new IOException("Wrong format in test result for JORM - string not found: " + s); } /** * Returns the String value from the current position of a reader and the * next closing tag. * @param fr * @return * @throws IOException */ private String getString2ClosingTag(Reader fr) throws IOException { int next = fr.read(); StringBuffer sb = new StringBuffer(); while (next != -1) { if (next == '<') { break; } sb.append((char) next); next = fr.read(); } return sb.toString(); } /** * Prints in a print writer the header of the html page to generate */ private void printHeader(PrintWriter pw) { pw.println(""); pw.println(""); pw.println(""); pw.println("Unit Test Results: Summary"); pw.println(""); pw.println(""); //pw.println(""); pw.println(""); pw.println("

JORM Unit Test Results

"); pw.println(""); pw.println(""); pw.println(""); pw.println(""); pw.println("
Designed for use with JUnit and Ant.
"); pw.println("
"); pw.println("

Summary

"); pw.println(""); pw.println(""); pw.println(""); pw.println(""); } private void printMiddle(PrintWriter pw) { pw.println("
TestsFailuresErrorsSuccess rateTime
"); pw.println(""); pw.println(""); pw.println(""); pw.println(""); pw.println("
"); pw.println("Note: failures are anticipated and checked for with assertions while errors are unanticipated."); pw.println("
"); pw.println("

Tested area

"); pw.println(""); pw.println(""); pw.println(""); pw.println(""); } private void printTrailer(PrintWriter pw) { pw.println("
NameTestsErrorsFailuresTime(s)
"); pw.println(""); pw.println(""); } }ow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/Jar2packageList.java0000644000175000017500000001621610256006212024676 0ustar mkochmkoch/** * Copyright (C) 2003 France Telecom R&D * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.objectweb.util.ant; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.taskdefs.UpToDate; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FileSet; import java.io.File; import java.io.IOException; import java.io.FileWriter; import java.util.Enumeration; import java.util.Set; import java.util.TreeSet; import java.util.Iterator; import java.util.zip.ZipFile; import java.util.zip.ZipEntry; /** * Permit to build .package-list files since archive files (jar, rar, zip, ...). * * @author S.Chassande-Barrioz */ public class Jar2packageList extends MatchingTask { File jarDir = null; File output = null; boolean flatten = false; boolean isolate = false; /** * The base directory containing archives * @param d */ public void setJarDir(File d) { jarDir = d; } /** * the directory where the .package-list will be generated * @param o */ public void setOutput(File o) { output = o; } public void setFlatten(boolean b) { flatten = b; } public void setIsolate(boolean b) { isolate = b; } public void execute() throws BuildException { String[] filenames = DirectoryScannerHelper.getSelectedFilesAsString( getDirectoryScanner(jarDir), getProject()); boolean hasGenerate = false; for (int i=0; i 0) { // for each found directory searches if contains java source file for (int i=0; itrue if and only if the name should be * included in the file list; false otherwise. */ public boolean accept(File dir, String name) { return name.endsWith(filter); } } } ow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/Ls.java0000644000175000017500000000547710415434626022330 0ustar mkochmkoch/** * Copyright (C) 2002 */ package org.objectweb.util.ant; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; import java.io.File; import java.util.ArrayList; import java.util.Iterator; /** * This simple task permits to list a set of directories. * The result is print on the System.out output. * * @author Sebastien Chassande-Barrioz */ public class Ls extends MatchingTask { /** * Base directory for the include/exclude expression */ File dir = null; /** * name of the property to set */ String propertyName = null; /** * valuer separator for the property */ String separator = ","; /** * Indicates if the search must include simple files */ boolean includeFiles = true; /** * Indicates if the search must include directories */ boolean includeDirectories = false; public void setPropertyName(String pn) { this.propertyName = pn; } public void setSeparator(String separator) { this.separator = separator; } public void setDir(File d) { dir = d; } public void setIncludeDirectories(boolean includeDirectories) { this.includeDirectories = includeDirectories; } public void setIncludeFiles(boolean includeFile) { this.includeFiles = includeFile; } public void execute() throws BuildException { ArrayList fileNames = new ArrayList(); if (includeDirectories) { getProject().log("include directories", Project.MSG_DEBUG); fileNames.addAll(DirectoryScannerHelper.getSelectedDirectories( getDirectoryScanner(dir), getProject())); } if (includeFiles) { getProject().log("include files", Project.MSG_DEBUG); fileNames.addAll(DirectoryScannerHelper.getSelectedFiles( getDirectoryScanner(dir), getProject())); } if (propertyName == null || propertyName.trim().length() == 0) { getProject().log("no property name", Project.MSG_DEBUG); for (Iterator it = fileNames.iterator(); it.hasNext();) { String fileName = (String) it.next(); System.out.println(fileName); } } else { getProject().log("Property name: " + propertyName, Project.MSG_DEBUG); StringBuffer sb = new StringBuffer(); String sep = ""; for (Iterator it = fileNames.iterator(); it.hasNext();) { String fileName = (String) it.next(); sb.append(sep).append(fileName); sep = separator; } getProject().log("value=" + sb.toString(), Project.MSG_DEBUG); getProject().setProperty(propertyName, sb.toString()); } } } ow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/MultipleAnt.java0000644000175000017500000001653710332667652024214 0ustar mkochmkoch/** * @Contributors: 2 && Character.isDigit(s.charAt(0)) && s.charAt(1) == '.') { if ((int)(s.charAt(0) - '0') > 1) { ant16 = true; } else if ((int)(s.charAt(2) - '0') > 5) { ant16 = true; } break; } } // make sure we don't have an illegal set of options validateAttributes(); // deal with the single file if (file != null) { if (file.exists()) { if (destFile == null) { destFile = new File(destDir, file.getName()); } if (!destFile.exists()) if (ant16) fileCopyMap.put(file.getAbsolutePath(), new String[] { destFile.getAbsolutePath() }); else fileCopyMap.put(file.getAbsolutePath(), destFile.getAbsolutePath()); else if (!notReplace && ( forceOverwrite || (file.lastModified() > destFile.lastModified())) ) { if (ant16) fileCopyMap.put(file.getAbsolutePath(), new String[] { destFile.getAbsolutePath() }); else fileCopyMap.put(file.getAbsolutePath(), destFile.getAbsolutePath()); } else { log(file + " omitted as " + destFile + " is up to date.", Project.MSG_VERBOSE); } } else { String message = "Could not find file " + file.getAbsolutePath() + " to copy."; log(message); throw new BuildException(message); } } // deal with the filesets for (int i = 0; i < filesets.size(); i++) { FileSet fs = (FileSet) filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(getProject()); File fromDir = fs.getDir(getProject()); String[] srcFiles = ds.getIncludedFiles(); String[] srcDirs = ds.getIncludedDirectories(); scan(fromDir, destDir, srcFiles, srcDirs); } // do all the copy operations now... doFileOperations(); // clean up destDir again - so this instance can be used a second // time without throwing an exception if (destFile != null) { destDir = null; } } public void setNotReplace(boolean nr) { notReplace = nr; } public void setTodir(File bd) { basedir = bd; } /** * Sets the destination file. */ public void setTofile(String f) { myFile = f; } /////////////////////////////////////////////////////////////// ////////////////////// MATCHING TASK ////////////////////////// /////////////////////////////////////////////////////////////// protected boolean useDefaultExcludes = true; protected FileSet fileset = new FileSet(); /** * add a name entry on the include list */ public PatternSet.NameEntry createInclude() { return fileset.createInclude(); } /** * add a name entry on the include files list */ public PatternSet.NameEntry createIncludesFile() { return fileset.createIncludesFile(); } /** * add a name entry on the exclude list */ public PatternSet.NameEntry createExclude() { return fileset.createExclude(); } /** * add a name entry on the include files list */ public PatternSet.NameEntry createExcludesFile() { return fileset.createExcludesFile(); } /** * add a set of patterns */ public PatternSet createPatternSet() { return fileset.createPatternSet(); } /** * Sets the set of include patterns. Patterns may be separated by a comma * or a space. * * @param includes the string containing the include patterns */ public void setIncludes(String includes) { fileset.setIncludes(includes); } /** * Sets the set of exclude patterns. Patterns may be separated by a comma * or a space. * * @param excludes the string containing the exclude patterns */ public void setExcludes(String excludes) { fileset.setExcludes(excludes); } /** * Sets whether default exclusions should be used or not. * * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions * should be used, "false"|"off"|"no" when they * shouldn't be used. */ public void setDefaultexcludes(boolean useDefaultExcludes) { this.useDefaultExcludes = useDefaultExcludes; } /** * Returns the directory scanner needed to access the files to process. */ protected DirectoryScanner getDirectoryScanner(File baseDir) { fileset.setDir(baseDir); fileset.setDefaultexcludes(useDefaultExcludes); return fileset.getDirectoryScanner(getProject()); } /** * Sets the name of the file containing the includes patterns. * * @param includesfile A string containing the filename to fetch * the include patterns from. */ public void setIncludesfile(File includesfile) { fileset.setIncludesfile(includesfile); } /** * Sets the name of the file containing the includes patterns. * * @param excludesfile A string containing the filename to fetch * the include patterns from. */ public void setExcludesfile(File excludesfile) { fileset.setExcludesfile(excludesfile); } } ow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/TokenizedAntCall.java0000644000175000017500000003137310256006212025124 0ustar mkochmkoch/** * Copyright (C) 2003 France Telecom R&D * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.objectweb.util.ant; import org.apache.tools.ant.taskdefs.CallTarget; import org.apache.tools.ant.taskdefs.Property; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import java.util.StringTokenizer; import java.util.Iterator; import java.util.ArrayList; /** * * @author S.Chassande-Barrioz */ public class TokenizedAntCall extends CallTarget { /** * is the list of tokens */ private String tokenList = ""; /** * is the list of separators */ private String separators = " "; /** * is the name of the variable that receives the current token. */ private String tokenVarName = "token"; private ArrayList props = new ArrayList(); public Property createParam() { Property p = super.createParam(); props.add(p); return p; } public String getTokenList() { return tokenList; } public void setTokenList(String tokenList) { this.tokenList = tokenList; } public String getSeparators() { return separators; } public void setSeparators(String separators) { this.separators = separators; } public String getTokenVarName() { return tokenVarName; } public void setTokenVarName(String tokenVarName) { this.tokenVarName = tokenVarName; } public void execute() throws BuildException { log("tokenList=" + tokenList, Project.MSG_DEBUG); tokenList = getVal(tokenList)[0]; log("effective TokenList=" + tokenList, Project.MSG_DEBUG); log("separators=" + separators, Project.MSG_DEBUG); StringTokenizer st = new StringTokenizer(tokenList, separators, false); while (st.hasMoreTokens()) { String tokenValue = st.nextToken(); log("token value=" + tokenValue, Project.MSG_DEBUG); Property prop = super.createParam(); prop.setName(tokenVarName); prop.setValue(tokenValue); super.execute(); if (st.hasMoreTokens()) { Iterator it = props.iterator(); while (it.hasNext()) { Property old = (Property) it.next(); Property neo = super.createParam(); neo.setName(old.getName()); neo.setValue(old.getValue()); } } } } private String[] getVal(String s) throws BuildException { int begin = s.indexOf("${"); int end = s.indexOf("}"); if (begin == -1) { if (end == -1) { return new String[]{s, ""}; } else { return new String[]{ s.substring(0, end), s.substring(end + 1) }; } } else { if (end == -1) { throw new BuildException("${ without } in the expression " + s); } if (end < begin) { return new String[]{ s.substring(0, end), s.substring(end + 1)}; } else { String res = s.substring(0, begin); String[] ss = getVal(s.substring(begin + 2)); if (ss[0].length() > 0) { String varValue = getProject().getProperty(ss[0]); if (varValue == null) { throw new BuildException("No variable '" + ss[0] + "' found"); } res += varValue; } String[] t = getVal(ss[1]); res += t[0]; return new String[]{res, t[1]}; } } } /* private int curPosInTokenList = 0; private int lastCloseBrackPos = 0; private String effectiveTokenList = ""; private void buildEffectiveTokenList() { while (curPosInTokenList != tokenList.length()) { System.out.println("curPosInTokenList= " + curPosInTokenList); effectiveTokenList += buildPartOfEffectiveTokenList(); } } private String buildPartOfEffectiveTokenList() { System.out.println("buildPartOfEffectiveTokenList"); String res = ""; int begvar = tokenList.indexOf("${", curPosInTokenList); if (begvar == -1) { // Gets the content of tokenList before the opening of variable def res += tokenList.substring(curPosInTokenList, tokenList.length()); curPosInTokenList = tokenList.length(); } else { if (begvar != curPosInTokenList) { // Gets the content of tokenList before the opening of variable def res += tokenList.substring(curPosInTokenList, begvar); curPosInTokenList = begvar; } int endvar = tokenList.indexOf("}", curPosInTokenList + 2); int begnewvar = tokenList.indexOf("${", curPosInTokenList + 2); if (endvar == -1) { // There is no closing of variable def: ignore variable res += tokenList.substring(curPosInTokenList, tokenList.length()); curPosInTokenList = tokenList.length(); lastCloseBrackPos = tokenList.length(); } else if (begnewvar == -1) { // There is no more variable def that follows the current one // OR // The next variable def is after the closing of current one: // sequential definitions! String varname = tokenList.substring(curPosInTokenList + 2, endvar); String value = (String) projectProperties.get(varname); if (value != null) { res += value; } curPosInTokenList = endvar + 1; lastCloseBrackPos = endvar; } else if (endvar < begnewvar) { // There is no more variable def that follows the current one // OR // The next variable def is after the closing of current one: // sequential definitions! String varname = tokenList.substring(curPosInTokenList + 2, endvar); String value = (String) projectProperties.get(varname); if (value != null) { res += value; } res += tokenList.substring(endvar + 1, begnewvar); curPosInTokenList = begnewvar; lastCloseBrackPos = endvar; } else { // The next variable def is before the closing of current one: // embedded definitions! String varname = ""; curPosInTokenList += 2; do { System.out.println("curPosInTokenList= " + curPosInTokenList + ", endvar= " + endvar + ", begnewvar= " + begnewvar); varname += tokenList.substring(curPosInTokenList, begnewvar); curPosInTokenList = begnewvar; varname += buildPartOfEffectiveTokenList(); endvar = tokenList.indexOf("}", curPosInTokenList); begnewvar = tokenList.indexOf("${", curPosInTokenList); if (endvar == -1) { res += "${" + varname + tokenList.substring(curPosInTokenList, tokenList.length()); curPosInTokenList = tokenList.length(); break; } if (begnewvar == -1) { System.out.println("Embbeded variable= " + varname); String value = (String) projectProperties.get(varname); if (value != null) { res += value; } curPosInTokenList = endvar + 1; lastCloseBrackPos = endvar; break; } if (endvar < begnewvar) { System.out.println("Embbeded variable= " + varname); String value = (String) projectProperties.get(varname); if (value != null) { res += value; } curPosInTokenList = endvar + 1; lastCloseBrackPos = endvar; break; } } while (true); } } return res; } public static void main(String[] args) { Properties props = new Properties(); TokenizedAntCall tac = new TokenizedAntCall(); tac.projectProperties = props; props.setProperty("var1", "X"); props.setProperty("var2", "Y"); props.setProperty("num1", "1"); props.setProperty("begvar", "va"); tac.tokenList = "AAAAAAAAAAAAAAAAAA"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [AAAAAAAAAAAAAAAAAA] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "${var1}"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [X] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "AA${var1}AAA"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [AAXAAA] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "AA${var1}AAA${var2}A"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [AAXAAAYA] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "AA${var1}${var2}AAA"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [AAXYAAA] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "${var${num1}}"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [X] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "${${begvar}r${num1}}"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [X] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "${${beg${begvar}r}r${num1}}"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [X] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "${var2"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [${var2] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "AA${${begvar}A"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [AA${vaA] - computed: [" + tac.effectiveTokenList + "]"); tac.tokenList = "${${begvar${num1}}"; tac.curPosInTokenList = 0; tac.lastCloseBrackPos = 0; tac.effectiveTokenList = ""; tac.buildEffectiveTokenList(); System.out.println("Expected Efftective Token List: [${] - computed: [" + tac.effectiveTokenList + "]"); } */ } ow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/Xalan2Liaison.java0000644000175000017500000000540210005171036024366 0ustar mkochmkoch/** * Copyright (C) 2002 */ package org.objectweb.util.ant; import org.apache.tools.ant.taskdefs.XSLTLiaison; import org.apache.xalan.processor.TransformerFactoryImpl; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import javax.xml.transform.Templates; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; /** * This class permits to use the Xalan 2. * * @author Sebastien Chassande-Barrioz */ public class Xalan2Liaison implements XSLTLiaison { /** The trax TransformerFactory */ private TransformerFactory tfactory = null; /** stylesheet stream, close it asap */ private FileInputStream xslStream = null; /** Stylesheet template */ private Templates templates = null; /** transformer */ private Transformer transformer = null; public Xalan2Liaison() throws Exception { tfactory = new TransformerFactoryImpl(); } public void setStylesheet(File stylesheet) throws Exception { xslStream = new FileInputStream(stylesheet); StreamSource src = new StreamSource(xslStream); src.setSystemId(getSystemId(stylesheet)); templates = tfactory.newTemplates(src); transformer = templates.newTransformer(); } public void transform(File infile, File outfile) throws Exception { FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(infile); fos = new FileOutputStream(outfile); StreamSource src = new StreamSource(fis); src.setSystemId(getSystemId(infile)); StreamResult res = new StreamResult(fos); // not sure what could be the need of this... res.setSystemId(getSystemId(outfile)); transformer.transform(src, res); } finally { // make sure to close all handles, otherwise the garbage // collector will close them...whenever possible and // Windows may complain about not being able to delete files. try { if (xslStream != null) { xslStream.close(); } } catch (IOException ignored) { } try { if (fis != null) { fis.close(); } } catch (IOException ignored) { } try { if (fos != null) { fos.close(); } } catch (IOException ignored) { } } } // make sure that the systemid is made of '/' and not '\' otherwise // crimson will complain that it cannot resolve relative entities // because it grabs the base uri via lastIndexOf('/') without // making sure it is really a /'ed path protected String getSystemId(File file) { String path = file.getAbsolutePath(); path = path.replace('\\', '/'); return FILE_PROTOCOL_PREFIX + path; } public void addParam(String name, String value) { transformer.setParameter(name, value); } } ow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/Zip.java0000644000175000017500000000451110415435310022467 0ustar mkochmkochpackage org.objectweb.util.ant; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.ZipFileSet; import java.util.List; import java.util.ArrayList; import java.io.File; /** * Permits to specify a group of zip which only some entries must be zipped. */ public class Zip extends org.apache.tools.ant.taskdefs.Zip { public List zipGroups; public Zip() { super(); zipGroups = new ArrayList(); } public ZipGroup createZipGroup() { ZipGroup g = new ZipGroup(getProject()); zipGroups.add(g); return g; } /** * represents a group of zip */ public class ZipGroup extends MatchingTask { // entries of zip files public ZipEntries theEntries; //contains zip files public File dir = null; public ZipGroup(Project p) { super(); setProject(p); theEntries = new ZipEntries(p); } public ZipEntries createZipEntries() { return theEntries; } public void setDir(File dir) { this.dir = dir; } public String[] getZipFileNames() { return DirectoryScannerHelper.getSelectedFilesAsString( super.getDirectoryScanner(dir), getProject()); } /** * used for the entries of zip files */ class ZipEntries extends MatchingTask { public ZipEntries(Project p) { super(); setProject(p); } public DirectoryScanner getDirectoryScanner(File p) { return super.getDirectoryScanner(p); } public FileSet getInnerFileSet() { return fileset; } } } /** * permit to use the constructor of ZipFileSet with the FileSet parameter */ public class MyZipFileSet extends ZipFileSet { public MyZipFileSet(FileSet fileset, File src) { super(fileset); setSrc(src); } } public void execute() throws BuildException { //foreach group of zip files for (int i = 0; i < zipGroups.size(); i++) { ZipGroup zg = (ZipGroup) zipGroups.get(i); String[] zipfiles = zg.getZipFileNames(); // for each zip file for (int j = 0; j < zipfiles.length; j++) { //create a ZipFileSet using include/exclude for the entries super.addFileset( new MyZipFileSet(zg.theEntries.getInnerFileSet(), new File(zg.dir, zipfiles[j]))); } } super.execute(); } } ow-util-ant-tasks-1.3.2/src/org/objectweb/util/ant/dependency-analyzer.dtd0000644000175000017500000000300110334331502025507 0ustar mkochmkoch ow-util-ant-tasks-1.3.2/src/ow.tasks0000644000175000017500000000107710415430150016265 0ustar mkochmkoch# # This file defines All OW Ant tasks # # # ... # dependency=org.objectweb.util.ant.DependencyAnalyzer jar2packageList=org.objectweb.util.ant.Jar2packageList javadocMultipleLink=org.objectweb.util.ant.JavadocMultipleLink junit-report-aggregator=org.objectweb.util.ant.JUnitTestReportAggregator ls=org.objectweb.util.ant.Ls multipleAnt=org.objectweb.util.ant.MultipleAnt multipleCopy=org.objectweb.util.ant.MultipleCopy owzip=org.objectweb.util.ant.Zip tokenizedantcall=org.objectweb.util.ant.TokenizedAntCall