From d1e64cc7fe5eef61094dbb643096cada4b880f72 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 10 Jan 2017 20:55:45 +0100 Subject: [PATCH] infrastructure for XZ compression support - PR 60350 --- build.xml | 13 ++++ fetch.xml | 6 +- lib/libraries.properties | 1 + release/ivy.xml | 6 ++ src/etc/poms/ant-xz/pom.xml | 70 +++++++++++++++++++ src/etc/poms/ant/pom.xml | 1 + src/etc/poms/pom.xml | 1 + .../tools/ant/taskdefs/defaults.properties | 1 + .../tools/ant/taskdefs/optional/xz/Xz.java | 67 ++++++++++++++++++ 9 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 src/etc/poms/ant-xz/pom.xml create mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/xz/Xz.java diff --git a/build.xml b/build.xml index 43917ea54..a0d4fc317 100644 --- a/build.xml +++ b/build.xml @@ -292,6 +292,12 @@ + + + + + + @@ -318,6 +324,7 @@ + @@ -505,6 +512,9 @@ + @@ -592,6 +602,7 @@ + @@ -764,6 +775,7 @@ + @@ -857,6 +869,7 @@ + diff --git a/fetch.xml b/fetch.xml index 1515fbfef..1610d414e 100644 --- a/fetch.xml +++ b/fetch.xml @@ -334,8 +334,12 @@ Set -Ddest=LOCATION on the command line + + + + + depends="ivy,logging,junit,xml,networking,regexp,antlr,bcel,jdepend,bsf,debugging,script,javamail,jspc,jai,netrexx,xz" /> diff --git a/lib/libraries.properties b/lib/libraries.properties index 4b498a962..21961f31b 100644 --- a/lib/libraries.properties +++ b/lib/libraries.properties @@ -61,6 +61,7 @@ which.version=1.0 xalan.version=2.7.2 xml-resolver.version=1.2 mail.version=1.4 +xz.version=1.6 #paired jacl.version=1.2.6 tcljava.version=${jacl.version} diff --git a/release/ivy.xml b/release/ivy.xml index 1b26cf9be..cdfd7f176 100644 --- a/release/ivy.xml +++ b/release/ivy.xml @@ -158,6 +158,12 @@ + + + + + + diff --git a/src/etc/poms/ant-xz/pom.xml b/src/etc/poms/ant-xz/pom.xml new file mode 100644 index 000000000..4aedaa5f9 --- /dev/null +++ b/src/etc/poms/ant-xz/pom.xml @@ -0,0 +1,70 @@ + + + + + + org.apache.ant + ant-parent + ../pom.xml + 1.10.1-SNAPSHOT + + 4.0.0 + http://ant.apache.org/ + org.apache.ant + ant-xz + 1.10.1-SNAPSHOT + Apache Ant + XZ for Java + contains the xz compression support + + + org.apache.ant + ant + 1.10.1-SNAPSHOT + compile + + + org.tukaani + xz + 1.6 + compile + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org/apache/tools/ant/taskdefs/optional/xz/* + + + + + ../../../../src/main + ../../../../src/testcases + ../../../../target/${project.artifactId}/classes + ../../../../target/${project.artifactId}/testcases + ../../../../target/${project.artifactId} + + diff --git a/src/etc/poms/ant/pom.xml b/src/etc/poms/ant/pom.xml index dd08f8a95..de566c461 100644 --- a/src/etc/poms/ant/pom.xml +++ b/src/etc/poms/ant/pom.xml @@ -122,6 +122,7 @@ org/apache/tools/ant/taskdefs/optional/NetRexxC* org/apache/tools/ant/taskdefs/optional/Xalan2TraceSupport* org/apache/tools/ant/taskdefs/optional/jdepend/* + org/apache/tools/ant/taskdefs/optional/xz/* org/apache/tools/ant/filters/util/JavaClassHelper* diff --git a/src/etc/poms/pom.xml b/src/etc/poms/pom.xml index f5e6acbb1..33b731ed3 100644 --- a/src/etc/poms/pom.xml +++ b/src/etc/poms/pom.xml @@ -102,6 +102,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma ant-netrexx ant-swing ant-testutil + ant-xz diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index 06507a369..69b29b40d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -115,6 +115,7 @@ war=org.apache.tools.ant.taskdefs.War whichresource=org.apache.tools.ant.taskdefs.WhichResource xmlproperty=org.apache.tools.ant.taskdefs.XmlProperty xslt=org.apache.tools.ant.taskdefs.XSLTProcess +xz=org.apache.tools.ant.taskdefs.optional.xz.Xz zip=org.apache.tools.ant.taskdefs.Zip # optional tasks diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/xz/Xz.java b/src/main/org/apache/tools/ant/taskdefs/optional/xz/Xz.java new file mode 100644 index 000000000..d88f91052 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/xz/Xz.java @@ -0,0 +1,67 @@ +/* + * 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. + * + */ + +package org.apache.tools.ant.taskdefs.optional.xz; + +import java.io.BufferedOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.util.FileUtils; +import org.apache.tools.ant.taskdefs.Pack; +import org.tukaani.xz.LZMA2Options; +import org.tukaani.xz.XZOutputStream; + +/** + * Compresses a file with the XZ algorithm. Normally used to compress + * non-compressed archives such as TAR files. + * + * @since Ant 1.10.1 + * + * @ant.task category="packaging" + */ + +public class Xz extends Pack { + /** + * Compress the zipFile. + */ + protected void pack() { + XZOutputStream zOut = null; + try { + zOut = new XZOutputStream(new FileOutputStream(zipFile), + new LZMA2Options()); + zipResource(getSrcResource(), zOut); + } catch (IOException ioe) { + String msg = "Problem creating xz " + ioe.getMessage(); + throw new BuildException(msg, ioe, getLocation()); + } finally { + FileUtils.close(zOut); + } + } + + /** + * Whether this task can deal with non-file resources. + * + *

This implementation always returns true only.

+ * @return true + */ + protected boolean supportsNonFileResources() { + return true; + } +}