<!-- issue warnings if source code contains unmappable characters for encoding ASCII -->
<property name="java.source.encoding" value="UTF-8"/>
- <scriptdef name="propertyreset" language="javascript"
- description="Allows to assign @{property} new value">
+ <macrodef name="propertyreset">
<attribute name="name"/>
<attribute name="value"/>
- project.setProperty(attributes.get("name"), attributes.get("value"));
- </scriptdef>
+ <sequential>
+ <mkdir dir="build/poi-ant-contrib"/>
+ <javac srcdir="src/excelant/poi-ant-contrib" destdir="build/poi-ant-contrib" includeantruntime="true"/>
+ <taskdef name="PropertyResetHelper" classname="PropertyReset" classpath="build/poi-ant-contrib"/>
+ <PropertyResetHelper name="@{name}" value="@{value}" />
+ </sequential>
+ </macrodef>
<!--
JVM system properties for running tests,
<echo message="Using Java: ${java.version}/${java.runtime.version}/${java.vm.version}/${java.vm.name} from ${java.vm.vendor} on ${os.name}: ${os.version}" />
<echo message="Building Apache POI version ${version.id} and RC: ${release.rc}" />
- <scriptdef name="release_tag" language="javascript">
- var rel = ("REL_"+project.getProperty("version.id")).toUpperCase().replace(/\W/g,"_");
- project.setProperty("RELEASE_TAG", rel);
- </scriptdef>
- <release_tag/>
+ <loadresource property="RELEASE_TAG">
+ <string>REL_${version.id}</string>
+ <filterchain>
+ <replaceregex pattern="\W" replace="_" flags="g"/>
+ </filterchain>
+ </loadresource>
</target>
<target name="clean" description="Remove generated artefacts">
<format property="tstamp_next" pattern="yyyy-MM" offset="3" unit="month"/>
</tstamp>
- <scriptdef name="getnextrel" language="javascript">
- var relCurr = new String(project.getProperty("version.id"));
- var relNext = relCurr.replace(/[0-9]+$/, function(lastNum){ return new String(new Number(lastNum)+1); });
- project.setProperty("rel_next", relNext);
- </scriptdef>
- <getnextrel/>
+ <taskdef name="NextRelease" classname="NextRelease" classpath="build/poi-ant-contrib"/>
+ <NextRelease property="rel_next"/>
<antcall target="-update-build.xml">
<param name="version_id" value="${version.id}"/>
</tstamp>
- <scriptdef name="getnextrel" language="javascript">
- var relPrev = new String(project.getProperty("version.id"))
- .replace(/([0-9]+)[^0-9]*$/, function(all,lastNum){ return new String(new Number(lastNum)-1); });
- project.setProperty("rel_prev", relPrev);
- var fileDateIso = new String(project.getProperty("file_date"))
- .replace(/([0-9]{4})([0-9]{2})([0-9]{2})/, "$1-$2-$3");
- project.setProperty("file_date_iso", fileDateIso);
- </scriptdef>
- <getnextrel/>
+ <taskdef name="NextRelease" classname="NextRelease" classpath="build/poi-ant-contrib"/>
+ <NextRelease property="rel_prev" increment="-1"/>
+
+ <!-- we don't simply generate a new iso file date with tstamp,
+ but potentially use the date given as an argument to ant -->
+ <loadresource property="file_date_iso">
+ <string>${file_date}</string>
+ <filterchain>
+ <replaceregex pattern="([0-9]{4})([0-9]{2})([0-9]{2})" replace="\1-\2-\3"/>
+ </filterchain>
+ </loadresource>
<replaceregexp file="build.gradle" match="( +version += +)'[^']+'" replace="\1'${version.id}'"/>
<replaceregexp file="build.gradle" match="(japicmpversion += +)'[^']+'" replace="\1'${rel_prev}'"/>
</sequential>
</macrodef>
- <scriptdef name="bytes2mega" language="javascript"
- description="Convert size in bytes to megabytes">
- <attribute name="property"/>
- <attribute name="bytes"/>
- var bytes = Number(attributes.get("bytes"));
- var mega = String((bytes/(1024.0*1024.0)).toFixed(2));
- project.setProperty(attributes.get("property"), mega);
- </scriptdef>
-
<macrodef name="download-line">
<attribute name="prop"/>
<attribute name="dist"/>
</filterchain>
</loadfile>
+ <taskdef name="bytes2mega" classname="Bytes2Mega" classpath="build/poi-ant-contrib"/>
<local name="fileSizeMb"/>
<bytes2mega property="fileSizeMb" bytes="${fileSize}"/>
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+public class Bytes2Mega extends Task {
+ private final NumberFormat formatter = new DecimalFormat("#0.00");
+ private String property;
+ private int bytes;
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ public void setBytes(int bytes) {
+ this.bytes = bytes;
+ }
+
+ public void execute() {
+ Project project = getProject();
+ double mega = bytes/(1024.*1024.);
+ project.setProperty(property, formatter.format(mega));
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+public class NextRelease extends Task {
+ private final Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+).*");
+ private String property;
+ private int increment = 1;
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ public void increment(int increment) {
+ this.increment = increment;
+ }
+
+ public void execute() {
+ Project project = getProject();
+ String relCurr = project.getProperty("version.id");
+ Matcher m = pattern.matcher(relCurr);
+ m.find();
+ project.setProperty(property, m.group(1)+"."+m.group(2)+"."+(Integer.parseInt(m.group(3))+increment));
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+public class PropertyReset extends Task {
+ private String name;
+ private String value;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public void execute() {
+ Project project = getProject();
+ if (project.getUserProperty(name) != null) {
+ project.setUserProperty(name, value);
+ } else {
+ project.setProperty(name, value);
+ }
+ }
+}
\ No newline at end of file