[jboss-svn-commits] JBL Code SVN: r24430 - in labs/jbossbuild/buildmagic/trunk/tasks/src: main/org/jboss/tools/buildmagic/task/config and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 18 15:06:56 EST 2008
Author: pgier
Date: 2008-12-18 15:06:56 -0500 (Thu, 18 Dec 2008)
New Revision: 24430
Modified:
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AbstractBuildListener.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AppendPath.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/CallTarget.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ContainerTask.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/FindRoot.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/IllegalAttributeException.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Loop.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/MissingAttributeException.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/MissingElementException.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ProjectHelp.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Property.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/PropertyFilter.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Require.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ResolveProperties.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Script.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedContainerTask.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedTask.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Set.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Subst.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Tasks.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Unset.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/UnsupportedAttributeException.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/UnsupportedElementException.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/VariableTask.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/ModuleLibrary.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/AbstractInfo.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ExecuteModules.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleConfig.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInfo.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInit.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/NamedElement.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ProjectInfo.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/ConditionalExecution.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Dump.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Puke.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/TaskLogger.java
labs/jbossbuild/buildmagic/trunk/tasks/src/test/org/jboss/tools/buildmagic/task/ResolvePropertiesTestCase.java
Log:
Update license headers. Apply JBoss code formatting conventions. Remove some unused imports.
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AbstractBuildListener.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AbstractBuildListener.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AbstractBuildListener.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -18,13 +31,13 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public abstract class AbstractBuildListener
- implements BuildListener
+public abstract class AbstractBuildListener implements BuildListener
{
/**
* Fired before any targets are started.
*/
- public void buildStarted(BuildEvent event) {
+ public void buildStarted(BuildEvent event)
+ {
}
/**
@@ -33,7 +46,8 @@
*
* @see BuildEvent#getException()
*/
- public void buildFinished(BuildEvent event) {
+ public void buildFinished(BuildEvent event)
+ {
}
/**
@@ -41,7 +55,8 @@
*
* @see BuildEvent#getTarget()
*/
- public void targetStarted(BuildEvent event) {
+ public void targetStarted(BuildEvent event)
+ {
}
/**
@@ -50,7 +65,8 @@
*
* @see BuildEvent#getException()
*/
- public void targetFinished(BuildEvent event) {
+ public void targetFinished(BuildEvent event)
+ {
}
/**
@@ -58,7 +74,8 @@
*
* @see BuildEvent#getTask()
*/
- public void taskStarted(BuildEvent event) {
+ public void taskStarted(BuildEvent event)
+ {
}
/**
@@ -67,7 +84,8 @@
*
* @see BuildEvent#getException()
*/
- public void taskFinished(BuildEvent event) {
+ public void taskFinished(BuildEvent event)
+ {
}
/**
@@ -76,6 +94,7 @@
* @see BuildEvent#getMessage()
* @see BuildEvent#getPriority()
*/
- public void messageLogged(BuildEvent event) {
+ public void messageLogged(BuildEvent event)
+ {
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AppendPath.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AppendPath.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AppendPath.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -13,8 +26,6 @@
import java.util.LinkedList;
import java.util.Iterator;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Target;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.Path;
@@ -26,20 +37,22 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class AppendPath
- extends Task
+public class AppendPath extends Task
{
protected List paths = new LinkedList();
+
protected String refid;
- public void setRefid(String id) {
+ public void setRefid(String id)
+ {
this.refid = id;
}
-
+
/**
* Create a nested path.
*/
- public Path createPath() {
+ public Path createPath()
+ {
Path path = new Path(getProject());
paths.add(path);
return path;
@@ -48,23 +61,26 @@
/**
* Create a nested path element.
*/
- public PathElement createPathElement() {
+ public PathElement createPathElement()
+ {
Path path = new Path(getProject());
paths.add(path);
return path.createPathElement();
}
-
+
/**
* Execute the task.
*/
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
if (refid == null)
throw new MissingAttributeException("refid", this);
- Path target = (Path)getProject().getReferences().get(refid);
+ Path target = (Path) getProject().getReferences().get(refid);
Iterator iter = paths.iterator();
- while (iter.hasNext()) {
- Path path = (Path)iter.next();
+ while (iter.hasNext())
+ {
+ Path path = (Path) iter.next();
target.append(path);
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/CallTarget.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/CallTarget.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/CallTarget.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -15,7 +28,6 @@
import java.util.*;
import java.lang.reflect.*;
-import org.jboss.tools.buildmagic.task.*;
import org.jboss.tools.buildmagic.task.util.TaskLogger;
/**
@@ -27,8 +39,7 @@
* @version $Id$
* @author Jason Dillon <A href="mailto:jason at planet57.com"><jason at planet57.com></A>
*/
-public class CallTarget
- extends Task
+public class CallTarget extends Task
{
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
@@ -43,6 +54,7 @@
protected boolean override = true;
protected String _if;
+
protected String unless;
protected List availables = new LinkedList();
@@ -52,7 +64,8 @@
*
* @param override Override flag.
*/
- public void setOverride(final boolean override) {
+ public void setOverride(final boolean override)
+ {
this.override = override;
log.debug("override flag: " + override);
}
@@ -62,90 +75,106 @@
*
* @param target The target to execute.
*/
- public void setTarget(final String target) {
+ public void setTarget(final String target)
+ {
this.target = target;
}
- public void setIf(final String property) {
+ public void setIf(final String property)
+ {
this._if = property;
}
- public void setUnless(final String property) {
+ public void setUnless(final String property)
+ {
this.unless = property;
}
public Available createAvailable()
{
- Available a = (Available)getProject().createTask("available");
+ Available a = (Available) getProject().createTask("available");
a.setProperty("null");
availables.add(a);
return a;
}
-
+
/**
* Validate the attributes for this task.
*
* @throws BuildException Attributes are not valid.
*/
- protected void validate() throws BuildException {
+ protected void validate() throws BuildException
+ {
if (target == null)
throw new MissingAttributeException("target", this);
}
/** The argument types for the property override method. */
- public static final Class[] ARGUMENT_TYPES = { Boolean.TYPE };
+ public static final Class[] ARGUMENT_TYPES =
+ {Boolean.TYPE};
/** The argument values for the property override method. */
- public static final Object[] ARGUMENT_VALUES = { Boolean.TRUE };
+ public static final Object[] ARGUMENT_VALUES =
+ {Boolean.TRUE};
/**
* Invoke the target.
*/
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
validate();
- Iterator iter=availables.iterator();
- while (iter.hasNext()) {
- Available a = (Available)iter.next();
- if (!a.eval()) return;
+ Iterator iter = availables.iterator();
+ while (iter.hasNext())
+ {
+ Available a = (Available) iter.next();
+ if (!a.eval())
+ return;
}
-
+
Map map = getProject().getProperties();
- if (_if != null && !map.containsKey(_if)) {
+ if (_if != null && !map.containsKey(_if))
+ {
return;
}
- else if (unless != null && map.containsKey(unless)) {
+ else if (unless != null && map.containsKey(unless))
+ {
return;
}
-
+
// initialize all nested parameters
- iter=params.iterator();
- while (iter.hasNext()) {
- Task task = (Task)iter.next();
-
- if (override) {
- try {
+ iter = params.iterator();
+ while (iter.hasNext())
+ {
+ Task task = (Task) iter.next();
+
+ if (override)
+ {
+ try
+ {
Class type = task.getClass();
Method meth = type.getMethod("setOverride", ARGUMENT_TYPES);
meth.invoke(task, ARGUMENT_VALUES);
log.debug("set override for task: " + task);
}
- catch (Exception e) {
+ catch (Exception e)
+ {
log.warning("failed to set override: " + e);
}
}
task.execute();
}
-
+
getProject().executeTarget(target);
}
/**
* Create a nested <tt>param</tt> element.
*/
- public Task createParam() {
+ public Task createParam()
+ {
Task task = getProject().createTask("property");
params.add(task);
return task;
@@ -154,7 +183,8 @@
/**
* Create a nested <tt>property</tt> element.
*/
- public Task createProperty() {
+ public Task createProperty()
+ {
Task task = getProject().createTask("property");
params.add(task);
return task;
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ContainerTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ContainerTask.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ContainerTask.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -13,7 +26,6 @@
import org.apache.tools.ant.*;
-import org.jboss.tools.buildmagic.task.*;
import org.jboss.tools.buildmagic.task.util.TaskLogger;
/**
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/FindRoot.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/FindRoot.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/FindRoot.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,18 +1,29 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
import java.io.File;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Target;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/IllegalAttributeException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/IllegalAttributeException.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/IllegalAttributeException.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -17,34 +30,40 @@
* @version $Id$
* @author Jason Dillon <A href="mailto:jason at planet57.com"><jason at planet57.com></A>
*/
-public class IllegalAttributeException
- extends BuildException
+public class IllegalAttributeException extends BuildException
{
- protected static String format(String name) {
+ protected static String format(String name)
+ {
return "Illegal value for attribute '" + name + "'";
}
- protected static String format(String name, String msg) {
+ protected static String format(String name, String msg)
+ {
return format(name) + ": " + msg;
}
- public IllegalAttributeException(String name, String msg, Location location) {
+ public IllegalAttributeException(String name, String msg, Location location)
+ {
super(format(name, msg), location);
}
- public IllegalAttributeException(String name, String msg, Task task) {
+ public IllegalAttributeException(String name, String msg, Task task)
+ {
super(format(name, msg), task.getLocation());
}
- public IllegalAttributeException(String name, Task task) {
+ public IllegalAttributeException(String name, Task task)
+ {
super(format(name), task.getLocation());
}
- public IllegalAttributeException(String name, Location location) {
+ public IllegalAttributeException(String name, Location location)
+ {
super(format(name), location);
}
- public IllegalAttributeException(String name) {
+ public IllegalAttributeException(String name)
+ {
super(format(name));
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Loop.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Loop.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Loop.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -17,8 +30,7 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class Loop
- extends ContainerTask
+public class Loop extends ContainerTask
{
/** The loop count. */
protected int count = -1;
@@ -28,7 +40,8 @@
*
* @param count The loop count.
*/
- public void setCount(final int count) {
+ public void setCount(final int count)
+ {
this.count = count;
}
@@ -37,7 +50,8 @@
*
* @throws BuildException Attributes are not valid.
*/
- protected void validate() throws BuildException {
+ protected void validate() throws BuildException
+ {
super.validate();
if (count <= 0)
@@ -47,11 +61,13 @@
/**
* Execute the configured target the configured number of times.
*/
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
validate();
log.verbose("looping '" + getOwningTarget() + "' for count: " + count);
- for (int i=0; i<count; i++) {
+ for (int i = 0; i < count; i++)
+ {
log.debug("i: " + i);
executeTasks();
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/MissingAttributeException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/MissingAttributeException.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/MissingAttributeException.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -17,11 +30,10 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class MissingAttributeException
- extends BuildException
+public class MissingAttributeException extends BuildException
{
- public MissingAttributeException(String name, Task task) {
- super(task.getClass() + " requires the '" + name + "' attribute.",
- task.getLocation());
+ public MissingAttributeException(String name, Task task)
+ {
+ super(task.getClass() + " requires the '" + name + "' attribute.", task.getLocation());
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/MissingElementException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/MissingElementException.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/MissingElementException.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -17,12 +30,10 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class MissingElementException
- extends BuildException
+public class MissingElementException extends BuildException
{
- public MissingElementException(String name, Task task) {
- super(task.getClass() + " requires a '" + name + "' element",
- task.getLocation());
+ public MissingElementException(String name, Task task)
+ {
+ super(task.getClass() + " requires a '" + name + "' element", task.getLocation());
}
}
-
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ProjectHelp.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ProjectHelp.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ProjectHelp.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -28,42 +41,49 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class ProjectHelp
- extends Task
+public class ProjectHelp extends Task
{
protected PrintWriter out = new PrintWriter(System.out);
+
protected List headers = new LinkedList();
+
protected List footers = new LinkedList();
- public Heading createHeader() {
+ public Heading createHeader()
+ {
Heading header = new Heading();
headers.add(header);
return header;
}
- public Heading createFooter() {
+ public Heading createFooter()
+ {
Heading footer = new Heading();
footers.add(footer);
return footer;
}
-
+
/**
* Execute the task.
*/
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
Map targets = getProject().getTargets();
List names = new LinkedList();
int maxlen = 0;
Iterator iter = targets.keySet().iterator();
-
- while (iter.hasNext()) {
- String name = (String)iter.next();
- Target target = (Target)targets.get(name);
+
+ while (iter.hasNext())
+ {
+ String name = (String) iter.next();
+ Target target = (Target) targets.get(name);
String desc = target.getDescription();
-
- if (desc != null) {
+
+ if (desc != null)
+ {
int len = name.length();
- if (len > maxlen) maxlen = len;
+ if (len > maxlen)
+ maxlen = len;
names.add(name);
}
}
@@ -75,33 +95,36 @@
out.flush();
}
- protected void printHeading(List list) {
+ protected void printHeading(List list)
+ {
Iterator iter = list.iterator();
- while (iter.hasNext()) {
- Heading heading = (Heading)iter.next();
+ while (iter.hasNext())
+ {
+ Heading heading = (Heading) iter.next();
heading.setProject(getProject());
heading.print(out);
}
}
-
- protected String getDescription(String name) {
- Target target = (Target)getProject().getTargets().get(name);
+
+ protected String getDescription(String name)
+ {
+ Target target = (Target) getProject().getTargets().get(name);
return target.getDescription();
}
-
- protected void printTargets(PrintWriter out,
- List names,
- int maxlen)
+
+ protected void printTargets(PrintWriter out, List names, int maxlen)
{
String spaces = " ";
- while (spaces.length() < maxlen) {
+ while (spaces.length() < maxlen)
+ {
spaces += spaces;
}
Collections.sort(names);
- for (int i=0; i<names.size(); i++) {
- String name = (String)names.get(i);
+ for (int i = 0; i < names.size(); i++)
+ {
+ String name = (String) names.get(i);
String pad = spaces.substring(0, maxlen - name.length() + 4);
out.print(" ");
@@ -115,25 +138,29 @@
protected class Heading
{
protected StringBuffer buff = new StringBuffer();
+
protected Project project;
- public void setProject(Project project) {
+ public void setProject(Project project)
+ {
this.project = project;
}
-
- public void setMessage(final String text) {
+
+ public void setMessage(final String text)
+ {
addText(text);
}
-
- public void addText(final String text) {
+
+ public void addText(final String text)
+ {
buff.append(text);
}
- public void print(PrintWriter out) {
+ public void print(PrintWriter out)
+ {
String msg = buff.toString();
msg = ResolveProperties.subst(msg, project.getProperties(), false);
out.println(msg);
}
}
}
-
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Property.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Property.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Property.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -23,57 +36,74 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class Property
- extends org.apache.tools.ant.taskdefs.Property
+public class Property extends org.apache.tools.ant.taskdefs.Property
{
public static final int STRING = 0;
+
public static final int INTEGER = 1;
+
public static final int FLOAT = 2;
+
public static final int BOOLEAN = 3;
+
public static final int PATH = 4;
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
protected String type;
+
protected String separator;
+
protected boolean override;
+
protected boolean filter;
+
protected boolean resolve;
+
protected boolean force;
+
protected boolean system;
-
+
//
// HACK
//
protected FindRoot findRoot;
-
- public void setType(final String type) {
+
+ public void setType(final String type)
+ {
this.type = type;
}
- public void setSeparator(final String sep) {
+ public void setSeparator(final String sep)
+ {
this.separator = sep;
}
- public void setOverride(final boolean override) {
+ public void setOverride(final boolean override)
+ {
this.override = override;
}
- public void setFilter(final boolean filter) {
+ public void setFilter(final boolean filter)
+ {
this.filter = filter;
}
- public void setSystem(final boolean system) {
+ public void setSystem(final boolean system)
+ {
this.system = system;
}
- public void setResolve(final String resolve) {
- if (resolve.equals("force")) {
+ public void setResolve(final String resolve)
+ {
+ if (resolve.equals("force"))
+ {
this.resolve = true;
this.force = true;
}
- else {
+ else
+ {
this.resolve = new Boolean(resolve).booleanValue();
}
}
@@ -81,21 +111,25 @@
//
// HACK
//
- public FindRoot createFindRoot() {
+ public FindRoot createFindRoot()
+ {
findRoot = new FindRoot(log);
return findRoot;
}
-
+
/**
* Add some raw text to the property.
*
* @param text A line of text to add to the property.
*/
- public void addText(final String text) {
- if (value == null) {
+ public void addText(final String text)
+ {
+ if (value == null)
+ {
value = text;
}
- else {
+ else
+ {
value += text;
}
}
@@ -103,35 +137,41 @@
/**
* Create an <tt>Element</tt> element.
*/
- public Element createElement() {
+ public Element createElement()
+ {
return new Element();
}
/**
* Create an <em>appending</em> <tt>Element</tt>.
*/
- public Element createAppend() {
+ public Element createAppend()
+ {
return new Element(Element.APPEND);
}
/**
* Create a <em>prepending</em> <tt>Element</tt>.
*/
- public Element createPrepend() {
+ public Element createPrepend()
+ {
return new Element(Element.PREPEND);
}
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
//
// HACK
//
- if (findRoot != null) {
+ if (findRoot != null)
+ {
findRoot.setProperty(getName());
File root = findRoot.getRoot();
value = root.getAbsolutePath();
}
-
- if (resolve) {
+
+ if (resolve)
+ {
log.debug("resolving property: " + name + "(force: " + force + ")");
Hashtable props = getProject().getProperties();
value = ResolveProperties.subst(value, props, force);
@@ -140,112 +180,130 @@
// perform any type converstions
convertType();
- if (system) {
+ if (system)
+ {
log.verbose("setting system proeprty: " + name + "=" + value);
System.setProperty(name, value);
getProject().setUserProperty(name, value);
}
-
+
// perform the default operation
super.execute();
- if (filter) {
+ if (filter)
+ {
log.debug("adding filter for property: " + name);
getProject().getGlobalFilterSet().addFilter(name, value);
}
}
- protected void addProperty(String n, String v) {
- if (userProperty) {
- if (override || getProject().getUserProperty(n) == null) {
+ protected void addProperty(String n, String v)
+ {
+ if (userProperty)
+ {
+ if (override || getProject().getUserProperty(n) == null)
+ {
getProject().setUserProperty(n, v);
if (override)
log.debug("overrode user property value for " + n);
}
- else {
+ else
+ {
log.debug("Override ignored for " + n);
- }
+ }
}
- else {
- if (override || getProject().getProperty(n) == null) {
- getProject().setProperty(n, v);
+ else
+ {
+ if (override || getProject().getProperty(n) == null)
+ {
+ getProject().setProperty(n, v);
if (override)
log.debug("overrode property value for " + n);
}
- else {
+ else
+ {
log.debug("Override ignored for " + n);
}
}
- }
+ }
/**
* Parse the type attribute and return a type code.
*/
- protected int parseType() throws BuildException {
+ protected int parseType() throws BuildException
+ {
log.debug("parsing type: " + type);
- if (type == null || type.equals("string")) {
+ if (type == null || type.equals("string"))
+ {
return STRING;
}
- else if (type.equals("integer")) {
+ else if (type.equals("integer"))
+ {
return INTEGER;
}
- else if (type.equals("float")) {
+ else if (type.equals("float"))
+ {
return FLOAT;
}
- else if (type.equals("boolean")) {
+ else if (type.equals("boolean"))
+ {
return BOOLEAN;
}
- else if (type.equals("path") ||
- type.equals("file") ||
- type.equals("dir")) {
+ else if (type.equals("path") || type.equals("file") || type.equals("dir"))
+ {
return PATH;
}
- else {
+ else
+ {
throw new BuildException("invalid property type: " + type);
}
}
- protected void convertType() throws BuildException {
+ protected void convertType() throws BuildException
+ {
int code = parseType();
- switch (code) {
- case INTEGER:
- try {
- log.debug("converting value to an integer");
- value = new Long(value).toString();
- }
- catch (Exception e) {
- throw new BuildException
- ("property value is not an integer: " + value);
- }
- break;
+ switch (code)
+ {
+ case INTEGER :
+ try
+ {
+ log.debug("converting value to an integer");
+ value = new Long(value).toString();
+ }
+ catch (Exception e)
+ {
+ throw new BuildException("property value is not an integer: " + value);
+ }
+ break;
- case FLOAT:
- try {
- log.debug("converting value to an floating point");
- value = new Double(value).toString();
- }
- catch (Exception e) {
- throw new BuildException
- ("property value is not a floating point number: " + value);
- }
- break;
+ case FLOAT :
+ try
+ {
+ log.debug("converting value to an floating point");
+ value = new Double(value).toString();
+ }
+ catch (Exception e)
+ {
+ throw new BuildException("property value is not a floating point number: " + value);
+ }
+ break;
- case BOOLEAN:
- value = new Boolean(value).toString();
- break;
+ case BOOLEAN :
+ value = new Boolean(value).toString();
+ break;
- case PATH:
- log.debug("converting value to a path");
- // do not specify a project here, so properties that have not been
- // set yet will not have the project basedir prepended to them.
- Path path = new Path(/*project*/ null, value);
- value = path.toString();
- break;
-
- default:
- // no converstion
+ case PATH :
+ log.debug("converting value to a path");
+ // do not specify a project here, so properties that have not been
+ // set yet will not have the project basedir prepended to them.
+ Path path = new Path(/*project*/null, value);
+ value = path.toString();
+ break;
+
+ default :
+ // no converstion
}
log.debug("converted value: " + value);
@@ -257,55 +315,69 @@
public class Element
{
public static final int APPEND = 0;
+
public static final int PREPEND = 1;
protected int mode = APPEND;
- public Element() {}
+ public Element()
+ {
+ }
- public Element(final int mode) {
+ public Element(final int mode)
+ {
this.mode = mode;
}
-
- public void setMode(final String mode) throws BuildException {
- if (mode.equals("append")) {
+
+ public void setMode(final String mode) throws BuildException
+ {
+ if (mode.equals("append"))
+ {
this.mode = APPEND;
}
- else if (mode.equals("prepend")) {
+ else if (mode.equals("prepend"))
+ {
this.mode = PREPEND;
}
- else {
+ else
+ {
throw new BuildException("Invalid property element mode: " + mode);
}
}
- public int getMode() {
+ public int getMode()
+ {
return mode;
}
- protected void appendCurrentValue(final StringBuffer buff) {
- if (value != null) {
+ protected void appendCurrentValue(final StringBuffer buff)
+ {
+ if (value != null)
+ {
buff.append(value);
- if (separator != null) buff.append(separator);
+ if (separator != null)
+ buff.append(separator);
}
}
- public void setValue(final String s) {
+ public void setValue(final String s)
+ {
StringBuffer buff = new StringBuffer();
- switch (mode) {
- case APPEND:
- appendCurrentValue(buff);
- buff.append(s);
- break;
+ switch (mode)
+ {
+ case APPEND :
+ appendCurrentValue(buff);
+ buff.append(s);
+ break;
- case PREPEND:
- buff.append(s);
- appendCurrentValue(buff);
- break;
+ case PREPEND :
+ buff.append(s);
+ appendCurrentValue(buff);
+ break;
- default:
- throw new BuildException("Invalid property element mode: " + mode);
+ default :
+ throw new BuildException("Invalid property element mode: " + mode);
}
log.debug("new value: " + buff);
@@ -313,4 +385,3 @@
}
}
}
-
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/PropertyFilter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/PropertyFilter.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/PropertyFilter.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -22,28 +35,31 @@
* @version $Id$
* @author Jason Dillon <A href="mailto:jason at planet57.com"><jason at planet57.com></A>
*/
-public class PropertyFilter
- extends Task
+public class PropertyFilter extends Task
{
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
protected boolean all = true;
- public void setAll(boolean all) {
+ public void setAll(boolean all)
+ {
this.all = all;
}
- public void execute() throws BuildException {
- if (all) {
+ public void execute() throws BuildException
+ {
+ if (all)
+ {
log.verbose("Adding filters for all properties");
Map props = getProject().getProperties();
Iterator iter = props.keySet().iterator();
- while (iter.hasNext()) {
- String key = (String)iter.next();
- String value = (String)props.get(key);
+ while (iter.hasNext())
+ {
+ String key = (String) iter.next();
+ String value = (String) props.get(key);
// log.debug("adding: " + key + "=" + value);
getProject().getGlobalFilterSet().addFilter(key, value);
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Require.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Require.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Require.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -13,9 +26,7 @@
import org.apache.tools.ant.types.*;
import java.io.*;
-import java.util.*;
-import org.jboss.tools.buildmagic.task.*;
import org.jboss.tools.buildmagic.task.util.TaskLogger;
/**
@@ -24,8 +35,7 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class Require
- extends Task
+public class Require extends Task
{
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
@@ -54,14 +64,16 @@
/**
* Set the message.
*/
- public void setMessage(final String text) {
+ public void setMessage(final String text)
+ {
addText(text);
}
-
+
/**
* Add some text to the message.
*/
- public void addText(final String text) {
+ public void addText(final String text)
+ {
if (message == null)
message = new StringBuffer();
message.append(text);
@@ -72,7 +84,8 @@
*
* @param property Property name.
*/
- public void setProperty(final String property) {
+ public void setProperty(final String property)
+ {
this.property = property;
}
@@ -81,7 +94,8 @@
*
* @param classname Class name.
*/
- public void setClass(final String classname) {
+ public void setClass(final String classname)
+ {
this.classname = classname;
}
@@ -90,7 +104,8 @@
*
* @param resource Resource name.
*/
- public void setResource(final String resource) {
+ public void setResource(final String resource)
+ {
this.resource = resource;
}
@@ -99,7 +114,8 @@
*
* @param file File.
*/
- public void setFile(final File file) {
+ public void setFile(final File file)
+ {
this.file = file;
}
@@ -108,11 +124,14 @@
*
* @param classpath Class path.
*/
- public void setClasspath(Path classpath) {
- if (this.classpath == null) {
+ public void setClasspath(Path classpath)
+ {
+ if (this.classpath == null)
+ {
this.classpath = classpath;
}
- else {
+ else
+ {
this.classpath.append(classpath);
}
}
@@ -120,8 +139,10 @@
/**
* Create a nested <tt>Path</tt> element.
*/
- public Path createClasspath() {
- if (this.classpath == null) {
+ public Path createClasspath()
+ {
+ if (this.classpath == null)
+ {
this.classpath = new Path(getProject());
}
return this.classpath.createPath();
@@ -130,7 +151,8 @@
/**
* Use a reference classpath.
*/
- public void setClasspathRef(Reference r) {
+ public void setClasspathRef(Reference r)
+ {
createClasspath().setRefid(r);
}
@@ -139,25 +161,31 @@
*
* @exception BuildException Missing required resource.
*/
- public void execute() throws BuildException {
- if ((property != null) && !checkProperty(property)) {
+ public void execute() throws BuildException
+ {
+ if ((property != null) && !checkProperty(property))
+ {
missingRequired("property", property);
}
- if ((file != null) && !checkFile(file)) {
+ if ((file != null) && !checkFile(file))
+ {
missingRequired("file", file);
}
// load the custom class path if it is not null
- if (classpath != null) {
+ if (classpath != null)
+ {
this.loader = new AntClassLoader(getProject(), classpath, false);
}
- if ((resource != null) && !checkResource(resource)) {
+ if ((resource != null) && !checkResource(resource))
+ {
missingRequired("resource", resource);
}
- if ((classname != null) && !checkClass(classname)) {
+ if ((classname != null) && !checkClass(classname))
+ {
missingRequired("classname", classname);
}
}
@@ -170,21 +198,20 @@
*
* @exception BuildException Missing required.
*/
- protected void missingRequired(final String type,
- final Object value)
- throws BuildException
+ protected void missingRequired(final String type, final Object value) throws BuildException
{
StringBuffer buff = new StringBuffer();
// Might want to allow user to pass in format string for generating
// message.
- if (message == null) {
+ if (message == null)
+ {
buff.append("Missing required ").append(type).append(": ").append(value);
}
- else {
- buff.append(ResolveProperties.subst
- (message.toString(), getProject().getProperties(), false));
+ else
+ {
+ buff.append(ResolveProperties.subst(message.toString(), getProject().getProperties(), false));
}
throw new BuildException(buff.toString());
@@ -196,25 +223,28 @@
* @param property Property name.
* @return True if property exists.
*/
- protected boolean checkProperty(final String property) {
+ protected boolean checkProperty(final String property)
+ {
boolean exists;
// look in system first
exists = System.getProperty(property, null) != null;
// next look in project
- if (!exists) {
+ if (!exists)
+ {
Project project = getProject();
-
+
// regular property first
exists = project.getProperty(property) != null;
// then user property
- if (!exists) {
+ if (!exists)
+ {
exists = project.getUserProperty(property) != null;
}
}
-
+
return exists;
}
@@ -224,7 +254,8 @@
* @param file File name.
* @return True if file exists.
*/
- protected boolean checkFile(final File file) {
+ protected boolean checkFile(final File file)
+ {
return file.exists();
}
@@ -234,30 +265,38 @@
* @param classname Class name.
* @return True if class exists.
*/
- protected boolean checkClass(final String classname) {
- try {
- if (loader != null) {
+ protected boolean checkClass(final String classname)
+ {
+ try
+ {
+ if (loader != null)
+ {
loader.loadClass(classname);
}
- else {
+ else
+ {
ClassLoader cl = this.getClass().getClassLoader();
// Can return null to represent the bootstrap class loader.
// see API docs of Class.getClassLoader.
- if (cl != null) {
+ if (cl != null)
+ {
cl.loadClass(classname);
}
- else {
+ else
+ {
Class.forName(classname);
}
}
return true;
}
- catch (ClassNotFoundException e) {
+ catch (ClassNotFoundException e)
+ {
log.verbose("Class not found: " + classname);
return false;
}
- catch (NoClassDefFoundError e) {
+ catch (NoClassDefFoundError e)
+ {
log.verbose("Class cound not be loaded: " + classname);
return false;
}
@@ -269,18 +308,22 @@
* @param resource Resource name.
* @return True if resource exists.
*/
- protected boolean checkResource(final String resource) {
- if (loader != null) {
+ protected boolean checkResource(final String resource)
+ {
+ if (loader != null)
+ {
return (loader.getResourceAsStream(resource) != null);
}
- else {
+ else
+ {
ClassLoader cl = this.getClass().getClassLoader();
- if (cl != null) {
+ if (cl != null)
+ {
return (cl.getResourceAsStream(resource) != null);
}
- else {
- return
- (ClassLoader.getSystemResourceAsStream(resource) != null);
+ else
+ {
+ return (ClassLoader.getSystemResourceAsStream(resource) != null);
}
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ResolveProperties.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ResolveProperties.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ResolveProperties.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -25,8 +38,7 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class ResolveProperties
- extends Task
+public class ResolveProperties extends Task
{
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
@@ -37,24 +49,28 @@
/**
* Set the force flag.
*/
- public void setForce(boolean force) {
+ public void setForce(boolean force)
+ {
this.force = force;
}
/**
* Resolve all property values.
*/
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
log.verbose("Resolving all properties");
- if (force) log.verbose("Unset properties will be forced resolve");
+ if (force)
+ log.verbose("Unset properties will be forced resolve");
Map props = getProject().getProperties();
// iterator over all of the properties
Iterator iter = props.keySet().iterator();
- while (iter.hasNext()) {
- String key = (String)iter.next();
- String value = (String)props.get(key);
+ while (iter.hasNext())
+ {
+ String key = (String) iter.next();
+ String value = (String) props.get(key);
log.debug("property: " + key);
log.debug(" before: " + value);
@@ -65,7 +81,7 @@
props.put(key, value);
}
}
-
+
/**
* Replace any properties in the expression with their values contained
* in the properties map.
@@ -76,72 +92,77 @@
* @return
* @throws BuildException
*/
- public static String subst(final String expression,
- final Map props,
- final boolean force)
- throws BuildException
+ public static String subst(final String expression, final Map props, final boolean force) throws BuildException
{
StringBuffer buff = new StringBuffer();
Set occured = new HashSet(10);
int prev = 0;
int pos;
- while ((pos = expression.indexOf("$", prev)) >= 0) {
- if (pos > 0) {
+ while ((pos = expression.indexOf("$", prev)) >= 0)
+ {
+ if (pos > 0)
+ {
buff.append(expression.substring(prev, pos));
}
- if (pos == (expression.length() - 1)) {
+ if (pos == (expression.length() - 1))
+ {
buff.append('$');
prev = pos + 1;
}
- else if (expression.charAt(pos + 1) != '{') {
+ else if (expression.charAt(pos + 1) != '{')
+ {
buff.append(expression.charAt(pos + 1));
prev = pos + 2;
}
- else {
+ else
+ {
int endName = expression.indexOf('}', pos);
- if (endName < 0) {
+ if (endName < 0)
+ {
throw new BuildException("Syntax error in prop: " + expression);
}
// get the name of the property
String n = expression.substring(pos + 2, endName);
String v = null;
-
- if (!occured.contains(n)) {
+
+ if (!occured.contains(n))
+ {
occured.add(n);
- if (props.containsKey(n)) {
- v = (String)props.get(n);
+ if (props.containsKey(n))
+ {
+ v = (String) props.get(n);
v = subst(v, props, force);
}
occured.remove(n);
}
- if (v == null && !force) {
- v = "${" + n + "}";
+ if (v == null && !force)
+ {
+ v = "${" + n + "}";
}
- if (v != null) buff.append(v);
+ if (v != null)
+ buff.append(v);
prev = endName + 1;
}
}
- if (prev < expression.length()) {
+ if (prev < expression.length())
+ {
buff.append(expression.substring(prev));
}
return buff.toString();
}
- public static String subst(final String value,
- final Project project,
- final boolean force)
+ public static String subst(final String value, final Project project, final boolean force)
{
return subst(value, project.getProperties(), force);
}
- public static String subst(final String value,
- final Project project)
+ public static String subst(final String value, final Project project)
{
return subst(value, project.getProperties(), false);
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Script.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Script.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Script.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -26,8 +39,7 @@
* @version $Id$
* @author Jason Dillon <A href="mailto:jason at planet57.com"><jason at planet57.com></A>
*/
-public class Script
- extends ScriptedTask
+public class Script extends ScriptedTask
{
/** The script text to execute. */
protected StringBuffer script = new StringBuffer();
@@ -37,24 +49,27 @@
*
* @param file The file to load the source from.
*/
- public void setSrc(final File file) throws BuildException {
+ public void setSrc(final File file) throws BuildException
+ {
log.verbose("reading script file: " + file);
if (!file.exists())
throw new BuildException("file not found: " + file);
- int count = (int)file.length();
+ int count = (int) file.length();
byte data[] = new byte[count];
- try {
+ try
+ {
InputStream in = new BufferedInputStream(new FileInputStream(file));
in.read(data);
in.close();
}
- catch (IOException e) {
+ catch (IOException e)
+ {
throw new BuildException(e);
}
-
+
script.append(new String(data));
}
@@ -63,7 +78,8 @@
*
* @param test A line of text to add to the script.
*/
- public void addText(final String text) {
+ public void addText(final String text)
+ {
script.append(text);
}
@@ -72,11 +88,9 @@
*
* @param engine The scripting engine.
*/
- protected void execute(final BSFEngine engine)
- throws BSFException, BuildException
+ protected void execute(final BSFEngine engine) throws BSFException, BuildException
{
// execute the script
engine.exec("<SCRIPT>", 0, 0, script.toString());
}
}
-
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedContainerTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedContainerTask.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedContainerTask.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -19,8 +32,7 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public abstract class ScriptedContainerTask
- extends ScriptedTask
+public abstract class ScriptedContainerTask extends ScriptedTask
{
/** The list of tasks to execute. */
protected List tasks = new LinkedList();
@@ -30,7 +42,8 @@
*
* @param target The target to execute.
*/
- public void setTarget(final String target) {
+ public void setTarget(final String target)
+ {
CallTarget call = createCall();
call.setTarget(target);
tasks.add(call);
@@ -41,7 +54,8 @@
*
* @param script The script for this target.
*/
- public void setScript(final String script) {
+ public void setScript(final String script)
+ {
Script task = createScript();
task.addText(script);
tasks.add(task);
@@ -50,9 +64,10 @@
/**
* Create a nested <tt>call</tt> target.
*/
- public CallTarget createCall() {
+ public CallTarget createCall()
+ {
log.verbose("creating nested <call> task");
- CallTarget task = (CallTarget)getProject().createTask("call");
+ CallTarget task = (CallTarget) getProject().createTask("call");
tasks.add(task);
log.verbose("tasks: " + tasks);
return task;
@@ -61,9 +76,10 @@
/**
* Create a nested <tt>script</tt> target.
*/
- public Script createScript() {
+ public Script createScript()
+ {
log.verbose("creating nested <script> task");
- Script task = (Script)getProject().createTask("script");
+ Script task = (Script) getProject().createTask("script");
tasks.add(task);
log.verbose("tasks: " + tasks);
return task;
@@ -74,7 +90,8 @@
*
* @throws BuildException Attributes are not valid.
*/
- protected void validate() throws BuildException {
+ protected void validate() throws BuildException
+ {
super.validate();
if (tasks.size() == 0)
@@ -84,14 +101,15 @@
/**
* Execute all of the sub-tasks.
*/
- protected void executeTasks() throws BuildException {
+ protected void executeTasks() throws BuildException
+ {
Iterator iter = tasks.iterator();
- while (iter.hasNext()) {
- Task task = (Task)iter.next();
+ while (iter.hasNext())
+ {
+ Task task = (Task) iter.next();
log.debug("executing sub-task: " + task);
task.execute();
}
}
}
-
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedTask.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedTask.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -27,9 +40,7 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public abstract class ScriptedTask
- extends Task
- implements Cloneable
+public abstract class ScriptedTask extends Task implements Cloneable
{
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
@@ -46,7 +57,8 @@
/**
* Set the scripting language that will be used.
*/
- public void setLanguage(final String language) {
+ public void setLanguage(final String language)
+ {
this.language = language;
}
@@ -55,7 +67,8 @@
*
* @throws BuildException Attributes are not valid.
*/
- protected void validate() throws BuildException {
+ protected void validate() throws BuildException
+ {
if (language == null)
throw new MissingAttributeException("language", this);
}
@@ -65,8 +78,10 @@
*
* @throws BSFException Failed to create BSF manager.
*/
- protected BSFManager getManager() throws BSFException {
- if (manager == null) {
+ protected BSFManager getManager() throws BSFException
+ {
+ if (manager == null)
+ {
manager = new BSFManager();
log.debug("created bsf manager: " + manager);
}
@@ -81,7 +96,8 @@
*
* @throws BSFException Failed to create engine.
*/
- protected BSFEngine createEngine() throws BSFException {
+ protected BSFEngine createEngine() throws BSFException
+ {
BSFManager manager = getManager();
// update the namespace
@@ -93,8 +109,9 @@
beans.put("project", getProject());
Iterator iter = beans.keySet().iterator();
- while (iter.hasNext()) {
- String key = (String)iter.next();
+ while (iter.hasNext())
+ {
+ String key = (String) iter.next();
Object value = beans.get(key);
manager.declareBean(key, value, value.getClass());
@@ -112,7 +129,8 @@
*
* @return Source name of the script.
*/
- protected String getSourceName() {
+ protected String getSourceName()
+ {
return "<SCRIPT>";
}
@@ -122,11 +140,12 @@
* @param valie String to check.
* @return True if the string is a valid identifier.
*/
- protected boolean isValidIdentifier(String value) {
- boolean valid = value.length()>0 &&
- Character.isJavaIdentifierStart(value.charAt(0));
-
- for (int i=1; valid && i<value.length(); i++) {
+ protected boolean isValidIdentifier(String value)
+ {
+ boolean valid = value.length() > 0 && Character.isJavaIdentifierStart(value.charAt(0));
+
+ for (int i = 1; valid && i < value.length(); i++)
+ {
valid = Character.isJavaIdentifierPart(value.charAt(i));
}
@@ -139,15 +158,19 @@
*
* @param map Map to add elements from.
*/
- protected void addBeans(final Map map) {
+ protected void addBeans(final Map map)
+ {
Iterator iter = map.keySet().iterator();
- while (iter.hasNext()) {
- String key = (String)iter.next();
- if (isValidIdentifier(key)) {
+ while (iter.hasNext())
+ {
+ String key = (String) iter.next();
+ if (isValidIdentifier(key))
+ {
beans.put(key, map.get(key));
}
- else {
+ else
+ {
log.debug("not a valid identifier: " + key);
}
}
@@ -159,21 +182,27 @@
* <p>Invokes {@link #execute(BSFEngine)} and handles any
* <tt>BSFException</tt>s that are thrown.
*/
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
validate();
- try {
+ try
+ {
BSFEngine engine = createEngine();
execute(engine);
}
- catch (BSFException e) {
+ catch (BSFException e)
+ {
Throwable nested = e.getTargetException();
- if (nested != null) {
- if (nested instanceof BuildException) {
- throw (BuildException)nested;
+ if (nested != null)
+ {
+ if (nested instanceof BuildException)
+ {
+ throw (BuildException) nested;
}
- else {
+ else
+ {
nested = e;
}
}
@@ -186,19 +215,21 @@
*
* @param engine The script specific engine.
*/
- protected abstract void execute(BSFEngine engine)
- throws BSFException, BuildException;
+ protected abstract void execute(BSFEngine engine) throws BSFException, BuildException;
/**
* Return a cloned copy of this object.
*
* @return Cloned object.
*/
- public Object clone() {
- try {
+ public Object clone()
+ {
+ try
+ {
return super.clone();
}
- catch (CloneNotSupportedException e) {
+ catch (CloneNotSupportedException e)
+ {
throw new InternalError();
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Set.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Set.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Set.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -28,131 +41,144 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class Set
- extends VariableTask
+public class Set extends VariableTask
{
- /** The list of nested elements. */
- protected List elements = new LinkedList();
+ /** The list of nested elements. */
+ protected List elements = new LinkedList();
- /**
- * Default to references.
- */
- public Set() {
- type = REFERENCE;
- }
+ /**
+ * Default to references.
+ */
+ public Set()
+ {
+ type = REFERENCE;
+ }
- /**
- * Execute the task, set the variable in name.
- */
- public void execute() throws BuildException {
- if (name == null)
- throw new MissingAttributeException("name", this);
+ /**
+ * Execute the task, set the variable in name.
+ */
+ public void execute() throws BuildException
+ {
+ if (name == null)
+ throw new MissingAttributeException("name", this);
- // if the type is a ref, then it can be any object
- if (type == REFERENCE) {
- Object value = getObject();
- getProject().getReferences().put(name, value);
- log.verbose("set reference " + name + "=" + value);
- }
- else {
- // else it must be converted to a string
- String value = getString();
- String ptype = null;
- Map map = null;
+ // if the type is a ref, then it can be any object
+ if (type == REFERENCE)
+ {
+ Object value = getObject();
+ getProject().getReferences().put(name, value);
+ log.verbose("set reference " + name + "=" + value);
+ }
+ else
+ {
+ // else it must be converted to a string
+ String value = getString();
+ String ptype = null;
+ Map map = null;
- switch (type) {
- case PROPERTY:
- map = getProject().getProperties();
- ptype = "project";
- break;
+ switch (type)
+ {
+ case PROPERTY :
+ map = getProject().getProperties();
+ ptype = "project";
+ break;
- case USER_PROPERTY:
- map = getProject().getUserProperties();
- ptype = "user";
- break;
+ case USER_PROPERTY :
+ map = getProject().getUserProperties();
+ ptype = "user";
+ break;
- case SYSTEM_PROPERTY:
- map = System.getProperties();
- ptype = "system";
- break;
- }
+ case SYSTEM_PROPERTY :
+ map = System.getProperties();
+ ptype = "system";
+ break;
+ }
- map.put(name, value);
- log.verbose("set " + ptype + " property " + name + "=" + value);
- }
- }
+ map.put(name, value);
+ log.verbose("set " + ptype + " property " + name + "=" + value);
+ }
+ }
- /**
- * Return a single object that represents the elements.
- */
- protected Object getObject() {
- Path path = new Path(getProject());
+ /**
+ * Return a single object that represents the elements.
+ */
+ protected Object getObject()
+ {
+ Path path = new Path(getProject());
- Iterator iter = elements.iterator();
- while (iter.hasNext()) {
- Object obj = iter.next();
- if (obj instanceof Path) {
- path.append((Path)obj);
- }
- else {
- path.append(new RPath(getProject(), obj.toString()));
- }
- }
+ Iterator iter = elements.iterator();
+ while (iter.hasNext())
+ {
+ Object obj = iter.next();
+ if (obj instanceof Path)
+ {
+ path.append((Path) obj);
+ }
+ else
+ {
+ path.append(new RPath(getProject(), obj.toString()));
+ }
+ }
- return path;
- }
+ return path;
+ }
- /**
- * Return a string that represents the elements.
- */
- protected String getString() {
- return getObject().toString();
- }
+ /**
+ * Return a string that represents the elements.
+ */
+ protected String getString()
+ {
+ return getObject().toString();
+ }
- /**
- * Create a nested path element.
- */
- public Path createPath() {
- Path path = new Path(getProject());
- elements.add(path);
- return path;
- }
+ /**
+ * Create a nested path element.
+ */
+ public Path createPath()
+ {
+ Path path = new Path(getProject());
+ elements.add(path);
+ return path;
+ }
- /**
- * A Path extentsion that will automatically resolve its contents
- * for property values.
- *
- * <p>NOTE: This is currently disabled due to its parrent prepending
- * the project root to things it thinks are relative.
- * Unfortunatly the bits required to fix this are in statics
- * and/or hidden in the Project object such that it is
- * impossible to fix this with out a large amount of pain.
- *
- * I can't wait for Ant2.
- */
- protected class RPath
- extends Path
- {
- protected Project project;
+ /**
+ * A Path extentsion that will automatically resolve its contents
+ * for property values.
+ *
+ * <p>NOTE: This is currently disabled due to its parrent prepending
+ * the project root to things it thinks are relative.
+ * Unfortunatly the bits required to fix this are in statics
+ * and/or hidden in the Project object such that it is
+ * impossible to fix this with out a large amount of pain.
+ *
+ * I can't wait for Ant2.
+ */
+ protected class RPath extends Path
+ {
+ protected Project project;
- public RPath(final Project project) {
- super(project);
- this.project = project;
- }
+ public RPath(final Project project)
+ {
+ super(project);
+ this.project = project;
+ }
- public RPath(final Project project, final String path) {
- super(project, path);
- }
+ public RPath(final Project project, final String path)
+ {
+ super(project, path);
+ }
- public String[] list() {
- String[] values = super.list();
- Map props = project.getProperties();
+ public String[] list()
+ {
+ String[] values = super.list();
+ Map props = project.getProperties();
- for (int i=0; i<values.length; i++) {
- values[i] = ResolveProperties.subst(values[i], props, false);
- }
+ for (int i = 0; i < values.length; i++)
+ {
+ values[i] = ResolveProperties.subst(values[i], props, false);
+ }
- return values;
- }
- }
+ return values;
+ }
+ }
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Subst.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Subst.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Subst.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,19 +1,29 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
-import java.util.*;
-
import org.apache.tools.ant.*;
-import org.jboss.tools.buildmagic.task.*;
import org.jboss.tools.buildmagic.task.util.TaskLogger;
/**
@@ -22,30 +32,36 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class Subst
- extends Task
+public class Subst extends Task
{
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
protected String value;
+
protected String property;
+
protected String from;
+
protected String to;
- public void setValue(String value) {
+ public void setValue(String value)
+ {
this.value = value;
}
- public void setProperty(String property) {
+ public void setProperty(String property)
+ {
this.property = property;
}
- public void setFrom(String from) {
+ public void setFrom(String from)
+ {
this.from = from;
}
- public void setTo(String to) {
+ public void setTo(String to)
+ {
this.to = to;
}
@@ -65,7 +81,8 @@
{
int begin = 0, end = 0;
- while ((end = string.indexOf(from, end)) != -1) {
+ while ((end = string.indexOf(from, end)) != -1)
+ {
// append the first part of the string
buff.append(string.substring(begin, end));
@@ -88,7 +105,8 @@
*
* @throws BuildException
*/
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
if (value == null)
throw new BuildException("value is null");
if (property == null)
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Tasks.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Tasks.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Tasks.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -31,21 +44,21 @@
* @param unless The <em>unless</em> condition.
* @return True if the task can execute.
*/
- public static boolean canExecute(final Map props,
- final String _if,
- final String unless)
+ public static boolean canExecute(final Map props, final String _if, final String unless)
{
- if (_if != null && !props.containsKey(_if)) {
+ if (_if != null && !props.containsKey(_if))
+ {
return false;
}
-
- if (unless != null && props.containsKey(unless)) {
+
+ if (unless != null && props.containsKey(unless))
+ {
return false;
}
return true;
}
-
+
/**
* Determine if a task should execute based on the given if and unless
* condtions.
@@ -55,13 +68,11 @@
* @param unless The <em>unless</em> condition.
* @return True if the task can execute.
*/
- public static boolean canExecute(final Project project,
- final String _if,
- final String unless)
+ public static boolean canExecute(final Project project, final String _if, final String unless)
{
return canExecute(project.getProperties(), _if, unless);
}
-
+
/**
* Determine if a task should execute based on the given if and unless
* condtions.
@@ -71,9 +82,7 @@
* @param unless The <em>unless</em> condition.
* @return True if the task can execute.
*/
- public static boolean canExecute(final Task task,
- final String _if,
- final String unless)
+ public static boolean canExecute(final Task task, final String _if, final String unless)
{
return canExecute(task.getProject(), _if, unless);
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Unset.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Unset.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Unset.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -17,43 +30,45 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class Unset
- extends VariableTask
+public class Unset extends VariableTask
{
- /**
- * Default to references.
- */
- public Unset() {
- type = REFERENCE;
- }
+ /**
+ * Default to references.
+ */
+ public Unset()
+ {
+ type = REFERENCE;
+ }
- /**
- * Execute the task, unset the variable in name.
- */
- public void execute() throws BuildException {
- if (name == null)
- throw new MissingAttributeException("name", this);
-
- switch (type) {
- case PROPERTY:
- getProject().getProperties().remove(name);
- log.verbose("unset property: " + name);
- break;
-
- case USER_PROPERTY:
- getProject().getUserProperties().remove(name);
- log.verbose("unset user property: " + name);
- break;
+ /**
+ * Execute the task, unset the variable in name.
+ */
+ public void execute() throws BuildException
+ {
+ if (name == null)
+ throw new MissingAttributeException("name", this);
- case SYSTEM_PROPERTY:
- System.getProperties().remove(name);
- log.verbose("unset system property: " + name);
- break;
-
- case REFERENCE:
- getProject().getReferences().remove(name);
- log.verbose("unset reference: " + name);
- break;
- }
- }
+ switch (type)
+ {
+ case PROPERTY :
+ getProject().getProperties().remove(name);
+ log.verbose("unset property: " + name);
+ break;
+
+ case USER_PROPERTY :
+ getProject().getUserProperties().remove(name);
+ log.verbose("unset user property: " + name);
+ break;
+
+ case SYSTEM_PROPERTY :
+ System.getProperties().remove(name);
+ log.verbose("unset system property: " + name);
+ break;
+
+ case REFERENCE :
+ getProject().getReferences().remove(name);
+ log.verbose("unset reference: " + name);
+ break;
+ }
+ }
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/UnsupportedAttributeException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/UnsupportedAttributeException.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/UnsupportedAttributeException.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -17,11 +30,10 @@
* @version $Id$
* @author Jason Dillon <A href="mailto:jason at planet57.com"><jason at planet57.com></A>
*/
-public class UnsupportedAttributeException
- extends BuildException
+public class UnsupportedAttributeException extends BuildException
{
- public UnsupportedAttributeException(String name, Task task) {
- super(task.getClass() + " does not support the '" + name + "' attribute.",
- task.getLocation());
+ public UnsupportedAttributeException(String name, Task task)
+ {
+ super(task.getClass() + " does not support the '" + name + "' attribute.", task.getLocation());
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/UnsupportedElementException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/UnsupportedElementException.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/UnsupportedElementException.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -17,11 +30,10 @@
* @version $Id$
* @author Jason Dillon <A href="mailto:jason at planet57.com"><jason at planet57.com></A>
*/
-public class UnsupportedElementException
- extends BuildException
+public class UnsupportedElementException extends BuildException
{
- public UnsupportedElementException(String name, Task task) {
- super(task.getClass() + " does not support the '" + name + "' element.",
- task.getLocation());
+ public UnsupportedElementException(String name, Task task)
+ {
+ super(task.getClass() + " does not support the '" + name + "' element.", task.getLocation());
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/VariableTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/VariableTask.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/VariableTask.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task;
@@ -19,57 +32,63 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public abstract class VariableTask
- extends Task
+public abstract class VariableTask extends Task
{
- /** Property variable. */
- public static final int PROPERTY = 0;
+ /** Property variable. */
+ public static final int PROPERTY = 0;
- /** User property variable. */
- public static final int USER_PROPERTY = 1;
+ /** User property variable. */
+ public static final int USER_PROPERTY = 1;
- /** System property variable. */
- public static final int SYSTEM_PROPERTY = 2;
+ /** System property variable. */
+ public static final int SYSTEM_PROPERTY = 2;
- /** Reference variable. */
- public static final int REFERENCE = 3;
-
- /** Instance logger. */
- protected final TaskLogger log = new TaskLogger(this);
+ /** Reference variable. */
+ public static final int REFERENCE = 3;
- /** The name of the variable. */
- protected String name;
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
- /** The type of variable. */
- protected int type;
+ /** The name of the variable. */
+ protected String name;
- /**
- * Set the name of the variable.
- */
- public void setName(final String name) {
- this.name = name;
- }
-
- /**
- * Set the type of the variable.
- */
- public void setType(String type) {
- type = type.toLowerCase();
-
- if (type.equals("prop") || type.equals("property")) {
- this.type = PROPERTY;
- }
- else if (type.equals("userprop") || type.equals("userproperty")) {
- this.type = USER_PROPERTY;
- }
- else if (type.equals("sysprop") || type.equals("systemproperty")) {
- this.type = SYSTEM_PROPERTY;
- }
- else if (type.equals("ref") || type.equals("reference")) {
- this.type = REFERENCE;
- }
- else {
- throw new IllegalAttributeException("type", this);
- }
- }
+ /** The type of variable. */
+ protected int type;
+
+ /**
+ * Set the name of the variable.
+ */
+ public void setName(final String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Set the type of the variable.
+ */
+ public void setType(String type)
+ {
+ type = type.toLowerCase();
+
+ if (type.equals("prop") || type.equals("property"))
+ {
+ this.type = PROPERTY;
+ }
+ else if (type.equals("userprop") || type.equals("userproperty"))
+ {
+ this.type = USER_PROPERTY;
+ }
+ else if (type.equals("sysprop") || type.equals("systemproperty"))
+ {
+ this.type = SYSTEM_PROPERTY;
+ }
+ else if (type.equals("ref") || type.equals("reference"))
+ {
+ this.type = REFERENCE;
+ }
+ else
+ {
+ throw new IllegalAttributeException("type", this);
+ }
+ }
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.config;
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.config;
@@ -18,11 +31,8 @@
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;
/**
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/ModuleLibrary.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/ModuleLibrary.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/ModuleLibrary.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.config;
@@ -20,13 +33,12 @@
* @version <tt>$Revision$</tt>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class ModuleLibrary
- extends Library
+public class ModuleLibrary extends Library
{
protected File getVendorDir()
{
- File vendorNameDir = new File( root, name );
- File vendorOutputDir = new File ( vendorNameDir, "output" );
- return vendorOutputDir;
+ File vendorNameDir = new File(root, name);
+ File vendorOutputDir = new File(vendorNameDir, "output");
+ return vendorOutputDir;
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/AbstractInfo.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/AbstractInfo.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/AbstractInfo.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,18 +1,30 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.module;
import java.util.Map;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
import org.jboss.tools.buildmagic.task.util.TaskLogger;
@@ -22,24 +34,27 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public abstract class AbstractInfo
- extends Task
+public abstract class AbstractInfo extends Task
{
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
protected String _if;
+
protected String unless;
- public void setIf(final String property) {
+ public void setIf(final String property)
+ {
this._if = property;
}
- public void setUnless(final String property) {
+ public void setUnless(final String property)
+ {
this.unless = property;
}
- protected boolean canContinue() {
+ protected boolean canContinue()
+ {
Map map = getProject().getProperties();
if (_if != null && !map.containsKey(_if))
return false;
@@ -48,8 +63,9 @@
return true;
}
-
- protected String getProperty(String name) {
+
+ protected String getProperty(String name)
+ {
return getProject().getProperty(name);
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ExecuteModules.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ExecuteModules.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ExecuteModules.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,16 +1,28 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.module;
import java.io.File;
-import java.io.PrintWriter;
import java.util.List;
import java.util.LinkedList;
@@ -20,17 +32,13 @@
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.TaskAdapter;
import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Target;
-import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Property;
import org.apache.tools.ant.taskdefs.Echo;
import org.jboss.util.Strings;
-import org.jboss.tools.buildmagic.task.IllegalAttributeException;
import org.jboss.tools.buildmagic.task.ResolveProperties;
import org.jboss.tools.buildmagic.task.Ant;
import org.jboss.tools.buildmagic.task.AbstractBuildListener;
@@ -43,8 +51,7 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class ExecuteModules
- extends Task
+public class ExecuteModules extends Task
{
/*
static {
@@ -57,7 +64,7 @@
});
}
*/
-
+
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
@@ -66,7 +73,7 @@
/** The buildfile to use. */
protected String antfile;
-
+
/** The list of module names to exectue. */
protected List modules;
@@ -80,17 +87,21 @@
protected Project _project;
protected String moduleProperty = "module";
+
protected String targetProperty = "target";
-
+
/** Skip over modules that do not exist. */
protected boolean skipMissing = false;
+
protected boolean inheritAll = false;
-
+
/** Tasks to echo some output before and after each module executes. */
protected List headers = new LinkedList();
+
protected List footers = new LinkedList();
protected List beforeHooks = new LinkedList();
+
protected List afterHooks = new LinkedList();
protected ModuleBuildListener listener = new ModuleBuildListener();
@@ -105,134 +116,155 @@
{
threading = flag;
}
-
- public void setExportproperties(String list) {
+
+ public void setExportproperties(String list)
+ {
StringTokenizer stok = new StringTokenizer(list, ",");
- while (stok.hasMoreTokens()) {
+ while (stok.hasMoreTokens())
+ {
exportProperties.add(stok.nextToken().trim());
}
}
-
- public void setModuleproperty(String property) {
+
+ public void setModuleproperty(String property)
+ {
moduleProperty = property;
}
- public void setTargetproperty(String property) {
+ public void setTargetproperty(String property)
+ {
targetProperty = property;
}
- public void setInheritAll(boolean flag) {
+ public void setInheritAll(boolean flag)
+ {
inheritAll = flag;
}
/** Setup the internal project. */
- public void init() {
+ public void init()
+ {
_project = new Project();
_project.setJavaVersionProperty();
Map tasks = getProject().getTaskDefinitions();
- _project.addTaskDefinition("property", (Class)tasks.get("property"));
- _project.addTaskDefinition("echo", (Class)tasks.get("echo"));
+ _project.addTaskDefinition("property", (Class) tasks.get("property"));
+ _project.addTaskDefinition("echo", (Class) tasks.get("echo"));
}
/** Re-initialize the internal project. */
- protected void reinit() {
+ protected void reinit()
+ {
init();
// copy the list of properties to the new internal project
- for (int i=0; i<properties.size(); i++) {
- Property a = (Property)properties.get(i);
- Property b = (Property)_project.createTask("property");
- copy(a, b);
+ for (int i = 0; i < properties.size(); i++)
+ {
+ Property a = (Property) properties.get(i);
+ Property b = (Property) _project.createTask("property");
+ copy(a, b);
properties.set(i, b);
}
}
/** Copy a property values to another property. */
- protected void copy(final Property a, final Property b) {
+ protected void copy(final Property a, final Property b)
+ {
b.setName(a.getName());
-
- if (a.getValue() != null) {
+
+ if (a.getValue() != null)
+ {
b.setValue(a.getValue());
}
-
- if (a.getFile() != null) {
+
+ if (a.getFile() != null)
+ {
b.setFile(a.getFile());
}
-
- if (a.getResource() != null) {
+
+ if (a.getResource() != null)
+ {
b.setResource(a.getResource());
}
}
-
+
/** Set the target name. */
- public void setTarget(final String target) {
+ public void setTarget(final String target)
+ {
this.target = target;
}
/** Set the buildfile to use. */
- public void setAntfile(final String antfile) {
+ public void setAntfile(final String antfile)
+ {
this.antfile = antfile;
}
-
+
/** Set the modules to execute. */
- public void setModules(String names) {
+ public void setModules(String names)
+ {
names = ResolveProperties.subst(names, getProject(), true);
StringTokenizer stok = new StringTokenizer(names, ",");
modules = new LinkedList();
- while (stok.hasMoreTokens()) {
+ while (stok.hasMoreTokens())
+ {
modules.add(stok.nextToken().trim());
}
}
- public void setSkipmissing(boolean flag) {
+ public void setSkipmissing(boolean flag)
+ {
skipMissing = flag;
}
-
+
/** Set the root. */
- public void setRoot(final String dir) throws BuildException {
+ public void setRoot(final String dir) throws BuildException
+ {
this.root = dir;
}
-
+
/**
* Execute this task.
*
* @throws BuildException Failed to execute task.
*/
- public void execute() throws BuildException {
- try {
+ public void execute() throws BuildException
+ {
+ try
+ {
// need at least one module name
- if (modules == null || modules.size() == 0) {
- throw new BuildException
- ("No module names were specified", getLocation());
+ if (modules == null || modules.size() == 0)
+ {
+ throw new BuildException("No module names were specified", getLocation());
}
// need the root directory
- if (root == null) {
- throw new BuildException
- ("Root directory not specified", getLocation());
+ if (root == null)
+ {
+ throw new BuildException("Root directory not specified", getLocation());
}
Iterator iter = modules.iterator();
- while (iter.hasNext()) {
- executeModule((String)iter.next());
+ while (iter.hasNext())
+ {
+ executeModule((String) iter.next());
}
}
- finally {
+ finally
+ {
// help the gc
_project = null;
}
}
-
+
/**
* Execute a single module.
*/
- protected void executeModule(final String module)
- throws BuildException
+ protected void executeModule(final String module) throws BuildException
{
this.module = module;
// create and setup the ant task
- final Ant ant = (Ant)getProject().createTask("Ant");
+ final Ant ant = (Ant) getProject().createTask("Ant");
ant.setInheritAll(inheritAll);
ant.init();
@@ -246,7 +278,7 @@
p.execute();*/
// project.setUserProperty(moduleProperty, module);
_project.setProperty(moduleProperty, module);
-
+
// add a property for the target of the module (our name that is)
String tempTargetName = (target == null) ? "<default>" : target;
evaluateExpression(tempTargetName);
@@ -257,47 +289,51 @@
p.execute();*/
// project.setUserProperty(targetProperty, tempTargetName);
_project.setProperty(targetProperty, tempTargetName);
-
+
ant.setLocation(getLocation());
tempTargetName = ResolveProperties.subst(root, getProject());
tempTargetName = Strings.subst("@MODULE@", module, tempTargetName);
tempTargetName = Strings.subst("@TARGET@", target, tempTargetName);
-
+
File moduleRoot = new File(tempTargetName);
log.verbose("module root: " + moduleRoot);
ant.setDir(moduleRoot);
ant.setAntfile(antfile);
-
- if (target != null) {
+
+ if (target != null)
+ {
log.verbose("using target: " + target);
ant.setTarget(target);
}
Map props = getProject().getProperties();
-
+
// Workaround for ant 1.7 compatibility [JBBUILD-432]
- if ( props.get("ant.version").toString().contains("1.7") )
+ if (props.get("ant.version").toString().contains("1.7"))
{
- Property antVersion = ant.createProperty();
- antVersion.setName("ant.version");
- antVersion.setValue(props.get("ant.version").toString());
- antVersion.execute();
-
- Property antCoreLib = ant.createProperty();
- antCoreLib.setName("ant.core.lib");
- antCoreLib.setValue(props.get("ant.core.lib").toString());
- antCoreLib.execute();
+ Property antVersion = ant.createProperty();
+ antVersion.setName("ant.version");
+ antVersion.setValue(props.get("ant.version").toString());
+ antVersion.execute();
+
+ Property antCoreLib = ant.createProperty();
+ antCoreLib.setName("ant.core.lib");
+ antCoreLib.setValue(props.get("ant.core.lib").toString());
+ antCoreLib.execute();
}
// End hack
-
// see if this is a valid ant file
- try {
- if (ant.getBuildFile() != null);
+ try
+ {
+ if (ant.getBuildFile() != null)
+ ;
}
- catch (BuildException e) {
+ catch (BuildException e)
+ {
log.verbose("exception: " + e);
- if (skipMissing) {
+ if (skipMissing)
+ {
listener.skipped(module);
log.warning("Missing build file; skipping module: " + module);
@@ -311,13 +347,14 @@
}
runHooks(beforeHooks);
-
+
ant.addBuildListener(listener);
-
+
// set up any properties
Iterator iter = properties.iterator();
- while (iter.hasNext()) {
- Property a = (Property)iter.next();
+ while (iter.hasNext())
+ {
+ Property a = (Property) iter.next();
Property b = ant.createProperty();
copy(a, b);
a.execute();
@@ -325,9 +362,10 @@
// export any listed property names
iter = exportProperties.iterator();
- while (iter.hasNext()) {
- String name = (String)iter.next();
- String value = (String)props.get(name);
+ while (iter.hasNext())
+ {
+ String name = (String) iter.next();
+ String value = (String) props.get(name);
Property p = ant.createProperty();
p.setName(name);
p.setValue(value);
@@ -336,75 +374,85 @@
}
final String targetName = tempTargetName;
-
+
Runnable runner = new Runnable()
+ {
+ public void run()
{
- public void run()
- {
- // execute the task
- printHeading(headers);
- log.verbose("Executing " + targetName + " in module '" + module + "'...");
+ // execute the task
+ printHeading(headers);
+ log.verbose("Executing " + targetName + " in module '" + module + "'...");
- ant.execute();
-
- log.verbose("Finished with " + targetName + " in module '" + module + "'...");
- printHeading(footers);
+ ant.execute();
- runHooks(afterHooks);
- }
- };
-
- if (threading) {
+ log.verbose("Finished with " + targetName + " in module '" + module + "'...");
+ printHeading(footers);
+
+ runHooks(afterHooks);
+ }
+ };
+
+ if (threading)
+ {
new Thread(runner, "Module Runner (" + module + ":" + targetName + ")").start();
}
- else {
+ else
+ {
runner.run();
}
-
+
// shit this sucks
// jason: this will not work in ant 1.5
// props.remove(moduleProperty);
// props.remove(targetProperty);
-
+
// iter = properties.iterator();
// while (iter.hasNext()) {
// Property a = (Property)iter.next();
// props.remove(a.getName());
// }
- }
+ }
- protected void printHeading(List headers) {
+ protected void printHeading(List headers)
+ {
Iterator iter = headers.iterator();
- while (iter.hasNext()) {
- MyEcho header = (MyEcho)iter.next();
+ while (iter.hasNext())
+ {
+ MyEcho header = (MyEcho) iter.next();
header.execute();
}
}
-
+
/** Create a nested property. */
- public Property createProperty() {
+ public Property createProperty()
+ {
Property prop = createProperty(properties);
return prop;
}
/** Create a nested property. */
- public Property createProperty(List list) {
- if (_project == null) {
+ public Property createProperty(List list)
+ {
+ if (_project == null)
+ {
reinit();
}
- Property prop = (Property)_project.createTask("property");
-
- if (list != null) {
+ Property prop = (Property) _project.createTask("property");
+
+ if (list != null)
+ {
list.add(0, prop);
}
-
+
return prop;
}
-
+
/** Create a nested header. */
- public Echo createHeader() {
- if (_project == null) {
+ public Echo createHeader()
+ {
+ if (_project == null)
+ {
reinit();
}
@@ -414,12 +462,13 @@
}
/** Create a nested footer. */
- public Echo createFooter() {
- if (_project == null) {
+ public Echo createFooter()
+ {
+ if (_project == null)
+ {
reinit();
}
-
MyEcho footer = new MyEcho(getProject());
footers.add(footer);
return footer;
@@ -432,116 +481,127 @@
* @param expr
* @return
*/
- public String evaluateExpression(String expr) {
+ public String evaluateExpression(String expr)
+ {
Map props = getProject().getUserProperties();
expr = ResolveProperties.subst(expr, props, false);
-
+
props = _project.getUserProperties();
expr = ResolveProperties.subst(expr, props, false);
props = _project.getProperties();
expr = ResolveProperties.subst(expr, props, false);
-
+
return expr;
}
-
+
/*public void printProperties(Map props, String header)
{
- Iterator keys = props.keySet().iterator();
- System.out.println(header);
- while(keys.hasNext())
- {
- Object key = keys.next();
- System.out.println(key + ":" + props.get(key));
- }
+ Iterator keys = props.keySet().iterator();
+ System.out.println(header);
+ while(keys.hasNext())
+ {
+ Object key = keys.next();
+ System.out.println(key + ":" + props.get(key));
+ }
}*/
-
+
/**
* Nested echo class to hold header and footer data.
*/
- protected class MyEcho
- extends Echo
+ protected class MyEcho extends Echo
{
Project project;
-
+
public MyEcho(Project project)
{
this.project = project;
}
-
- public void addText(String msg) {
+
+ public void addText(String msg)
+ {
message += msg;
}
-
- public void execute() throws BuildException {
+
+ public void execute() throws BuildException
+ {
String temp = evaluateExpression(message);
-
+
temp = Strings.subst("@MODULE@", module, temp);
temp = Strings.subst("@TARGET@", ExecuteModules.this.target, temp);
project.log(temp, logLevel);
}
-
+
public String getMessage()
{
- return this.message;
+ return this.message;
}
}
- public Hook createBefore() {
+ public Hook createBefore()
+ {
Hook hook = new Hook(this);
beforeHooks.add(hook);
return hook;
}
-
- public Hook createAfter() {
+
+ public Hook createAfter()
+ {
Hook hook = new Hook(this);
afterHooks.add(hook);
return hook;
}
-
+
protected class Hook
{
public ExecuteModules task;
+
public String target;
-
- public Hook(ExecuteModules task) {
+ public Hook(ExecuteModules task)
+ {
this.task = task;
}
-
- public void setTarget(String target) {
+
+ public void setTarget(String target)
+ {
this.target = target;
}
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
Project project = task.getProject();
String t = task.evaluateExpression(target);
t = Strings.subst("@MODULE@", module, t);
t = Strings.subst("@TARGET@", ExecuteModules.this.target, t);
-
- if (project.getTargets().containsKey(t)) {
+
+ if (project.getTargets().containsKey(t))
+ {
project.executeTarget(t);
}
- else {
+ else
+ {
log.verbose("skipping missing hook: " + t);
}
}
}
- protected void runHooks(List list) throws BuildException {
+ protected void runHooks(List list) throws BuildException
+ {
log.verbose("executing hooks");
log.debug("list: " + list);
-
+
Iterator iter = list.iterator();
- while (iter.hasNext()) {
- Hook hook = (Hook)iter.next();
+ while (iter.hasNext())
+ {
+ Hook hook = (Hook) iter.next();
log.debug("executing hook: " + hook);
hook.execute();
}
}
-
+
/**
* This is meant to provide the ability to generate an xml file
* which contains what modules we have invoked, their targets and
@@ -551,52 +611,68 @@
* to produce documentaion for the build, only showing the relevant
* bits.
*/
- protected class ModuleBuildListener
- extends AbstractBuildListener
+ protected class ModuleBuildListener extends AbstractBuildListener
{
//
// hookup xml output here
//
- public void skipped(String module) {
+ public void skipped(String module)
+ {
// System.out.println("skipped module: " + module);
}
- public void buildStarted(BuildEvent event) {
+
+ public void buildStarted(BuildEvent event)
+ {
// System.out.println("started build: " + event);
}
- public void buildFinished(BuildEvent event) {
+
+ public void buildFinished(BuildEvent event)
+ {
// System.out.println("finished build: " + event);
}
- public void targetStarted(BuildEvent event) {
+
+ public void targetStarted(BuildEvent event)
+ {
// System.out.println("started target: " + event.getTarget());
}
- public void targetFinished(BuildEvent event) {
+
+ public void targetFinished(BuildEvent event)
+ {
// System.out.println("finished target: " + event.getTarget());
}
- public void taskStarted(BuildEvent event) {
+
+ public void taskStarted(BuildEvent event)
+ {
// System.out.println("started task: " + event.getTask());
}
- public void taskFinished(BuildEvent event) {
+
+ public void taskFinished(BuildEvent event)
+ {
// System.out.println("finished task: " + event.getTask());
}
- public void messageLogged(BuildEvent event) {
+
+ public void messageLogged(BuildEvent event)
+ {
Throwable t = event.getException();
int pri = event.getPriority();
String message = event.getMessage();
-
- if (t != null) {
+
+ if (t != null)
+ {
// System.out.println("exception: " + t);
}
- switch (pri) {
- case Project.MSG_ERR:
- // System.out.println("error: " + message);
- break;
- case Project.MSG_WARN:
- // System.out.println("warning: " + message);
- break;
- case Project.MSG_INFO:
- case Project.MSG_VERBOSE:
- case Project.MSG_DEBUG:
+ switch (pri)
+ {
+ case Project.MSG_ERR :
+ // System.out.println("error: " + message);
+ break;
+ case Project.MSG_WARN :
+ // System.out.println("warning: " + message);
+ break;
+ case Project.MSG_INFO :
+ case Project.MSG_VERBOSE :
+ case Project.MSG_DEBUG :
}
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleConfig.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleConfig.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleConfig.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.module;
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInfo.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInfo.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInfo.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -17,16 +17,17 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class ModuleInfo
- extends AbstractInfo
+public class ModuleInfo extends AbstractInfo
{
/**
* Execute this task.
*
* @throws BuildException Failed to execute task.
*/
- public void execute() throws BuildException {
- if (!canContinue()) return;
+ public void execute() throws BuildException
+ {
+ if (!canContinue())
+ return;
log.info("Project root: " + getProperty("project.root"));
log.info(" Module root: " + getProperty("module.root"));
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInit.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInit.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInit.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -13,7 +13,6 @@
import org.apache.tools.ant.BuildException;
import org.jboss.tools.buildmagic.task.MissingAttributeException;
-import org.jboss.tools.buildmagic.task.MissingElementException;
import org.jboss.tools.buildmagic.task.util.TaskLogger;
/**
@@ -29,14 +28,15 @@
* @version <tt>$Revision$</tt>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class ModuleInit
- extends Task
+public class ModuleInit extends Task
{
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
protected String name;
+
protected String title;
+
protected String version;
public void setName(final String name)
@@ -59,7 +59,7 @@
*
* @throws BuildException Attributes are not valid.
*/
- protected void validate() throws BuildException
+ protected void validate() throws BuildException
{
if (name == null)
throw new MissingAttributeException("name", this);
@@ -70,21 +70,23 @@
*
* @throws BuildException Failed to execute.
*/
- public void execute() throws BuildException
+ public void execute() throws BuildException
{
validate();
getProject().setProperty("module.name", name);
log.debug("name: " + name);
- if (title == null) {
+ if (title == null)
+ {
title = name;
}
getProject().setProperty("module.title", name);
getProject().setProperty("module.Name", name); // deprecated
log.debug("title: " + title);
- if (version == null) {
+ if (version == null)
+ {
version = "DEV";
}
getProject().setProperty("module.version", version);
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/NamedElement.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/NamedElement.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/NamedElement.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,5 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.tools.buildmagic.task.module;
+/**
+ * Module configuration task.
+ *
+ * @todo Merge groups and modules. they will share namespace, but
+ * will be easier to work with.
+ *
+ * @version <pre>$Id$</pre>
+ * @author Paul Gier
+ */
public interface NamedElement
{
public String getName();
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ProjectInfo.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ProjectInfo.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ProjectInfo.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.module;
@@ -17,17 +30,18 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class ProjectInfo
- extends AbstractInfo
+public class ProjectInfo extends AbstractInfo
{
/**
* Execute this task.
*
* @throws BuildException Failed to execute task.
*/
- public void execute() throws BuildException {
- if (!canContinue()) return;
-
+ public void execute() throws BuildException
+ {
+ if (!canContinue())
+ return;
+
log.info("Project root: " + getProperty("project.root"));
log.info("Modules: " + getProperty("modules"));
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/ConditionalExecution.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/ConditionalExecution.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/ConditionalExecution.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.util;
@@ -26,44 +39,53 @@
public class ConditionalExecution
{
protected List conditions = new LinkedList();
+
protected Task task;
- public ConditionalExecution(final Task task) {
+ public ConditionalExecution(final Task task)
+ {
this.task = task;
}
- public Condition createCondition() {
+ public Condition createCondition()
+ {
Condition cond = new Condition();
conditions.add(cond);
return cond;
}
- public boolean canExecute() {
+ public boolean canExecute()
+ {
Iterator iter = conditions.iterator();
boolean can = true;
- while (iter.hasNext()) {
- Condition cond = (Condition)iter.next();
+ while (iter.hasNext())
+ {
+ Condition cond = (Condition) iter.next();
if (!cond.canExecute())
can = false;
}
return can;
}
-
+
public class Condition
{
protected String _if;
+
protected String unless;
- public void setIf(String property) {
+ public void setIf(String property)
+ {
_if = property;
}
- public void setUnless(String property) {
+ public void setUnless(String property)
+ {
unless = property;
}
-
- public boolean canExecute() {
+
+ public boolean canExecute()
+ {
return Tasks.canExecute(task, _if, unless);
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Dump.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Dump.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Dump.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.util;
@@ -21,69 +34,90 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class Dump
- extends Task
+public class Dump extends Task
{
- /** Instance logger. */
- protected final TaskLogger log = new TaskLogger(this);
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
- protected boolean refs;
- protected boolean properties;
- protected boolean datatypes;
- protected boolean targets;
- protected boolean taskdefs;
- protected boolean filters;
+ protected boolean refs;
- public void setRefs(boolean flag) {
- refs = flag;
- }
+ protected boolean properties;
- public void setProperties(boolean flag) {
- properties = flag;
- }
+ protected boolean datatypes;
- public void setProps(boolean flag) {
- setProperties(flag);
- }
+ protected boolean targets;
- public void setDatatypes(boolean flag) {
- datatypes = flag;
- }
+ protected boolean taskdefs;
- public void setTargets(boolean flag) {
- targets = flag;
- }
+ protected boolean filters;
- public void setTaskdefs(boolean flag) {
- taskdefs = flag;
- }
-
- public void setFilters(boolean flag) {
- filters = flag;
- }
-
- public void execute() throws BuildException {
- if (refs) dumpMap("References", getProject().getReferences());
- if (properties) dumpMap("Properties", getProject().getProperties());
- if (datatypes) dumpMap("DataTypes", getProject().getDataTypeDefinitions());
- if (targets) dumpMap("Targets", getProject().getTargets());
- if (taskdefs) dumpMap("Taskdefs", getProject().getTaskDefinitions());
- if (filters) dumpMap("Filters", getProject().getGlobalFilterSet().getFilterHash());
- }
+ public void setRefs(boolean flag)
+ {
+ refs = flag;
+ }
- protected void dumpMap(final String name, final Map map) {
- log.info(name + ":");
- dumpMap(map, " ");
- log.info("");
- }
-
- protected void dumpMap(final Map map, final String prefix) {
- Iterator iter = map.keySet().iterator();
- while (iter.hasNext()) {
- String key = (String)iter.next();
- Object value = map.get(key);
- String classname = value.getClass().getName();
- log.info(prefix + key + "=" + value + " (" + classname + ")");
- }
- }
+ public void setProperties(boolean flag)
+ {
+ properties = flag;
+ }
+
+ public void setProps(boolean flag)
+ {
+ setProperties(flag);
+ }
+
+ public void setDatatypes(boolean flag)
+ {
+ datatypes = flag;
+ }
+
+ public void setTargets(boolean flag)
+ {
+ targets = flag;
+ }
+
+ public void setTaskdefs(boolean flag)
+ {
+ taskdefs = flag;
+ }
+
+ public void setFilters(boolean flag)
+ {
+ filters = flag;
+ }
+
+ public void execute() throws BuildException
+ {
+ if (refs)
+ dumpMap("References", getProject().getReferences());
+ if (properties)
+ dumpMap("Properties", getProject().getProperties());
+ if (datatypes)
+ dumpMap("DataTypes", getProject().getDataTypeDefinitions());
+ if (targets)
+ dumpMap("Targets", getProject().getTargets());
+ if (taskdefs)
+ dumpMap("Taskdefs", getProject().getTaskDefinitions());
+ if (filters)
+ dumpMap("Filters", getProject().getGlobalFilterSet().getFilterHash());
+ }
+
+ protected void dumpMap(final String name, final Map map)
+ {
+ log.info(name + ":");
+ dumpMap(map, " ");
+ log.info("");
+ }
+
+ protected void dumpMap(final Map map, final String prefix)
+ {
+ Iterator iter = map.keySet().iterator();
+ while (iter.hasNext())
+ {
+ String key = (String) iter.next();
+ Object value = map.get(key);
+ String classname = value.getClass().getName();
+ log.info(prefix + key + "=" + value + " (" + classname + ")");
+ }
+ }
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Puke.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Puke.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Puke.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.util;
@@ -18,18 +31,20 @@
* @version <pre>$Id$</pre>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
*/
-public class Puke
- extends Task
+public class Puke extends Task
{
- public Puke() {
- throw new RuntimeException("puke");
- }
-
- public void init() throws BuildException {
- throw new BuildException("puke");
- }
-
- public void execute() throws BuildException {
- throw new BuildException("puke");
- }
+ public Puke()
+ {
+ throw new RuntimeException("puke");
+ }
+
+ public void init() throws BuildException
+ {
+ throw new BuildException("puke");
+ }
+
+ public void execute() throws BuildException
+ {
+ throw new BuildException("puke");
+ }
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/TaskLogger.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/TaskLogger.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/TaskLogger.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,11 +1,24 @@
-/***************************************
- * *
- * JBoss: The OpenSource J2EE WebOS *
- * *
- * Distributable under LGPL license. *
- * See terms of license at gnu.org. *
- * *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.tools.buildmagic.task.util;
@@ -21,27 +34,33 @@
{
protected Task task;
- public TaskLogger(final Task task) {
+ public TaskLogger(final Task task)
+ {
this.task = task;
}
- public void info(final String message) {
+ public void info(final String message)
+ {
task.log(message, Project.MSG_INFO);
}
- public void error(final String message) {
+ public void error(final String message)
+ {
task.log(message, Project.MSG_ERR);
}
- public void warning(final String message) {
+ public void warning(final String message)
+ {
task.log(message, Project.MSG_WARN);
}
- public void verbose(final String message) {
+ public void verbose(final String message)
+ {
task.log(message, Project.MSG_VERBOSE);
}
- public void debug(final String message) {
+ public void debug(final String message)
+ {
task.log(message, Project.MSG_DEBUG);
}
}
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/test/org/jboss/tools/buildmagic/task/ResolvePropertiesTestCase.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/test/org/jboss/tools/buildmagic/task/ResolvePropertiesTestCase.java 2008-12-18 20:01:59 UTC (rev 24429)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/test/org/jboss/tools/buildmagic/task/ResolvePropertiesTestCase.java 2008-12-18 20:06:56 UTC (rev 24430)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.tools.buildmagic.task;
import java.util.Properties;
@@ -4,35 +26,35 @@
import junit.framework.TestCase;
-public class ResolvePropertiesTestCase extends TestCase {
+public class ResolvePropertiesTestCase extends TestCase
+{
- public void testEvalExpr()
- {
- Properties props = new Properties();
- props.put("atest", "test");
- props.put("test1", "one");
- props.put("test2", "two");
-
- String expression = "This is test ${test1} ${test2} ${test3}";
-
- String evaluatedExpr = ResolveProperties.subst(expression, props, true);
- this.assertEquals("This is test one two ", evaluatedExpr);
-
- evaluatedExpr = ResolveProperties.subst(expression, props, false);
- this.assertEquals("This is test one two ${test3}", evaluatedExpr);
-
- /*evaluatedExpr = ResolveProperties.evalExpr(expression, props, true);
- this.assertEquals("This is test one two ", evaluatedExpr);
-
- evaluatedExpr = ResolveProperties.evalExpr(expression, props, false);
- this.assertEquals("This is test one two ${test3}", evaluatedExpr);*/
-
- String nestedExpr = "This is test ${${atest}1} ${test2} ${test3}";
-
- evaluatedExpr = ResolveProperties.subst(nestedExpr, props, false);
- //this.assertEquals("This is test one two ${test3}", evaluatedExpr);
-
-
- //System.out.println(evaluatedExpr);
- }
+ public void testEvalExpr()
+ {
+ Properties props = new Properties();
+ props.put("atest", "test");
+ props.put("test1", "one");
+ props.put("test2", "two");
+
+ String expression = "This is test ${test1} ${test2} ${test3}";
+
+ String evaluatedExpr = ResolveProperties.subst(expression, props, true);
+ this.assertEquals("This is test one two ", evaluatedExpr);
+
+ evaluatedExpr = ResolveProperties.subst(expression, props, false);
+ this.assertEquals("This is test one two ${test3}", evaluatedExpr);
+
+ /*evaluatedExpr = ResolveProperties.evalExpr(expression, props, true);
+ this.assertEquals("This is test one two ", evaluatedExpr);
+
+ evaluatedExpr = ResolveProperties.evalExpr(expression, props, false);
+ this.assertEquals("This is test one two ${test3}", evaluatedExpr);*/
+
+ String nestedExpr = "This is test ${${atest}1} ${test2} ${test3}";
+
+ evaluatedExpr = ResolveProperties.subst(nestedExpr, props, false);
+ //this.assertEquals("This is test one two ${test3}", evaluatedExpr);
+
+ //System.out.println(evaluatedExpr);
+ }
}
More information about the jboss-svn-commits
mailing list