1 48 package net.sf.antcontrib.property; 49 50 import org.apache.tools.ant.BuildException; 51 import org.apache.tools.ant.Project; 52 import org.apache.tools.ant.Target; 53 import org.apache.tools.ant.Task; 54 import org.apache.tools.ant.taskdefs.CallTarget; 55 import org.apache.tools.ant.taskdefs.Property; 56 import org.apache.tools.ant.types.FileSet; 57 import java.io.File ; 58 59 94 public class PropertyCopy extends Task 95 { 96 private String name; 97 private String from; 98 private boolean silent; 99 100 103 public PropertyCopy() 104 { 105 super(); 106 this.name = null; 107 this.from = null; 108 this.silent = false; 109 } 110 111 public void setName(String name) 112 { 113 this.name = name; 114 } 115 116 public void setFrom(String from) 117 { 118 this.from = from; 119 } 120 121 public void setSilent(boolean silent) 122 { 123 this.silent = silent; 124 } 125 126 public void execute() 127 throws BuildException 128 { 129 if (name == null) 130 throw new BuildException("Missing the 'name' attribute."); 131 132 if (from == null) 133 throw new BuildException("Missing the 'from' attribute."); 134 135 String value = getProject().getProperty(from); 136 137 138 if (value == null && ! silent) 139 throw new BuildException("Property '" + from + "' is not defined."); 140 141 if (value != null) 142 { 143 if (getProject().getUserProperty(name) == null) 144 getProject().setProperty(name, value); 145 else 146 getProject().setUserProperty(name, value); 147 } 148 } 149 150 } 151 152 153 | Popular Tags |