From: Andreas Beeker Date: Tue, 22 Sep 2020 00:07:32 +0000 (+0000) Subject: Fix Ant javascript issues X-Git-Tag: before_ooxml_3rd_edition~111 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fe2b58a9ccd1f615b9d7ce402dd4fd9a2563de07;p=poi.git Fix Ant javascript issues git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1881914 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/build.xml b/build.xml index 1cf5568a48..b53686e1b9 100644 --- a/build.xml +++ b/build.xml @@ -91,12 +91,16 @@ under the License. - + - project.setProperty(attributes.get("name"), attributes.get("value")); - + + + + + + + + + ${file_date} + + + + @@ -2853,15 +2856,6 @@ under the License. - - - - var bytes = Number(attributes.get("bytes")); - var mega = String((bytes/(1024.0*1024.0)).toFixed(2)); - project.setProperty(attributes.get("property"), mega); - - @@ -2887,6 +2881,7 @@ under the License. + diff --git a/src/excelant/poi-ant-contrib/Bytes2Mega.java b/src/excelant/poi-ant-contrib/Bytes2Mega.java new file mode 100644 index 0000000000..3bdafe18f5 --- /dev/null +++ b/src/excelant/poi-ant-contrib/Bytes2Mega.java @@ -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)); + } +} diff --git a/src/excelant/poi-ant-contrib/NextRelease.java b/src/excelant/poi-ant-contrib/NextRelease.java new file mode 100644 index 0000000000..bd21b0e6cb --- /dev/null +++ b/src/excelant/poi-ant-contrib/NextRelease.java @@ -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)); + } +} diff --git a/src/excelant/poi-ant-contrib/PropertyReset.java b/src/excelant/poi-ant-contrib/PropertyReset.java new file mode 100644 index 0000000000..4f569e67fd --- /dev/null +++ b/src/excelant/poi-ant-contrib/PropertyReset.java @@ -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); + } + } +} \ No newline at end of file