/*****************************************************************/ /* Copyright 2013 Code Strategies */ /* This code may be freely used and distributed in any project. */ /* However, please do not remove this credit if you publish this */ /* code in paper or electronic form, such as on a web site. */ /*****************************************************************/ package com.cakes.ant; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; public class Variable extends Task { private String name = ""; private String value = ""; public Variable() { super(); } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public void execute() throws BuildException { if ((name == null) || ("".equals(name))) { System.out.println("The variable name is null"); return; } System.out.println("Setting '" + name + "' variable to '" + value + "'"); getProject().setProperty(name, value); } }