mirror of https://github.com/apache/poi.git
Fix Ant javascript issues
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1881914 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8eefca1bfe
commit
fe2b58a9cc
61
build.xml
61
build.xml
|
@ -91,12 +91,16 @@ under the License.
|
||||||
<!-- issue warnings if source code contains unmappable characters for encoding ASCII -->
|
<!-- issue warnings if source code contains unmappable characters for encoding ASCII -->
|
||||||
<property name="java.source.encoding" value="UTF-8"/>
|
<property name="java.source.encoding" value="UTF-8"/>
|
||||||
|
|
||||||
<scriptdef name="propertyreset" language="javascript"
|
<macrodef name="propertyreset">
|
||||||
description="Allows to assign @{property} new value">
|
|
||||||
<attribute name="name"/>
|
<attribute name="name"/>
|
||||||
<attribute name="value"/>
|
<attribute name="value"/>
|
||||||
project.setProperty(attributes.get("name"), attributes.get("value"));
|
<sequential>
|
||||||
</scriptdef>
|
<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,
|
JVM system properties for running tests,
|
||||||
|
@ -547,11 +551,12 @@ under the License.
|
||||||
<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="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}" />
|
<echo message="Building Apache POI version ${version.id} and RC: ${release.rc}" />
|
||||||
|
|
||||||
<scriptdef name="release_tag" language="javascript">
|
<loadresource property="RELEASE_TAG">
|
||||||
var rel = ("REL_"+project.getProperty("version.id")).toUpperCase().replace(/\W/g,"_");
|
<string>REL_${version.id}</string>
|
||||||
project.setProperty("RELEASE_TAG", rel);
|
<filterchain>
|
||||||
</scriptdef>
|
<replaceregex pattern="\W" replace="_" flags="g"/>
|
||||||
<release_tag/>
|
</filterchain>
|
||||||
|
</loadresource>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="clean" description="Remove generated artefacts">
|
<target name="clean" description="Remove generated artefacts">
|
||||||
|
@ -2650,12 +2655,8 @@ under the License.
|
||||||
<format property="tstamp_next" pattern="yyyy-MM" offset="3" unit="month"/>
|
<format property="tstamp_next" pattern="yyyy-MM" offset="3" unit="month"/>
|
||||||
</tstamp>
|
</tstamp>
|
||||||
|
|
||||||
<scriptdef name="getnextrel" language="javascript">
|
<taskdef name="NextRelease" classname="NextRelease" classpath="build/poi-ant-contrib"/>
|
||||||
var relCurr = new String(project.getProperty("version.id"));
|
<NextRelease property="rel_next"/>
|
||||||
var relNext = relCurr.replace(/[0-9]+$/, function(lastNum){ return new String(new Number(lastNum)+1); });
|
|
||||||
project.setProperty("rel_next", relNext);
|
|
||||||
</scriptdef>
|
|
||||||
<getnextrel/>
|
|
||||||
|
|
||||||
<antcall target="-update-build.xml">
|
<antcall target="-update-build.xml">
|
||||||
<param name="version_id" value="${version.id}"/>
|
<param name="version_id" value="${version.id}"/>
|
||||||
|
@ -2778,15 +2779,17 @@ under the License.
|
||||||
</tstamp>
|
</tstamp>
|
||||||
|
|
||||||
|
|
||||||
<scriptdef name="getnextrel" language="javascript">
|
<taskdef name="NextRelease" classname="NextRelease" classpath="build/poi-ant-contrib"/>
|
||||||
var relPrev = new String(project.getProperty("version.id"))
|
<NextRelease property="rel_prev" increment="-1"/>
|
||||||
.replace(/([0-9]+)[^0-9]*$/, function(all,lastNum){ return new String(new Number(lastNum)-1); });
|
|
||||||
project.setProperty("rel_prev", relPrev);
|
<!-- we don't simply generate a new iso file date with tstamp,
|
||||||
var fileDateIso = new String(project.getProperty("file_date"))
|
but potentially use the date given as an argument to ant -->
|
||||||
.replace(/([0-9]{4})([0-9]{2})([0-9]{2})/, "$1-$2-$3");
|
<loadresource property="file_date_iso">
|
||||||
project.setProperty("file_date_iso", fileDateIso);
|
<string>${file_date}</string>
|
||||||
</scriptdef>
|
<filterchain>
|
||||||
<getnextrel/>
|
<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="( +version += +)'[^']+'" replace="\1'${version.id}'"/>
|
||||||
<replaceregexp file="build.gradle" match="(japicmpversion += +)'[^']+'" replace="\1'${rel_prev}'"/>
|
<replaceregexp file="build.gradle" match="(japicmpversion += +)'[^']+'" replace="\1'${rel_prev}'"/>
|
||||||
|
@ -2853,15 +2856,6 @@ under the License.
|
||||||
</sequential>
|
</sequential>
|
||||||
</macrodef>
|
</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">
|
<macrodef name="download-line">
|
||||||
<attribute name="prop"/>
|
<attribute name="prop"/>
|
||||||
<attribute name="dist"/>
|
<attribute name="dist"/>
|
||||||
|
@ -2887,6 +2881,7 @@ under the License.
|
||||||
</filterchain>
|
</filterchain>
|
||||||
</loadfile>
|
</loadfile>
|
||||||
|
|
||||||
|
<taskdef name="bytes2mega" classname="Bytes2Mega" classpath="build/poi-ant-contrib"/>
|
||||||
<local name="fileSizeMb"/>
|
<local name="fileSizeMb"/>
|
||||||
<bytes2mega property="fileSizeMb" bytes="${fileSize}"/>
|
<bytes2mega property="fileSizeMb" bytes="${fileSize}"/>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/* ====================================================================
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/* ====================================================================
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/* ====================================================================
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue