[prev in list] [next in list] [prev in thread] [next in thread]
List: gump
Subject: cvs commit: jakarta-gump/java Project.java
From: rubys () apache ! org
Date: 2003-02-21 21:00:56
[Download RAW message or body]
rubys 2003/02/21 13:00:55
Modified: java Project.java
Log:
Fix tabs
Revision Changes Path
1.52 +592 -592 jakarta-gump/java/Project.java
Index: Project.java
===================================================================
RCS file: /home/cvs/jakarta-gump/java/Project.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- Project.java 21 Feb 2003 19:55:53 -0000 1.51
+++ Project.java 21 Feb 2003 21:00:55 -0000 1.52
@@ -24,8 +24,8 @@
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
@@ -41,7 +41,7 @@
* 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
+ * 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
@@ -58,7 +58,7 @@
* <http://www.apache.org/>.
*
*/
-
+
// DOM classes
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -101,33 +101,33 @@
* @param elements list of <project> elements
*/
public static void load(Enumeration elements) throws Exception {
- Element element = null;
- while (elements.hasMoreElements()) {
- try {
- element = (Element)elements.nextElement();
- new Project(element);
- } catch (Throwable t) {
- System.err.println("Dropping project "
- + element.getAttribute("name")
- + " because of Exception " + t);
- }
- }
-
- // Resolve all references so that the XML can be processed in
- // one pass.
- for (Enumeration e=((Hashtable) projects.clone()).elements(); e.hasMoreElements();) {
- Project p = ((Project)(e.nextElement()));
- try {
- p.expandDepends();
- p.resolveProperties();
- } catch (Throwable t) {
- System.err.println("Dropping project " + p.get("name")
- + " because of Exception " + t);
- p.remove();
- }
- }
-
- sort();
+ Element element = null;
+ while (elements.hasMoreElements()) {
+ try {
+ element = (Element)elements.nextElement();
+ new Project(element);
+ } catch (Throwable t) {
+ System.err.println("Dropping project "
+ + element.getAttribute("name")
+ + " because of Exception " + t);
+ }
+ }
+
+ // Resolve all references so that the XML can be processed in
+ // one pass.
+ for (Enumeration e=((Hashtable) projects.clone()).elements(); e.hasMoreElements();) {
+ Project p = ((Project)(e.nextElement()));
+ try {
+ p.expandDepends();
+ p.resolveProperties();
+ } catch (Throwable t) {
+ System.err.println("Dropping project " + p.get("name")
+ + " because of Exception " + t);
+ p.remove();
+ }
+ }
+
+ sort();
}
/**
@@ -136,7 +136,7 @@
* @return Value of the specified attribute.
*/
public String get(String name) {
- return element.getAttribute(name);
+ return element.getAttribute(name);
}
/**
@@ -144,102 +144,102 @@
* @param element <project> element
*/
public Project(Element element) throws Exception {
- this.element = element;
- document = element.getOwnerDocument();
- name = element.getAttribute("name");
-
- Element home = null;
- Element javadoc = null;
-
- Node child=element.getFirstChild();
- for (; child != null; child=child.getNextSibling()) {
- if (child.getNodeName().equals("depend")) {
- dependsOn.put(((Element)child).getAttribute("project"), child);
- } else if (child.getNodeName().equals("option")) {
- dependsOn.put(((Element)child).getAttribute("project"), child);
- } else if (child.getNodeName().equals("ant")) {
- if (ant != null) {
- // multiple ant children? Merge them!
- Jenny.moveChildren(ant, (Element)child);
- element.removeChild(ant);
- }
- ant = (Element)child;
- } else if (child.getNodeName().equals("home")) {
- home = (Element)child;
- } else if (child.getNodeName().equals("description")) {
- description = (Element)child;
- } else if (child.getNodeName().equals("url")) {
- url = (Element)child;
- } else if (child.getNodeName().equals("javadoc")) {
- javadoc = (Element)child;
- } else if (child.getNodeName().equals("jar")) {
- jars.put(((Element)child).getAttribute("id"), child);
- } else if (child.getNodeName().equals("deliver")) {
- deliver.add(child);
- } else if (child.getNodeName().equals("nag")) {
- expandNag((Element) child);
- } else if (child.getNodeName().equals("redistributable")) {
- redistributable = true;
- }
- }
-
- computeHome(home);
-
- if (ant != null) {
- genProperties(ant);
- genDepends(ant);
- if (!get("target").equals("")) {
- ant.setAttribute("target", get("target"));
- }
- }
-
- resolveJavadoc(javadoc);
- handleDeliver();
-
- // if only one jar is found, make sure that it can be accessed without
- // specifying an id.
- if (jars.size() == 1) {
- jars.put("", jars.elements().nextElement());
- }
+ this.element = element;
+ document = element.getOwnerDocument();
+ name = element.getAttribute("name");
+
+ Element home = null;
+ Element javadoc = null;
+
+ Node child=element.getFirstChild();
+ for (; child != null; child=child.getNextSibling()) {
+ if (child.getNodeName().equals("depend")) {
+ dependsOn.put(((Element)child).getAttribute("project"), child);
+ } else if (child.getNodeName().equals("option")) {
+ dependsOn.put(((Element)child).getAttribute("project"), child);
+ } else if (child.getNodeName().equals("ant")) {
+ if (ant != null) {
+ // multiple ant children? Merge them!
+ Jenny.moveChildren(ant, (Element)child);
+ element.removeChild(ant);
+ }
+ ant = (Element)child;
+ } else if (child.getNodeName().equals("home")) {
+ home = (Element)child;
+ } else if (child.getNodeName().equals("description")) {
+ description = (Element)child;
+ } else if (child.getNodeName().equals("url")) {
+ url = (Element)child;
+ } else if (child.getNodeName().equals("javadoc")) {
+ javadoc = (Element)child;
+ } else if (child.getNodeName().equals("jar")) {
+ jars.put(((Element)child).getAttribute("id"), child);
+ } else if (child.getNodeName().equals("deliver")) {
+ deliver.add(child);
+ } else if (child.getNodeName().equals("nag")) {
+ expandNag((Element) child);
+ } else if (child.getNodeName().equals("redistributable")) {
+ redistributable = true;
+ }
+ }
+
+ computeHome(home);
- projects.put(name, this);
+ if (ant != null) {
+ genProperties(ant);
+ genDepends(ant);
+ if (!get("target").equals("")) {
+ ant.setAttribute("target", get("target"));
+ }
+ }
+
+ resolveJavadoc(javadoc);
+ handleDeliver();
+
+ // if only one jar is found, make sure that it can be accessed without
+ // specifying an id.
+ if (jars.size() == 1) {
+ jars.put("", jars.elements().nextElement());
+ }
+
+ projects.put(name, this);
}
/**
- * Replace ant "depend" elements with "property" elements. This is
+ * Replace ant "depend" elements with "property" elements. This is
* a convenience "syntatic sugar" that makes for simpler project
- * definitions. Attribute "property" becomes name. Attributes
+ * definitions. Attribute "property" becomes name. Attributes
* reference="jarpath" and classpath="true" are added.
* @param ant <ant> element to be processed
*/
private void genProperties(Element ant) throws Exception {
- Node child=ant.getFirstChild();
- while (child != null) {
- Node next = child.getNextSibling();
-
- if (child.getNodeName().equals("depend")) {
- // create a new element based on existing element
- Element property = document.createElement("property");
- property.setAttribute("reference", "jarpath");
- property.setAttribute("classpath", "add");
- Jenny.moveChildren((Element)child, property);
-
- // change property attribute to name attribute
- if (property.getAttributeNode("name")==null) {
- Attr pname = property.getAttributeNode("property");
- if (pname != null) {
- property.setAttribute("name",pname.getValue());
- property.removeAttributeNode(pname);
- }
- }
-
- // replace existing element with new one
- ant.replaceChild(property, child);
- }
+ Node child=ant.getFirstChild();
+ while (child != null) {
+ Node next = child.getNextSibling();
+
+ if (child.getNodeName().equals("depend")) {
+ // create a new element based on existing element
+ Element property = document.createElement("property");
+ property.setAttribute("reference", "jarpath");
+ property.setAttribute("classpath", "add");
+ Jenny.moveChildren((Element)child, property);
+
+ // change property attribute to name attribute
+ if (property.getAttributeNode("name")==null) {
+ Attr pname = property.getAttributeNode("property");
+ if (pname != null) {
+ property.setAttribute("name",pname.getValue());
+ property.removeAttributeNode(pname);
+ }
+ }
+
+ // replace existing element with new one
+ ant.replaceChild(property, child);
+ }
- child = next;
- }
+ child = next;
+ }
}
/**
@@ -247,91 +247,91 @@
* @param ant <ant> element to be processed
*/
private void genDepends(Element ant) throws Exception {
- Node child=ant.getFirstChild();
- for (;child!=null; child=child.getNextSibling()) {
- if (!child.getNodeName().equals("property")) continue;
- Element property = (Element) child;
-
- String dependency = property.getAttribute("project");
- if (dependency.equals("")) continue;
- if (dependency.equals(name)) continue;
- if (dependsOn.get(dependency) != null) continue;
-
- if (property.getAttribute("reference").equals("srcdir")) continue;
-
- Element depend = document.createElement("depend");
- depend.setAttribute("project", dependency);
- if (property.getAttributeNode("classpath") == null) {
- depend.appendChild(document.createElement("noclasspath"));
- }
+ Node child=ant.getFirstChild();
+ for (;child!=null; child=child.getNextSibling()) {
+ if (!child.getNodeName().equals("property")) continue;
+ Element property = (Element) child;
+
+ String dependency = property.getAttribute("project");
+ if (dependency.equals("")) continue;
+ if (dependency.equals(name)) continue;
+ if (dependsOn.get(dependency) != null) continue;
+
+ if (property.getAttribute("reference").equals("srcdir")) continue;
+
+ Element depend = document.createElement("depend");
+ depend.setAttribute("project", dependency);
+ if (property.getAttributeNode("classpath") == null) {
+ depend.appendChild(document.createElement("noclasspath"));
+ }
- Attr runtime = property.getAttributeNode("runtime");
- if (runtime != null) {
- depend.setAttribute("runtime", runtime.getValue());
- }
+ Attr runtime = property.getAttributeNode("runtime");
+ if (runtime != null) {
+ depend.setAttribute("runtime", runtime.getValue());
+ }
- element.appendChild(depend);
- dependsOn.put(dependency, depend);
- }
+ element.appendChild(depend);
+ dependsOn.put(dependency, depend);
+ }
}
/**
- * Resolve home directory. In the process copy any description and
+ * Resolve home directory. In the process copy any description and
* url elements necessary to complete this definition.
* @param home <ant> element which may contain info
*/
private void computeHome(Element home) {
- String basedir = Workspace.getBaseDir();
+ String basedir = Workspace.getBaseDir();
- Module module = Module.find(element.getAttribute("module"));
- if (module == null) return;
+ Module module = Module.find(element.getAttribute("module"));
+ if (module == null) return;
- String srcdir;
- String pkg = element.getAttribute("package");
- if (pkg.equals("")) {
- srcdir = module.getSrcDir();
- } else {
- srcdir = Workspace.getPkgDir() + "/" + pkg;
- }
- element.setAttribute("srcdir", srcdir);
-
- // if a description is not provided, copy the one from the module
- if (description == null) {
- description = module.getDescription();
- if (description != null) {
- element.appendChild(description.cloneNode(true));
- }
- }
-
- // if a url is not provided, copy the one from the module
- if (url == null) {
- url = module.getUrl();
- if (url != null) {
- element.appendChild(url.cloneNode(true));
- }
- }
-
- // compute home directory
- String result=element.getAttribute("home");
- if (result.equals("")) {
- if (home != null) {
- String attr;
- if (! (attr=home.getAttribute("parent")).equals("")) {
- result = basedir + "/" + attr;
- } else if (! (attr=home.getAttribute("nested")).equals("")) {
- result = srcdir + "/" + attr;
- } else if (! (attr=home.getAttribute("dir")).equals("")) {
- result = attr;
- }
- }
-
- if (result.equals("")) result=srcdir;
- element.setAttribute("home", result);
- } else {
- element.setAttribute("srcdir", result);
- }
+ String srcdir;
+ String pkg = element.getAttribute("package");
+ if (pkg.equals("")) {
+ srcdir = module.getSrcDir();
+ } else {
+ srcdir = Workspace.getPkgDir() + "/" + pkg;
+ }
+ element.setAttribute("srcdir", srcdir);
+
+ // if a description is not provided, copy the one from the module
+ if (description == null) {
+ description = module.getDescription();
+ if (description != null) {
+ element.appendChild(description.cloneNode(true));
+ }
+ }
- redistributable |= module.getRedistributable();
+ // if a url is not provided, copy the one from the module
+ if (url == null) {
+ url = module.getUrl();
+ if (url != null) {
+ element.appendChild(url.cloneNode(true));
+ }
+ }
+
+ // compute home directory
+ String result=element.getAttribute("home");
+ if (result.equals("")) {
+ if (home != null) {
+ String attr;
+ if (! (attr=home.getAttribute("parent")).equals("")) {
+ result = basedir + "/" + attr;
+ } else if (! (attr=home.getAttribute("nested")).equals("")) {
+ result = srcdir + "/" + attr;
+ } else if (! (attr=home.getAttribute("dir")).equals("")) {
+ result = attr;
+ }
+ }
+
+ if (result.equals("")) result=srcdir;
+ element.setAttribute("home", result);
+ } else {
+ element.setAttribute("srcdir", result);
+ }
+
+ redistributable |= module.getRedistributable();
}
/**
@@ -340,74 +340,74 @@
* self contained.
*/
private void expandDepends() throws Exception {
- String jardir = Workspace.getJarDir();
+ String jardir = Workspace.getJarDir();
+
+ if (redistributable) {
+ element.setAttribute("redistributable","true");
+ }
+
+ for (Enumeration e=dependsOn.keys(); e.hasMoreElements(); ) {
+ String name = (String)e.nextElement();
+ Element depend = (Element) dependsOn.get(name);
+ Project target = (Project)projects.get(name);
+
+ String idsAttr = depend.getAttribute("ids");
+ StringTokenizer tok = new StringTokenizer(idsAttr, " ", false);
+ Vector jarIds = new Vector();
+ while (tok.hasMoreTokens()) {
+ jarIds.add(tok.nextToken());
+ }
- if (redistributable) {
- element.setAttribute("redistributable","true");
- }
-
- for (Enumeration e=dependsOn.keys(); e.hasMoreElements(); ) {
- String name = (String)e.nextElement();
- Element depend = (Element) dependsOn.get(name);
- Project target = (Project)projects.get(name);
-
- String idsAttr = depend.getAttribute("ids");
- StringTokenizer tok = new StringTokenizer(idsAttr, " ", false);
- Vector jarIds = new Vector();
- while (tok.hasMoreTokens()) {
- jarIds.add(tok.nextToken());
- }
-
- boolean buildable = false;
-
- if (!depend.getNodeName().equals("option")) {
- require(target, "project", name);
- }
- if (target == null) continue;
-
- target.referencedBy.put(this, depend);
- depend.setAttribute("home",target.get("home"));
- depend.setAttribute("defined-in",target.get("defined-in"));
-
- Node child=target.element.getFirstChild();
- for (; child != null; child=child.getNextSibling()) {
- if (child.getNodeName().equals("jar")) {
- String id = ((Element) child).getAttribute("id");
- if (idsAttr.equals("")) {
- depend.appendChild(child.cloneNode(false));
+ boolean buildable = false;
+
+ if (!depend.getNodeName().equals("option")) {
+ require(target, "project", name);
+ }
+ if (target == null) continue;
+
+ target.referencedBy.put(this, depend);
+ depend.setAttribute("home",target.get("home"));
+ depend.setAttribute("defined-in",target.get("defined-in"));
+
+ Node child=target.element.getFirstChild();
+ for (; child != null; child=child.getNextSibling()) {
+ if (child.getNodeName().equals("jar")) {
+ String id = ((Element) child).getAttribute("id");
+ if (idsAttr.equals("")) {
+ depend.appendChild(child.cloneNode(false));
} else if (!id.equals("") && jarIds.contains(id)) {
- depend.appendChild(child.cloneNode(false));
+ depend.appendChild(child.cloneNode(false));
jarIds.remove(id);
- }
- } else if (child.getNodeName().equals("ant")) {
- depend.appendChild(document.createElement("ant"));
- buildable = true;
- } else if (child.getNodeName().equals("script")) {
- depend.appendChild(document.createElement("script"));
- buildable = true;
- }
- }
+ }
+ } else if (child.getNodeName().equals("ant")) {
+ depend.appendChild(document.createElement("ant"));
+ buildable = true;
+ } else if (child.getNodeName().equals("script")) {
+ depend.appendChild(document.createElement("script"));
+ buildable = true;
+ }
+ }
if (jarIds.size()>0) {
- throw new Exception(
- "A jar with id \"" + jarIds.firstElement() +
- "\" was not found in project \"" +
- this.name + "\" referenced by project " + name);
- }
-
- if (buildable && !jardir.equals("") && target.isRedistributable()) {
- String module = target.get("module");
- depend.setAttribute("home", jardir + "/" + module);
- child=depend.getFirstChild();
- for (; child != null; child=child.getNextSibling()) {
- if (child.getNodeName().equals("jar")) {
- String jarname = ((Element)child).getAttribute("name");
- jarname = jarname.substring(jarname.lastIndexOf("/")+1);
- ((Element)child).setAttribute("name", jarname);
- }
- }
- }
- }
+ throw new Exception(
+ "A jar with id \"" + jarIds.firstElement() +
+ "\" was not found in project \"" +
+ this.name + "\" referenced by project " + name);
+ }
+
+ if (buildable && !jardir.equals("") && target.isRedistributable()) {
+ String module = target.get("module");
+ depend.setAttribute("home", jardir + "/" + module);
+ child=depend.getFirstChild();
+ for (; child != null; child=child.getNextSibling()) {
+ if (child.getNodeName().equals("jar")) {
+ String jarname = ((Element)child).getAttribute("name");
+ jarname = jarname.substring(jarname.lastIndexOf("/")+1);
+ ((Element)child).setAttribute("name", jarname);
+ }
+ }
+ }
+ }
}
/**
@@ -417,10 +417,10 @@
* @return true if this project is ready to go
*/
private boolean isReady(Set todo) {
- for (Enumeration e=dependsOn.keys(); e.hasMoreElements();) {
- if (todo.contains(e.nextElement())) return false;
- }
- return true;
+ for (Enumeration e=dependsOn.keys(); e.hasMoreElements();) {
+ if (todo.contains(e.nextElement())) return false;
+ }
+ return true;
}
/**
@@ -429,111 +429,111 @@
* @return true if this project is holding up progress
*/
private boolean isPrereq(Set todo) {
- for (Enumeration e=referencedBy.keys(); e.hasMoreElements();) {
- Project p = (Project)e.nextElement();
- if (todo.contains(p.name)) return true;
- }
- return false;
+ for (Enumeration e=referencedBy.keys(); e.hasMoreElements();) {
+ Project p = (Project)e.nextElement();
+ if (todo.contains(p.name)) return true;
+ }
+ return false;
}
/**
* Move this element to the end of the parents set of children.
*/
private void moveToLast() {
- Element parent = (Element) element.getParentNode();
- parent.removeChild(element);
- parent.appendChild(element);
+ Element parent = (Element) element.getParentNode();
+ parent.removeChild(element);
+ parent.appendChild(element);
}
/**
- * Process all inherited dependencies.
+ * Process all inherited dependencies.
*/
private void inheritDependencies() {
- Vector inheritance = new Vector();
+ Vector inheritance = new Vector();
- for (Enumeration e=dependsOn.elements(); e.hasMoreElements(); ) {
- Element depend = (Element) e.nextElement();
- String inherit = depend.getAttribute("inherit");
- Project p = (Project) projects.get(depend.getAttribute("project"));
- if (p == null) continue;
-
- for (Enumeration d=p.dependsOn.keys(); d.hasMoreElements(); ) {
- String name = (String) d.nextElement();
- if (dependsOn.get(name) != null) continue;
- Element source = (Element) p.dependsOn.get(name);
- String type = source.getNodeName();
-
- // if inherit="all" is specified on a depends element, then all
- // of the optional and depends elements on the referenced
- // project are inherited by this project.
- //
- // if inherit="hard", the same thing happens except that all
- // optional dependencies are converted to "hard" dependencies
- // in the copy.
- if (inherit.equals("all") || inherit.equals("hard")) {
- Element clone = (Element) source.cloneNode(true);
- if (inherit.equals("hard") && type.equals("option")) {
- Element renamed = document.createElement("depend");
- Jenny.moveChildren(clone, renamed);
- clone = renamed;
- }
- inheritance.add(clone);
-
- // look for runtime="true" dependencies in the referenced
- // project. Convert depends to options if the reference to
- // the project is an option.
- } else if (inherit.equals("runtime")) {
- if (source.getAttribute("runtime").equals("true")) {
- Element clone = (Element) source.cloneNode(true);
- if (type.equals("option")) {
- Element renamed = document.createElement("option");
- Jenny.moveChildren(clone, renamed);
- clone = renamed;
- }
- inheritance.add(clone);
- }
- }
-
- // if this project depends on any project which in turn has
- // a dependency which specifies inherit="jars", then inherit
- // that dependency.
- if (source.getAttribute("inherit").equals("jars")) {
- Element clone = (Element) source.cloneNode(true);
- clone.setAttribute("runtime", "true");
- inheritance.add(clone);
- }
- }
- }
-
- // Add the inherited nodes
- for (Enumeration e=inheritance.elements(); e.hasMoreElements(); ) {
- Element inherited = (Element) e.nextElement();
- String project = inherited.getAttribute("project");
- if (dependsOn.get(project) == null) {
- inherited.setAttribute("inherited", "true");
- dependsOn.put(project, inherited);
- element.appendChild(inherited);
- }
- }
+ for (Enumeration e=dependsOn.elements(); e.hasMoreElements(); ) {
+ Element depend = (Element) e.nextElement();
+ String inherit = depend.getAttribute("inherit");
+ Project p = (Project) projects.get(depend.getAttribute("project"));
+ if (p == null) continue;
+
+ for (Enumeration d=p.dependsOn.keys(); d.hasMoreElements(); ) {
+ String name = (String) d.nextElement();
+ if (dependsOn.get(name) != null) continue;
+ Element source = (Element) p.dependsOn.get(name);
+ String type = source.getNodeName();
+
+ // if inherit="all" is specified on a depends element, then all
+ // of the optional and depends elements on the referenced
+ // project are inherited by this project.
+ //
+ // if inherit="hard", the same thing happens except that all
+ // optional dependencies are converted to "hard" dependencies
+ // in the copy.
+ if (inherit.equals("all") || inherit.equals("hard")) {
+ Element clone = (Element) source.cloneNode(true);
+ if (inherit.equals("hard") && type.equals("option")) {
+ Element renamed = document.createElement("depend");
+ Jenny.moveChildren(clone, renamed);
+ clone = renamed;
+ }
+ inheritance.add(clone);
+
+ // look for runtime="true" dependencies in the referenced
+ // project. Convert depends to options if the reference to
+ // the project is an option.
+ } else if (inherit.equals("runtime")) {
+ if (source.getAttribute("runtime").equals("true")) {
+ Element clone = (Element) source.cloneNode(true);
+ if (type.equals("option")) {
+ Element renamed = document.createElement("option");
+ Jenny.moveChildren(clone, renamed);
+ clone = renamed;
+ }
+ inheritance.add(clone);
+ }
+ }
+
+ // if this project depends on any project which in turn has
+ // a dependency which specifies inherit="jars", then inherit
+ // that dependency.
+ if (source.getAttribute("inherit").equals("jars")) {
+ Element clone = (Element) source.cloneNode(true);
+ clone.setAttribute("runtime", "true");
+ inheritance.add(clone);
+ }
+ }
+ }
+
+ // Add the inherited nodes
+ for (Enumeration e=inheritance.elements(); e.hasMoreElements(); ) {
+ Element inherited = (Element) e.nextElement();
+ String project = inherited.getAttribute("project");
+ if (dependsOn.get(project) == null) {
+ inherited.setAttribute("inherited", "true");
+ dependsOn.put(project, inherited);
+ element.appendChild(inherited);
+ }
+ }
}
/**
* Implement a deterministing sort order. Projects which are most
- * referenced get priority. After that, order is determined alphabetically.
+ * referenced get priority. After that, order is determined alphabetically.
*/
private static class Ranker implements Comparator {
- public int compare(Object o1, Object o2) {
- Project p1 = (Project) projects.get(o1);
- Project p2 = (Project) projects.get(o2);
- if (p1 == p2) return 0;
- if (p1 == null) return -1;
- if (p2 == null) return 1;
+ public int compare(Object o1, Object o2) {
+ Project p1 = (Project) projects.get(o1);
+ Project p2 = (Project) projects.get(o2);
+ if (p1 == p2) return 0;
+ if (p1 == null) return -1;
+ if (p2 == null) return 1;
- int diff = p2.referencedBy.size() - p1.referencedBy.size();
- if (diff != 0) return diff;
+ int diff = p2.referencedBy.size() - p1.referencedBy.size();
+ if (diff != 0) return diff;
- return ((String)o1).compareTo((String)o2);
- }
+ return ((String)o1).compareTo((String)o2);
+ }
}
/**
@@ -543,143 +543,143 @@
* way the inheritance will recurse properly.
*/
private static void sort() throws Exception {
- TreeSet todo = new TreeSet(new Ranker());
- todo.addAll(projects.keySet());
+ TreeSet todo = new TreeSet(new Ranker());
+ todo.addAll(projects.keySet());
+
+ // As long as there are projects which are ready, put the next
+ // available one at the end of the list.
+ for (Iterator i=todo.iterator(); i.hasNext();) {
+ Project p = (Project) projects.get(i.next());
+ if (p.isReady(todo)) {
+ p.moveToLast();
+ p.inheritDependencies();
+ todo.remove(p.name);
+ i=todo.iterator();
+ }
+ }
+
+ // Did we succeed?
+ if (todo.isEmpty()) return;
- // As long as there are projects which are ready, put the next
- // available one at the end of the list.
- for (Iterator i=todo.iterator(); i.hasNext();) {
- Project p = (Project) projects.get(i.next());
- if (p.isReady(todo)) {
- p.moveToLast();
- p.inheritDependencies();
- todo.remove(p.name);
- i=todo.iterator();
- }
- }
-
- // Did we succeed?
- if (todo.isEmpty()) return;
-
- // Remove all elements which are not prereqed by any projects
- // remaining
- if (todo.isEmpty()) return;
- for (Iterator i=todo.iterator(); i.hasNext();) {
- Project p = (Project) projects.get(i.next());
- if (!p.isPrereq(todo)) {
- todo.remove(p.name);
- i=todo.iterator();
- }
- }
-
-
- // Construct a list of the rest, and throw an exception
- String message="Circular dependency loop involving:";
- for (Iterator i=todo.iterator(); i.hasNext();) {
- Project p = (Project) projects.get(i.next());
- message += "\n " + p.name;
- }
- throw new Exception(message);
+ // Remove all elements which are not prereqed by any projects
+ // remaining
+ if (todo.isEmpty()) return;
+ for (Iterator i=todo.iterator(); i.hasNext();) {
+ Project p = (Project) projects.get(i.next());
+ if (!p.isPrereq(todo)) {
+ todo.remove(p.name);
+ i=todo.iterator();
+ }
+ }
+
+
+ // Construct a list of the rest, and throw an exception
+ String message="Circular dependency loop involving:";
+ for (Iterator i=todo.iterator(); i.hasNext();) {
+ Project p = (Project) projects.get(i.next());
+ message += "\n " + p.name;
+ }
+ throw new Exception(message);
}
/**
* Resolve property references, based on the value of "reference"
- * attribute (if present). Supported values for reference are:
+ * attribute (if present). Supported values for reference are:
*
* <ul>
* <li> home: the home directory for the referenced project </li>
- * <li> jar: the simple name (path relative to home) of the jar in a
+ * <li> jar: the simple name (path relative to home) of the jar in a
* referenced project. </li>
- * <li> jarpath: the fully qualified path of the jar in a referenced
+ * <li> jarpath: the fully qualified path of the jar in a referenced
* project. </li>
* <li> srcdir: the srcdir for the module containing the project. </li>
- * <li> path: a path which is to be interpreted relative to the srcdir
+ * <li> path: a path which is to be interpreted relative to the srcdir
* for the module containing this project </li>
* </ul>
*/
private void resolveProperties() throws Exception {
- if (ant == null) return;
+ if (ant == null) return;
- Node child=ant.getFirstChild();
- for (;child!=null; child=child.getNextSibling()) {
- if (!child.getNodeName().equals("property")) continue;
- Element property = (Element) child;
- if (property.getAttributeNode("value") != null) continue;
-
- String reference = property.getAttribute("reference");
- String projectName = property.getAttribute("project");
-
- String value = null;
-
- if (reference.equals("home")) {
- Project project = (Project) projects.get(projectName);
- require (project, "project", projectName);
- value = project.get("home");
- property.setAttribute("type", "path");
- } else if (reference.equals("jar")) {
- String id = property.getAttribute("id");
- Element jar = getJar (projectName, property.getAttribute("id"));
- value = jar.getAttribute("name");
- } else if (reference.equals("jarpath")) {
- Project project = (Project) projects.get(projectName);
- Element jar = getJar (projectName, property.getAttribute("id"));
- value = project.get("home") + "/" + jar.getAttribute("name");
- property.setAttribute("type", "path");
- } else if (reference.equals("srcdir")) {
- Project project = (Project) projects.get(projectName);
- require (project, "project", projectName);
- Module module = Module.find(project.get("module"));
- require (module, "module containing project", projectName);
- value = module.getSrcDir();
- property.setAttribute("type", "path");
- } else if (property.getAttributeNode("path") != null) {
- Project project = (Project) projects.get(projectName);
- if (project == null) project=this;
- value = project.get("srcdir");
- value += "/" + property.getAttribute("path");
- property.setAttribute("type", "path");
- }
+ Node child=ant.getFirstChild();
+ for (;child!=null; child=child.getNextSibling()) {
+ if (!child.getNodeName().equals("property")) continue;
+ Element property = (Element) child;
+ if (property.getAttributeNode("value") != null) continue;
+
+ String reference = property.getAttribute("reference");
+ String projectName = property.getAttribute("project");
+
+ String value = null;
+
+ if (reference.equals("home")) {
+ Project project = (Project) projects.get(projectName);
+ require (project, "project", projectName);
+ value = project.get("home");
+ property.setAttribute("type", "path");
+ } else if (reference.equals("jar")) {
+ String id = property.getAttribute("id");
+ Element jar = getJar (projectName, property.getAttribute("id"));
+ value = jar.getAttribute("name");
+ } else if (reference.equals("jarpath")) {
+ Project project = (Project) projects.get(projectName);
+ Element jar = getJar (projectName, property.getAttribute("id"));
+ value = project.get("home") + "/" + jar.getAttribute("name");
+ property.setAttribute("type", "path");
+ } else if (reference.equals("srcdir")) {
+ Project project = (Project) projects.get(projectName);
+ require (project, "project", projectName);
+ Module module = Module.find(project.get("module"));
+ require (module, "module containing project", projectName);
+ value = module.getSrcDir();
+ property.setAttribute("type", "path");
+ } else if (property.getAttributeNode("path") != null) {
+ Project project = (Project) projects.get(projectName);
+ if (project == null) project=this;
+ value = project.get("srcdir");
+ value += "/" + property.getAttribute("path");
+ property.setAttribute("type", "path");
+ }
- if (value != null) property.setAttribute("value", value);
- }
+ if (value != null) property.setAttribute("value", value);
+ }
}
/**
- * Locate a specific jar from a dependency, issuing an exception if
+ * Locate a specific jar from a dependency, issuing an exception if
* the jar can not be found.
* @param projectName the name of the project
* @param id the identifier for which jar is desired
* @return Value of the specified attribute.
*/
- private Element getJar(String projectName, String id)
- throws Exception
+ private Element getJar(String projectName, String id)
+ throws Exception
{
- Project project = (Project) projects.get(projectName);
- require (project, "project", projectName);
+ Project project = (Project) projects.get(projectName);
+ require (project, "project", projectName);
- Element jar = (Element)project.jars.get(id);
- if (jar != null) return jar;
+ Element jar = (Element)project.jars.get(id);
+ if (jar != null) return jar;
- if (!id.equals("")) {
+ if (!id.equals("")) {
- throw new Exception(
- "A jar with id \"" + id + "\" was not found in project \"" +
- projectName + "\" referenced by project " + name);
+ throw new Exception(
+ "A jar with id \"" + id + "\" was not found in project \"" +
+ projectName + "\" referenced by project " + name);
- } else if (project.jars.size() > 1) {
+ } else if (project.jars.size() > 1) {
- throw new Exception(
- "Multiple jars defined by project \"" + projectName + "\" " +
- "referenced by project \"" + name + "\"; " +
- "an id attribute is required to select the one you want.");
+ throw new Exception(
+ "Multiple jars defined by project \"" + projectName + "\" " +
+ "referenced by project \"" + name + "\"; " +
+ "an id attribute is required to select the one you want.");
- } else {
+ } else {
- throw new Exception(
- "Project \"" + projectName + "\" referenced by project " +
- name + " defines no jars as output.");
+ throw new Exception(
+ "Project \"" + projectName + "\" referenced by project " +
+ name + " defines no jars as output.");
- }
+ }
}
@@ -690,70 +690,70 @@
* @param javadoc child XML element
*/
private void resolveJavadoc(Element javadoc) throws Exception {
- if (javadoc == null) return;
+ if (javadoc == null) return;
- // retrieve url and dir of javadoc from the workspace
- Element config = Workspace.getJavaDoc();
- if (config == null) return;
- String url = config.getAttribute("url");
- String javadocDir = config.getAttribute("dir");
-
- // default project attribute to the name of this project
- if (javadoc.getAttributeNode("project") == null)
- javadoc.setAttribute("project", name);
-
- // default module attribute to the module which this project belongs
- String moduleName = javadoc.getAttribute("module");
- if (moduleName.equals("")) moduleName = this.get("module");
- Module module = Module.find(moduleName);
- require (module, "module", moduleName);
-
- if (!moduleName.equals(this.get("module"))) {
- javadoc.setAttribute("defined-in", this.get("module"));
- }
-
- // if there are no child nodes, add this project's description
- if (!javadoc.hasChildNodes() && description!=null) {
- Element desc = (Element) description.cloneNode(true);
- javadoc.appendChild(desc);
- }
-
- // resolve relative and full path to this javadoc entry
- String path = javadoc.getAttribute("nested");
- String fullpath;
- if (!path.equals("")) {
- fullpath = get("srcdir") + "/" + path;
- } else {
- path = javadoc.getAttribute("parent");
- fullpath = Workspace.getBaseDir() + "/" + path;
- }
- path = moduleName + "/" + path;
-
- // for each description entry, resolve source, url, and dest attrs.
- Node child=javadoc.getFirstChild();
- for (; child != null; child=child.getNextSibling()) {
- if (child.getNodeName().equals("description")) {
- Element desc = (Element) child;
- String dir = desc.getAttribute("dir");
- String append = "";
- if (!dir.equals("")) append = "/" + dir;
-
- desc.setAttribute("source", fullpath + append);
-
- if (url.equals("")) {
- desc.setAttribute("url", "file:///" + fullpath + append);
- } else {
- desc.setAttribute("url", url + path + append);
- }
-
- if (!javadocDir.equals("")) {
- desc.setAttribute("dest", javadocDir + "/" + path + append);
- }
- }
- }
+ // retrieve url and dir of javadoc from the workspace
+ Element config = Workspace.getJavaDoc();
+ if (config == null) return;
+ String url = config.getAttribute("url");
+ String javadocDir = config.getAttribute("dir");
+
+ // default project attribute to the name of this project
+ if (javadoc.getAttributeNode("project") == null)
+ javadoc.setAttribute("project", name);
+
+ // default module attribute to the module which this project belongs
+ String moduleName = javadoc.getAttribute("module");
+ if (moduleName.equals("")) moduleName = this.get("module");
+ Module module = Module.find(moduleName);
+ require (module, "module", moduleName);
+
+ if (!moduleName.equals(this.get("module"))) {
+ javadoc.setAttribute("defined-in", this.get("module"));
+ }
+
+ // if there are no child nodes, add this project's description
+ if (!javadoc.hasChildNodes() && description!=null) {
+ Element desc = (Element) description.cloneNode(true);
+ javadoc.appendChild(desc);
+ }
+
+ // resolve relative and full path to this javadoc entry
+ String path = javadoc.getAttribute("nested");
+ String fullpath;
+ if (!path.equals("")) {
+ fullpath = get("srcdir") + "/" + path;
+ } else {
+ path = javadoc.getAttribute("parent");
+ fullpath = Workspace.getBaseDir() + "/" + path;
+ }
+ path = moduleName + "/" + path;
+
+ // for each description entry, resolve source, url, and dest attrs.
+ Node child=javadoc.getFirstChild();
+ for (; child != null; child=child.getNextSibling()) {
+ if (child.getNodeName().equals("description")) {
+ Element desc = (Element) child;
+ String dir = desc.getAttribute("dir");
+ String append = "";
+ if (!dir.equals("")) append = "/" + dir;
+
+ desc.setAttribute("source", fullpath + append);
+
+ if (url.equals("")) {
+ desc.setAttribute("url", "file:///" + fullpath + append);
+ } else {
+ desc.setAttribute("url", url + path + append);
+ }
+
+ if (!javadocDir.equals("")) {
+ desc.setAttribute("dest", javadocDir + "/" + path + append);
+ }
+ }
+ }
- // copy the entire result to the desired module
- module.appendChild(javadoc);
+ // copy the entire result to the desired module
+ module.appendChild(javadoc);
}
/**
@@ -764,22 +764,22 @@
* @param value the value of this attribute
* @return Value of the specified attribute.
*/
- private void require(Object object, String attr, String value)
- throws Exception
+ private void require(Object object, String attr, String value)
+ throws Exception
{
- if (object != null) return;
+ if (object != null) return;
- throw new Exception(
- attr + " \"" + value + "\" not found processing project " + name
- );
+ throw new Exception(
+ attr + " \"" + value + "\" not found processing project " + name
+ );
}
/**
* Remove this Project instance from the workspace.
*/
private void remove() {
- projects.remove(name);
- element.getParentNode().removeChild(element);
+ projects.remove(name);
+ element.getParentNode().removeChild(element);
}
/**
@@ -787,18 +787,18 @@
* elements, if these are defined.
*/
private void handleDeliver() {
- Enumeration elements = deliver.elements();
- String srcdir = element.getAttribute("srcdir");
- while (elements.hasMoreElements()) {
- Element deliver = (Element) elements.nextElement();
- String siteName = deliver.getAttribute("tosite");
- Element site = Server.getSite(siteName);
- if (site != null) {
- String fromdir = deliver.getAttribute("fromdir");
- deliver.setAttribute("fromdir", srcdir + "/" + fromdir);
- site.appendChild(deliver);
- }
- }
+ Enumeration elements = deliver.elements();
+ String srcdir = element.getAttribute("srcdir");
+ while (elements.hasMoreElements()) {
+ Element deliver = (Element) elements.nextElement();
+ String siteName = deliver.getAttribute("tosite");
+ Element site = Server.getSite(siteName);
+ if (site != null) {
+ String fromdir = deliver.getAttribute("fromdir");
+ deliver.setAttribute("fromdir", srcdir + "/" + fromdir);
+ site.appendChild(deliver);
+ }
+ }
}
/**
@@ -808,70 +808,70 @@
* Push attributes to nested regexp elements
*/
private void expandNag(Element nag) {
- if (nagPrefix == null) {
- Element workspaceNag = Workspace.getNag();
- if (workspaceNag == null) {
- nagPrefix = defaultNagPrefix;
- } else {
- if (!workspaceNag.getAttribute("prefix").equals("")) {
- nagPrefix = workspaceNag.getAttribute("prefix");
- } else {
- nagPrefix = defaultNagPrefix;
- }
- if (!workspaceNag.getAttribute("to").equals("")) {
- nagTo = workspaceNag.getAttribute("to");
- }
- }
- }
-
-
- String subject = nagPrefix + " Build Failure - "+name;
- String to = nagTo == null ? nag.getAttribute("to") : nagTo;
- String from = nag.getAttribute("from");
-
- if (!nag.getAttribute("subject").equals("")) {
- subject = nagPrefix + " " + nag.getAttribute("subject");
- }
-
- Element regexp = null;
- Node child = nag.getFirstChild();
- for (; child != null; child = child.getNextSibling()) {
- if (child.getNodeName().equals("regexp")) {
- regexp = (Element)child;
-
- if (regexp.getAttribute("pattern").equals("")) {
- regexp.setAttribute("pattern", defaultNagPattern);
- }
-
- if (regexp.getAttribute("subject").equals("")) {
- regexp.setAttribute("subject", subject);
- } else {
- String orig = regexp.getAttribute("subject");
- regexp.setAttribute("subject", nagPrefix + " " + orig);
- }
-
- if (nagTo != null || regexp.getAttribute("to").equals("")) {
- regexp.setAttribute("to", to);
- }
-
- if (regexp.getAttribute("from").equals("")) {
- regexp.setAttribute("from", from);
- }
- }
- }
-
- if (regexp == null) {
- regexp = nag.getOwnerDocument().createElement("regexp");
- regexp.setAttribute("pattern", defaultNagPattern);
- regexp.setAttribute("subject", subject);
- regexp.setAttribute("to", to);
- regexp.setAttribute("from", from);
- nag.appendChild(regexp);
- }
+ if (nagPrefix == null) {
+ Element workspaceNag = Workspace.getNag();
+ if (workspaceNag == null) {
+ nagPrefix = defaultNagPrefix;
+ } else {
+ if (!workspaceNag.getAttribute("prefix").equals("")) {
+ nagPrefix = workspaceNag.getAttribute("prefix");
+ } else {
+ nagPrefix = defaultNagPrefix;
+ }
+ if (!workspaceNag.getAttribute("to").equals("")) {
+ nagTo = workspaceNag.getAttribute("to");
+ }
+ }
+ }
+
+
+ String subject = nagPrefix + " Build Failure - "+name;
+ String to = nagTo == null ? nag.getAttribute("to") : nagTo;
+ String from = nag.getAttribute("from");
+
+ if (!nag.getAttribute("subject").equals("")) {
+ subject = nagPrefix + " " + nag.getAttribute("subject");
+ }
+
+ Element regexp = null;
+ Node child = nag.getFirstChild();
+ for (; child != null; child = child.getNextSibling()) {
+ if (child.getNodeName().equals("regexp")) {
+ regexp = (Element)child;
+
+ if (regexp.getAttribute("pattern").equals("")) {
+ regexp.setAttribute("pattern", defaultNagPattern);
+ }
+
+ if (regexp.getAttribute("subject").equals("")) {
+ regexp.setAttribute("subject", subject);
+ } else {
+ String orig = regexp.getAttribute("subject");
+ regexp.setAttribute("subject", nagPrefix + " " + orig);
+ }
+
+ if (nagTo != null || regexp.getAttribute("to").equals("")) {
+ regexp.setAttribute("to", to);
+ }
+
+ if (regexp.getAttribute("from").equals("")) {
+ regexp.setAttribute("from", from);
+ }
+ }
+ }
+
+ if (regexp == null) {
+ regexp = nag.getOwnerDocument().createElement("regexp");
+ regexp.setAttribute("pattern", defaultNagPattern);
+ regexp.setAttribute("subject", subject);
+ regexp.setAttribute("to", to);
+ regexp.setAttribute("from", from);
+ nag.appendChild(regexp);
+ }
}
-
+
public boolean isRedistributable() {
- return redistributable;
+ return redistributable;
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic