User: user57
Date: 02/02/27 21:54:09
Modified: tasks/src/main/org/jboss/tools/buildmagic/task/config
Library.java
Added: tasks/src/main/org/jboss/tools/buildmagic/task/config
LibrarySet.java
Log:
o Added LibrarySet, to help make library.classpath
Revision Changes Path
1.2 +21 -2
buildmagic/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java
Index: Library.java
===================================================================
RCS file:
/cvsroot/jboss/buildmagic/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Library.java 28 Feb 2002 05:36:07 -0000 1.1
+++ Library.java 28 Feb 2002 05:54:08 -0000 1.2
@@ -58,7 +58,7 @@
* <p>If no includes/excludes or classpath elements are specified,
* then a default includes of "*" is used.
*
- * @version <tt>$Revision: 1.1 $</tt>
+ * @version <tt>$Revision: 1.2 $</tt>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
*/
public class Library
@@ -72,6 +72,8 @@
protected File root;
protected FileSet classpathSet;
+ protected Path classpath;
+
public void setVendor(final String vendor)
{
this.vendor = vendor;
@@ -134,6 +136,9 @@
*/
public void execute() throws BuildException
{
+ // short circuit if we are done
+ if (classpath != null) return;
+
validate();
log.debug("vendor: " + vendor);
@@ -161,12 +166,26 @@
log.debug("classpathSet: " + classpathSet);
classpathSet.setDir(libDir);
- Path classpath = new Path(project);
+ classpath = new Path(project);
classpath.addFileset(classpathSet);
log.debug("classpath: " + classpath);
// set classpath ref
Map refs = project.getReferences();
refs.put(vendor + "." + name + ".classpath", classpath);
+
+ // help gc
+ vendor = null;
+ name = null;
+ root = null;
+ classpathSet = null;
+ }
+
+ /**
+ * For helper tasks.
+ */
+ public Path getClasspath()
+ {
+ return classpath;
}
}
1.1
buildmagic/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java
Index: LibrarySet.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.tools.buildmagic.task.config;
import java.io.File;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;
import org.jboss.tools.buildmagic.task.MissingAttributeException;
import org.jboss.tools.buildmagic.task.MissingElementException;
import org.jboss.tools.buildmagic.task.util.TaskLogger;
/**
* A helper task to setup a path from a set of library elements.
*
* <p>Usage:
* <xmp>
*
*
*
* </xmp>
*
* @version <tt>$Revision: 1.1 $</tt>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
*/
public class LibrarySet
extends Task
{
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
protected String name;
protected File root;
protected List libraries;
protected Path classpath;
public void setName(final String name)
{
this.name = name;
}
public void setRoot(final File root)
{
this.root = root;
}
public Library createLibrary()
{
Library lib = (Library)project.createTask("library");
if (libraries == null) {
libraries = new ArrayList();
}
libraries.add(lib);
return lib;
}
/**
* Validate the attributes for this task.
*
* @throws BuildException Attributes are not valid.
*/
protected void validate() throws BuildException
{
if (name == null)
throw new MissingAttributeException("name", this);
if (libraries == null)
throw new MissingElementException("library", this);
}
/**
* Execute the task.
*
* @throws BuildException Failed to execute.
*/
public void execute() throws BuildException
{
// short circuit if we are done
if (classpath != null) return;
validate();
log.debug("name: " + name);
log.debug("root: " + root);
// setup the classpath
classpath = new Path(project);
Iterator iter = libraries.iterator();
while (iter.hasNext()) {
Library lib = (Library)iter.next();
// set the root if we have one, else use the libs
if (root != null) {
lib.setRoot(root);
}
// execute
lib.execute();
// append the classpath
classpath.append(lib.getClasspath());
}
log.debug("classpath: " + classpath);
// set classpath ref
Map refs = project.getReferences();
refs.put(name + ".classpath", classpath);
// help gc
name = null;
root = null;
libraries = null;
}
/**
* For helper tasks.
*/
public Path getClasspath()
{
return classpath;
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development