aboutsummaryrefslogtreecommitdiffstats
path: root/excelant/src/poi-ant-contrib
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2021-03-27 14:03:16 +0000
committerAndreas Beeker <kiwiwings@apache.org>2021-03-27 14:03:16 +0000
commit37791e4bdfc706aa5684745594260f243b4be7ee (patch)
treea8dd8d0976fc478074d52cd3de79e0e6b5e6a33a /excelant/src/poi-ant-contrib
parent2bb3839bfe3e3bacff79f8157465633e311239ce (diff)
downloadpoi-37791e4bdfc706aa5684745594260f243b4be7ee.tar.gz
poi-37791e4bdfc706aa5684745594260f243b4be7ee.zip
65206 - Migrate ant / maven to gradle build
update gradle files and project structure along https://github.com/centic9/poi/tree/gradle_build remove eclipse IDE project files remove obsolete record generator files git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1888111 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'excelant/src/poi-ant-contrib')
-rw-r--r--excelant/src/poi-ant-contrib/java/Bytes2Mega.java42
-rw-r--r--excelant/src/poi-ant-contrib/java/Junit5Progress.java99
-rw-r--r--excelant/src/poi-ant-contrib/java/NextRelease.java46
-rw-r--r--excelant/src/poi-ant-contrib/java/PropertyReset.java41
4 files changed, 228 insertions, 0 deletions
diff --git a/excelant/src/poi-ant-contrib/java/Bytes2Mega.java b/excelant/src/poi-ant-contrib/java/Bytes2Mega.java
new file mode 100644
index 0000000000..3bdafe18f5
--- /dev/null
+++ b/excelant/src/poi-ant-contrib/java/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/excelant/src/poi-ant-contrib/java/Junit5Progress.java b/excelant/src/poi-ant-contrib/java/Junit5Progress.java
new file mode 100644
index 0000000000..8e87ef064f
--- /dev/null
+++ b/excelant/src/poi-ant-contrib/java/Junit5Progress.java
@@ -0,0 +1,99 @@
+/* ====================================================================
+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.io.PrintStream;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.junit.platform.engine.TestExecutionResult;
+import org.junit.platform.launcher.TestExecutionListener;
+import org.junit.platform.launcher.TestIdentifier;
+
+/**
+ * Custom listener class for Ants junitlauncher, because it chomps the important running details
+ *
+ * @see <a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=64836">Bug 64836 - junitlaucher poor summary</a>
+ **/
+public class Junit5Progress implements TestExecutionListener {
+ private final AtomicInteger numSkippedInTestSet = new AtomicInteger();
+ private final AtomicInteger numAbortedInTestSet = new AtomicInteger();
+ private final AtomicInteger numSucceededInTestSet = new AtomicInteger();
+ private final AtomicInteger numFailedInTestSet = new AtomicInteger();
+ private Instant testSetStartTime;
+
+ final PrintStream out;
+
+ public Junit5Progress() {
+ this.out = System.out;
+ }
+
+ private void resetCountsForNewTestSet() {
+ this.numSkippedInTestSet.set(0);
+ this.numAbortedInTestSet.set(0);
+ this.numSucceededInTestSet.set(0);
+ this.numFailedInTestSet.set(0);
+ this.testSetStartTime = Instant.now();
+ }
+
+ @Override
+ public void executionStarted(TestIdentifier testIdentifier) {
+ Optional<String> parentId = testIdentifier.getParentId();
+ if (parentId.isPresent() && parentId.get().indexOf('/') < 0) {
+ println("\nRunning " + testIdentifier.getLegacyReportingName());
+ resetCountsForNewTestSet();
+ }
+ }
+
+ @Override
+ public void executionSkipped(TestIdentifier testIdentifier, String reason) {
+ this.numSkippedInTestSet.incrementAndGet();
+ }
+
+ @Override
+ public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
+ Optional<String> parentId = testIdentifier.getParentId();
+ if (parentId.isPresent() && parentId.get().indexOf('/') < 0) {
+ int totalTestsInClass = this.numSucceededInTestSet.get() + this.numAbortedInTestSet.get() + this.numFailedInTestSet.get()
+ + this.numSkippedInTestSet.get();
+ Duration duration = Duration.between(this.testSetStartTime, Instant.now());
+ double numSeconds = (double) duration.toMillis() / 1_000;
+ String summary = String.format("Tests run: %d, Failures: %d, Aborted: %d, Skipped: %d, Time elapsed: %f sec", totalTestsInClass,
+ this.numFailedInTestSet.get(), this.numAbortedInTestSet.get(), this.numSkippedInTestSet.get(), numSeconds);
+ println(summary);
+ } else if (testIdentifier.isTest()) {
+ switch (testExecutionResult.getStatus()) {
+ case SUCCESSFUL:
+ this.numSucceededInTestSet.incrementAndGet();
+ break;
+ case ABORTED:
+ println(" Aborted: " + testIdentifier.getDisplayName());
+ this.numAbortedInTestSet.incrementAndGet();
+ break;
+ case FAILED:
+ println(" Failed: " + testIdentifier.getDisplayName());
+ this.numFailedInTestSet.incrementAndGet();
+ break;
+ }
+ }
+ }
+
+ private void println(String str) {
+ this.out.println(str);
+ }
+} \ No newline at end of file
diff --git a/excelant/src/poi-ant-contrib/java/NextRelease.java b/excelant/src/poi-ant-contrib/java/NextRelease.java
new file mode 100644
index 0000000000..c0b6b3d864
--- /dev/null
+++ b/excelant/src/poi-ant-contrib/java/NextRelease.java
@@ -0,0 +1,46 @@
+/* ====================================================================
+ 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;
+
+@SuppressWarnings("unused")
+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 setIncrement(int increment) {
+ this.increment = increment;
+ }
+
+ public void execute() {
+ Project project = getProject();
+ String relCurr = project.getProperty("version.id");
+ Matcher m = pattern.matcher(relCurr);
+ if (m.find()) {
+ project.setProperty(property, m.group(1) + "." + m.group(2) + "." + (Integer.parseInt(m.group(3)) + increment));
+ }
+ }
+}
diff --git a/excelant/src/poi-ant-contrib/java/PropertyReset.java b/excelant/src/poi-ant-contrib/java/PropertyReset.java
new file mode 100644
index 0000000000..4f569e67fd
--- /dev/null
+++ b/excelant/src/poi-ant-contrib/java/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