Merge branch '1.9.x'
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 79f94be..3f45cf2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -23,11 +23,24 @@
first. This way you can make sure you're not wasting your time on
something that isn't considered to be in Ant's scope.
+Branches
+--------
+
+The master branch is where we develop the next release of Ant 1.10.x -
+any patch or PR against this branch must be buildable using Java8.
+
+The branch 1.9.x is where we develop the next release of Ant 1.9.x -
+any patch or PR against this branch must be buildable using Java5.
+
+Please state clearly whether you are targeting 1.9.x or 1.10.x -
+usually we port changes from 1.9.x to 1.10.x but not necessarily the
+other way around.
+
Making Changes
--------------
+ Create a topic branch from where you want to base your work (this is
- usually the master branch).
+ usually the master or the 1.9.x branch, see above).
+ Make commits of logical units.
+ Respect the original code style:
+ Only use spaces for indentation.
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 17022c7..6481253 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -283,6 +283,7 @@
Nigel Magnay
Oliver Merkel
Oliver Rossmueller
+Olivier Parent
Ondra Medek
Omer Shapira
Oystein Gisnas
diff --git a/ReleaseInstructions b/ReleaseInstructions
index 27d4c41..7a752fc 100644
--- a/ReleaseInstructions
+++ b/ReleaseInstructions
@@ -5,8 +5,9 @@
Magesh Umasankar
Antoine Levy-Lambert
-Note: This document was updated in the context of releasing Ant
- 1.9.7 which was the first release cut from the 1.9.x branch.
+Note: This document was adapted from the one created in the context of
+ releasing Ant 1.9.7. It assumes the first release created from
+ master will be 1.10.
Please interpret the branch names, tags, etc. according to
your context.
@@ -31,7 +32,7 @@
2. Ensure you have all the external libraries that Ant uses in your
lib/optional directory. All dependencies are either provided by
- JDK 1.5.0 or downloadable using
+ JDK 1.8.0 or downloadable using
ant -f fetch.xml -Ddest=optional
To find out whether you have all the libraries you need, execute
the build with -verbose option and scan for lines beginning with
@@ -40,9 +41,9 @@
3. We don't want tags for failed votes to end up on out branches so
the release is first created from a detached head.
- Checkout the HEAD of the 1.9.x branch as a detached head:
+ Checkout the HEAD of the master branch as a detached head:
- $ git checkout 1.9.x^0
+ $ git checkout master^0
4. Make sure that your directory tree is clean by running git status.
Some tests leave behind leftovers which end up in the source
@@ -57,7 +58,7 @@
* POM files under src/etc/poms and subdirectories
if you've got mvn installed
- $ mvn versions:set -DnewVersion=1.9.7 -DgenerateBackupPoms=false
+ $ mvn versions:set -DnewVersion=1.10.0 -DgenerateBackupPoms=false
inside src/etc/poms should do the trick.
@@ -82,11 +83,11 @@
$ ./dist/bin/ant -nouserlib -lib lib/optional distribution
build.xml specifies that the code should be compiled with
- source=1.5 and target=1.5.
+ source=1.8 and target=1.8.
8. Commit your changes, tag them, push them.
- $ git tag -s -m "Tagging RC1 for version 1.9.7 of Ant" ANT_197_RC1
+ $ git tag -s -m "Tagging RC1 for version 1.10.0 of Ant" ANT_1.10.0_RC1
$ git push --tags
9. Ensure that the GPG key you use is inside the KEYS file in Ant's
@@ -144,12 +145,12 @@
This target generates a file build/html/WHATSNEW.html
Add an html head element with a title like "Release Notes of Apache Ant
- 1.9.7" (from the default txt2html)
+ 1.10.0" (from the default txt2html)
Cut all sections about previous releases to keep only the current release,
- and save as RELEASE-NOTES-1.9.7.html inside the distribution folder.
+ and save as RELEASE-NOTES-1.10.0.html inside the distribution folder.
- Copy the contents of RELEASE-NOTES-1.9.7.html also into README.html
+ Copy the contents of RELEASE-NOTES-1.10.0.html also into README.html
12. The distribution is now ready to go.
Create a SVN sandbox on your computer with https://dist.apache.org/repos/dist/dev/ant in it
@@ -193,7 +194,7 @@
16. Once the vote has passed, tag the last RC created with the final tag
- $ git tag -s -m "Tagging version 1.9.7 of Ant" rel/1.9.7 HASH_OF_LAST_RC
+ $ git tag -s -m "Tagging version 1.10.0 of Ant" rel/1.10.0 HASH_OF_LAST_RC
$ git push --tags
17. The distrib artifacts should be published the apache dist. It is
@@ -221,36 +222,40 @@
https://reporter.apache.org/addrelease.html?ant
19. Address the available version tags in BugZilla. Create new
- milestone 1.9.8 and version 1.9.7.
+ milestone 1.10.1 and version 1.10.0.
20. Add a new release tag to doap_Ant.rdf in Ant's site.
-21. checkout the 1.9.x branch, merge the tag but don't push the
+21. checkout the master branch, merge the tag but don't push the
commit
- $ git checkout 1.9.x
- $ git merge rel/1.9.7
+ [if a release of Ant 1.9.x happened at the same time, deal with
+ the 1.9.x tag on the 1.9.x branch first and merge the 1.9.x branch
+ to master before proceeding here]
+
+ $ git checkout master
+ $ git merge rel/1.10.0
Set the version number in several files to the required version of
- the next 1.9.x release. These are:
+ the next 1.10.x release. These are:
* manual/cover.html
* manual/credits.html
* build.xml properties : project.version,manifest-version,pom.version
project.version property in build.xml gets bumped to
- [newversion]alpha, for example 1.9.8alpha
+ [newversion]alpha, for example 1.10.1alpha
manifest-version gets bumped to the exact next release number
- for example 1.9.8.
+ for example 1.10.1.
pom.version gets bumped to [newversion]-SNAPSHOT
- for example 1.9.8-SNAPSHOT.
+ for example 1.10.1-SNAPSHOT.
* POM files under src/etc/poms and subdirectories
if you've got mvn installed
- $ mvn versions:set -DnewVersion=1.9.8-SNAPSHOT -DgenerateBackupPoms=false
+ $ mvn versions:set -DnewVersion=1.10.1-SNAPSHOT -DgenerateBackupPoms=false
inside src/etc/poms should do the trick.
@@ -264,15 +269,9 @@
$ git commit -a --amend
$ git push
-22. checkout the master branch, merge the 1.9.x branch
+22. wait a few hours for the mirrors to catch up
- $ git checkout master
- $ git merge 1.9.x
- $ git push
-
-23. wait a few hours for the mirrors to catch up
-
-24. Update the ant.apache.org site :
+23. Update the ant.apache.org site :
The website is managed here: https://svn.apache.org/repos/asf/ant/site/ant/
@@ -280,6 +279,10 @@
the site still uses svn and Ant proper uses git there currently is
no way to use the scm for this.
+ [TODO once there is the first release of 1.10.0, we'll likely need
+ to restructure the site to allow two versions of the manual to
+ exist in parallel]
+
Update the following files for version number:
* source/antnews.xml (Announcement)
@@ -294,17 +297,20 @@
Commit the modified/generated files in the 'production' folder, it will go
live on ant.apache.org in a matter on seconds.
-25. At this point in time, the release is done and announcements are made.
+24. At this point in time, the release is done and announcements are made.
PGP-sign your announcement posts.
Apache mailing lists that should get the announcements:
announce@apache.org, dev@ant and user@ant.
-26. You can now reacquaint yourself with your family and friends.
+25. You can now reacquaint yourself with your family and friends.
-27. After a few days "svn rm" the older release artifacts and release
+26. After a few days "svn rm" the older release artifacts and release
notes from https://dist.apache.org/repos/dist/release/ant/
+ "older" here means any older 1.10.x release but not the latest
+ 1.9.x release.
+
Related Information
http://www.apache.org/dev/#releases
diff --git a/STATUS b/STATUS
index 874396d..67ba9d8 100644
--- a/STATUS
+++ b/STATUS
@@ -1,10 +1,10 @@
Apache Ant Status
-Last modified at 2016-02-24
+Last modified at 2016-04-09
Release:
- Current: 1.9.6 (in GIT Tag: ANT_196)
- Maintenance: 1.9.x (in GIT Branch: master)
- Development: 1.9.7 (in GIT Branch: master)
+ Current: 1.9.6 (in GIT Tag: rel/1.9.6)
+ Maintenance: 1.9.x (in GIT Branch: 1.9.x)
+ Development: 1.10.x (in GIT Branch: master)
Assets:
DNS: ant.apache.org
diff --git a/WHATSNEW b/WHATSNEW
index ae2cb15..86504f2 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -1,5 +1,5 @@
-Changes from Ant 1.9.9 TO Ant 1.9.10
-====================================
+Changes from Ant 1.10.1 TO Ant 1.10.2
+=====================================
Other changes:
--------------
@@ -8,6 +8,10 @@
values always get quoted.
Github Pull Request #32
+ * Added <encoding> attributes to various script related tasks and a
+ compiled attribute to scriptdef.
+ Github Pull Request #30
+
Fixed bugs:
-----------
@@ -15,13 +19,13 @@
value.
Bugzilla Report 60767
-Changes from Ant 1.9.8 TO Ant 1.9.9
-===================================
+Changes from Ant 1.10.0 TO Ant 1.10.1
+=====================================
Fixed bugs:
-----------
- * Ant 1.9.8 made Path#systemClasspath final which broke the Eclipse
+ * Ant 1.10.0 made Path#systemClasspath final which broke the Eclipse
integration.
Bugzilla Report 60582
@@ -31,17 +35,36 @@
newlines present in command line arguments.
Bugzilla Report 60562
-Changes from Ant 1.9.7 TO Ant 1.9.8
-===================================
+Other changes:
+--------------
+
+ * new tasks <xz> and <unxz> and resource <xzresource> for XZ
+ compression. Also the compression attribute of <tar>/<untar> now
+ accepts "xz" as valid value.
+ The tasks and type are contained in the new ant-xz.jar and require
+ the library XZ for Java to be on the CLASSPATH.
+ Bugzilla Report 60350
+
+Changes from Ant 1.9.7 TO Ant 1.10.0
+====================================
Changes that could break older environments:
-------------------------------------------
+ * Ant 1.10.x requires Java8 or newer at compile or build time.
+ The 1.9.x series wil stay compatible with Java5.
+
+ * The <apt> task has been removed since apt itself has been removed
+ with Java8.
+
* <fileset>/<zipfileset>/<tarfileset> exhibited undefined
behavior when both the dir and file attribute have been used on the
same instance. This will now cause the build to fail.
Bugzilla Report 59402
+ * <native2ascii> will default to the builtin implementation on Java8
+ as well (sun isn't available for Java9+ anyway).
+
* The ant.java.version property will now hold the value "9" rather
than "1.9" if running on Java 9.
@@ -49,6 +72,9 @@
be used when running on Java 9 since this option has been removed.
Bugzilla Report 59906
+ * <javah> will default to the "forking" implementation on Java8
+ as well.
+
Fixed bugs:
-----------
@@ -96,6 +122,11 @@
Other changes:
--------------
+ * New file selectors <executable>, <symlink> and <ownedBy>.
+
+ * New task <setpermissions> that provides the ability to set POSIX
+ compatible permssions via NIO's PosixFilePermission
+
* <junit> now initializes the cause of the AssertionFailedError when
converting from AssertionError.
Bugzilla Report 58982
@@ -133,6 +164,9 @@
* it is now possible to use references to Ant types and classloaders
built around Ant <path>s as values for TraX factory attributes.
+ * AntClassLoader and its subclasses register themselves as parallel
+ capable.
+
* <junitreport> now enables the feature
http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions
when run on Java 9 so the redirect extension function can be used
diff --git a/build.xml b/build.xml
index d20cdd3..a576e10 100644
--- a/build.xml
+++ b/build.xml
@@ -34,10 +34,10 @@
<property name="name" value="ant"/>
<!-- this is the groupId of ant in the Maven repository -->
<property name="groupid" value="org/apache/ant"/>
- <property name="project.version" value="1.9.10alpha"/>
+ <property name="project.version" value="1.10.2alpha"/>
<!-- pom.version is used when doing a distribution and must match with what is checked in under src/etc/poms -->
- <property name="pom.version" value="1.9.10-SNAPSHOT"/>
- <property name="manifest-version" value="1.9.10"/>
+ <property name="pom.version" value="1.10.2-SNAPSHOT"/>
+ <property name="manifest-version" value="1.10.2"/>
<property name="bootstrap.jar" value="ant-bootstrap.jar"/>
<property name="ant.package" value="org/apache/tools/ant"/>
@@ -100,12 +100,11 @@
===================================================================
-->
<property name="debug" value="true"/>
- <property name="chmod.fail" value="true"/>
- <property name="chmod.maxparallel" value="250"/>
+ <property name="setpermissions.fail" value="true"/>
<property name="deprecation" value="false"/>
<property name="optimize" value="true"/>
- <property name="javac.target" value="1.5"/>
- <property name="javac.source" value="1.5"/>
+ <property name="javac.target" value="1.8"/>
+ <property name="javac.source" value="1.8"/>
<property name="junit.filtertrace" value="off"/>
<property name="junit.summary" value="no"/>
<property name="test.haltonfailure" value="false"/>
@@ -122,7 +121,6 @@
<property name="junit.collector.dir" value="${build.dir}/failingTests"/>
<property name="junit.collector.class" value="FailedTests"/>
-
<!--
===================================================================
Set the paths used in the build
@@ -294,6 +292,13 @@
<filename name="${optional.package}/Xalan2TraceSupport*"/>
</selector>
+ <selector id="needs.xz">
+ <or>
+ <filename name="${optional.package}/xz/"/>
+ <filename name="${type.package}/optional/xz/"/>
+ </or>
+ </selector>
+
<selector id="ant.launcher">
<filename name="${ant.package}/launch/"/>
</selector>
@@ -320,6 +325,7 @@
<selector refid="needs.junit4"/>
<selector refid="needs.netrexx"/>
<selector refid="needs.swing"/>
+ <selector refid="needs.xz"/>
<selector refid="ant.launcher"/>
</or>
</not>
@@ -375,9 +381,6 @@
</not>
</condition>
<property name="ignoresystemclasses" value="false"/>
- <available property="jdk1.6+" classname="java.net.CookieStore"/>
- <available property="jdk1.7+" classname="java.nio.file.FileSystem"/>
- <available property="jdk1.8+" classname="java.lang.reflect.Executable"/>
<available property="jdk9+" classname="java.lang.module.ModuleDescriptor"/>
<available property="kaffe" classname="kaffe.util.NotImplemented"/>
<available property="harmony"
@@ -510,6 +513,9 @@
<available property="jsch.present"
classname="com.jcraft.jsch.Session"
classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
+ <available property="xz.present"
+ classname="org.tukaani.xz.XZOutputStream"
+ classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
<property name="build.compiler" value="modern"/>
@@ -531,10 +537,7 @@
property="javadoc.doclint.none"
value="-Xdoclint:none"
else="">
- <and>
- <isset property="jdk1.8+"/>
- <not><isset property="withDoclint"/></not>
- </and>
+ <not><isset property="withDoclint"/></not>
</condition>
</target>
@@ -600,6 +603,7 @@
<selector refid="needs.jdepend" unless="jdepend.present"/>
<selector refid="needs.swing" unless="swing.present"/>
<selector refid="needs.jsch" unless="jsch.present"/>
+ <selector refid="needs.xz" unless="xz.present"/>
<selector refid="needs.xmlschema" unless="xmlschema.present"/>
<selector refid="needs.apache-xalan2"
unless="recent.xalan2.present"/>
@@ -772,6 +776,7 @@
<optional-jar dep="jsch"/>
<optional-jar dep="jdepend"/>
<optional-jar dep="apache-xalan2"/>
+ <optional-jar dep="xz"/>
</target>
@@ -865,6 +870,7 @@
<optional-src-jar dep="jsch"/>
<optional-src-jar dep="jdepend"/>
<optional-src-jar dep="apache-xalan2"/>
+ <optional-src-jar dep="xz"/>
</target>
@@ -918,18 +924,20 @@
<include name="*.pl"/>
</fixcrlf>
- <chmod perm="ugo+rx" dir="${dist.dir}" type="dir" includes="**"
- failonerror="${chmod.fail}"/>
- <chmod perm="ugo+r" dir="${dist.dir}" type="file" includes="**"
- failonerror="${chmod.fail}" maxparallel="${chmod.maxparallel}"/>
- <chmod perm="ugo+x" type="file" failonerror="${chmod.fail}">
+ <setpermissions mode="755" failonerror="${setpermissions.fail}">
+ <dirset dir="${dist.dir}"/>
+ </setpermissions>
+ <setpermissions mode="644" failonerror="${setpermissions.fail}">
+ <fileset dir="${dist.dir}"/>
+ </setpermissions>
+ <setpermissions mode="755" failonerror="${setpermissions.fail}">
<fileset dir="${dist.bin}">
<include name="**/ant"/>
<include name="**/antRun"/>
<include name="**/*.pl"/>
<include name="**/*.py"/>
</fileset>
- </chmod>
+ </setpermissions>
</target>
@@ -1030,18 +1038,20 @@
</fileset>
</copy>
- <chmod perm="ugo+rx" dir="${dist.dir}" type="dir" includes="**"
- failonerror="${chmod.fail}"/>
- <chmod perm="ugo+r" dir="${dist.dir}" type="file" includes="**"
- failonerror="${chmod.fail}" maxparallel="${chmod.maxparallel}"/>
- <chmod perm="ugo+x" type="file" failonerror="${chmod.fail}">
+ <setpermissions mode="755" failonerror="${setpermissions.fail}">
+ <dirset dir="${dist.dir}"/>
+ </setpermissions>
+ <setpermissions mode="644" failonerror="${setpermissions.fail}">
+ <fileset dir="${dist.dir}"/>
+ </setpermissions>
+ <setpermissions mode="755" failonerror="${setpermissions.fail}">
<fileset dir="${dist.bin}">
<include name="**/ant"/>
<include name="**/antRun"/>
<include name="**/*.pl"/>
<include name="**/*.py"/>
</fileset>
- </chmod>
+ </setpermissions>
<!-- publish some useful stylesheets -->
<copy todir="${dist.etc}">
@@ -1148,18 +1158,21 @@
<exclude name="${tests.etc.dir}/taskdefs/fixcrlf/input/Junk?.java"/>
</fixcrlf>
- <chmod perm="ugo+x" dir="${src.dist.dir}" type="dir"
- failonerror="${chmod.fail}"/>
- <chmod perm="ugo+r" dir="${src.dist.dir}" failonerror="${chmod.fail}"/>
- <chmod perm="ugo+x" failonerror="${chmod.fail}">
+ <setpermissions mode="755" failonerror="${setpermissions.fail}">
+ <dirset dir="${src.dist.dir}"/>
+ </setpermissions>
+ <setpermissions mode="644" failonerror="${setpermissions.fail}">
+ <fileset dir="${src.dist.dir}"/>
+ </setpermissions>
+ <setpermissions mode="755" failonerror="${setpermissions.fail}">
<fileset dir="${src.dist.dir}">
- <include name="**/.sh"/>
- <include name="**/.pl"/>
- <include name="**/.py"/>
+ <include name="**/*.sh"/>
+ <include name="**/*.pl"/>
+ <include name="**/*.py"/>
<include name="**/ant"/>
<include name="**/antRun"/>
</fileset>
- </chmod>
+ </setpermissions>
</target>
@@ -1242,6 +1255,8 @@
src="${dist.base.binaries}/${dist.name}-bin.tar"/>
<bzip2 destfile="${dist.base.binaries}/${dist.name}-bin.tar.bz2"
src="${dist.base.binaries}/${dist.name}-bin.tar"/>
+ <xz destfile="${dist.base.binaries}/${dist.name}-bin.tar.xz"
+ src="${dist.base.binaries}/${dist.name}-bin.tar"/>
<delete file="${dist.base.binaries}/${dist.name}-bin.tar"/>
</target>
@@ -1295,6 +1310,8 @@
src="${dist.base.manual}/${dist.name}-manual.tar"/>
<bzip2 destfile="${dist.base.manual}/${dist.name}-manual.tar.bz2"
src="${dist.base.manual}/${dist.name}-manual.tar"/>
+ <xz destfile="${dist.base.manual}/${dist.name}-manual.tar.xz"
+ src="${dist.base.manual}/${dist.name}-manual.tar"/>
<delete file="${dist.base.manual}/${dist.name}-manual.tar"/>
<delete dir="${dist.name}"/>
@@ -1346,6 +1363,8 @@
src="${dist.base.source}/${dist.name}-src.tar"/>
<bzip2 destfile="${dist.base.source}/${dist.name}-src.tar.bz2"
src="${dist.base.source}/${dist.name}-src.tar"/>
+ <xz destfile="${dist.base.source}/${dist.name}-src.tar.xz"
+ src="${dist.base.source}/${dist.name}-src.tar"/>
<delete file="${dist.base.source}/${dist.name}-src.tar"/>
<delete dir="${dist.name}"/>
<checksums>
diff --git a/check.xml b/check.xml
index 5509522..92d0346 100644
--- a/check.xml
+++ b/check.xml
@@ -15,7 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project default="checkstyle" name="CheckAnt" xmlns:ivy="antlib:org.apache.ivy.ant">
+<project default="checkstyle" name="CheckAnt" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:if="ant:if" xmlns:unless="ant:unless">
<description>
Check Ants codebase against certain code styleguide rules using
@@ -34,35 +34,48 @@
</description>
<import file="build.xml"/>
+
<property name="config.dir" location="${etc.dir}/checkstyle"/>
- <property name="checkstyle.reportdir" location="${build.dir}/reports/checkstyle"/>
- <property name="checkstyle.raw" location="${checkstyle.reportdir}/raw.xml"/>
- <property name="stylesheet.html" location="${config.dir}/checkstyle-frames.xsl"/>
- <property name="stylesheet.html.sorted" location="${config.dir}/checkstyle-frames-sortby-check.xsl"/>
- <property name="stylesheet.text" location="${config.dir}/checkstyle-text.xsl"/>
- <property name="stylesheet.xdoc" location="${config.dir}/checkstyle-xdoc.xsl"/>
-
- <property name="checkstyle.basedir" location="${java.dir}"/>
-
<!-- Ant Checkstyle report -->
- <property name="tocheck" value="**/*.java"/>
- <property name="javadoc.scope" value="public"/>
+ <property name="checkstyle.reportdir"
+ location="${build.dir}/reports/checkstyle"
+ description="Where to store Checkstyle reports"/>
+ <property name="checkstyle.raw"
+ location="${checkstyle.reportdir}/raw.xml"
+ description="Name of Checkstyle XML-Report"/>
+ <property name="stylesheet.html"
+ location="${config.dir}/checkstyle-frames.xsl"
+ description="Name of Checkstyle XSLT for generating HTML"/>
+ <property name="stylesheet.html.sorted"
+ location="${config.dir}/checkstyle-frames-sortby-check.xsl"
+ description="Name of Checkstyle XSLT for generating 2nd HTML"/>
+ <property name="stylesheet.text"
+ location="${config.dir}/checkstyle-text.xsl"
+ description="Name of Checkstyle XSLT for generating plain text"/>
+ <property name="stylesheet.xdoc"
+ location="${config.dir}/checkstyle-xdoc.xsl"
+ description="Name of Checkstyle XSLT for generating XDOC"/>
- <taskdef resource="simiantask.properties"/>
-
+ <property name="checkstyle.basedir"
+ location="${java.dir}"
+ description="Where are the Java sources to check"/>
+ <property name="tocheck"
+ value="**/*.java"
+ description="Include pattern of the files to check"/>
+
<!-- Findbugs: Running Findbugs -->
- <property name="findbugs.reportdir"
- location="${build.dir}/reports/findbugs"
+ <property name="findbugs.reportdir"
+ location="${build.dir}/reports/findbugs"
description="Where to store Findbugs results"/>
- <property name="findbugs.raw"
- value="raw.xml"
+ <property name="findbugs.raw"
+ value="raw.xml"
description="Findbugs Output xml-file"/>
- <property name="findbugs.xsl"
- value="fancy.xsl"
+ <property name="findbugs.xsl"
+ value="fancy.xsl"
description="Which XSL to use for generating Output: default, fancy, plain, summary"/>
- <property name="findbugs.jvmargs"
- value="-Xms128m -Xmx512m"
+ <property name="findbugs.jvmargs"
+ value="-Xms128m -Xmx512m"
description="JVMArgs for invoking Findbugs"/>
<!-- RAT Release Auditing Tool -->
@@ -73,13 +86,26 @@
value="${rat.report.dir}/report.html"
description="RAT-Report file"/>
<property name="rat.version"
- value="0.7"
+ value="0.11"
description="Which Version of RAT to use"/>
+ <!-- Simian -->
+ <property name="simian.version"
+ value="2.4.0"
+ description="Which Version of Simian to use"/>
+ <property name="simian.uri"
+ value="http://www.harukizaemon.com/simian/simian-${simian.version}.tar.gz"
+ description="Where to get Simian"/>
+ <property name="simian.lib.dir"
+ value="${build.dir}/simian-lib"
+ description="Where to store Simian resources"/>
+ <property name="simian.report.dir"
+ value="${build.dir}/simian"
+ description="Where to store Simian reports"/>
<target name="init-ivy">
- <property name="ivy.version" value="2.4.0-rc1"/>
+ <property name="ivy.version" value="2.4.0"/>
<property name="ivy.jar.url" value="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
<property name="ivy.jar.dir" value="${build.dir}/ivy"/>
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
@@ -92,21 +118,30 @@
</target>
<target name="checkstyle" description="--> checks Ant codebase according to ${config.dir}/checkstyle-config" depends="init-ivy">
- <ivy:cachepath organisation="com.puppycrawl.tools" module="checkstyle" revision="5.7"
- inline="true" conf="default" pathid="checkstyle.classpath" transitive="true"/>
- <taskdef resource="checkstyletask.properties" classpathref="checkstyle.classpath" />
- <mkdir dir="${checkstyle.reportdir}"/>
- <checkstyle config="${config.dir}/checkstyle-config" failOnViolation="false">
- <formatter type="xml" toFile="${checkstyle.raw}"/>
- <fileset dir="${java.dir}">
- <include name="${tocheck}"/>
- <exclude name="**/bzip2/*.java"/>
- <exclude name="**/CVSPass.java"/>
- </fileset>
- </checkstyle>
+ <available property="antlr.present" classname="antlr.CommonAST"/>
+ <echo if:set="antlr.present">
+ Found antlr on the classpath.
+ Having a wrong antlr version on the same classpath as Checkstyle may produce errors like
+ 'Can't find/access AST Node typecom.puppycrawl.tools.checkstyle.api.DetailAST'
+ Skip running Checkstyle.
+ </echo>
+ <sequential unless:set="antlr.present">
+ <ivy:cachepath organisation="com.puppycrawl.tools" module="checkstyle" revision="6.18"
+ inline="true" conf="default" pathid="checkstyle.classpath" transitive="true"/>
+ <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties" classpathref="checkstyle.classpath" />
+ <mkdir dir="${checkstyle.reportdir}"/>
+ <checkstyle config="${config.dir}/checkstyle-config" failOnViolation="false">
+ <formatter type="xml" toFile="${checkstyle.raw}"/>
+ <fileset dir="${java.dir}">
+ <include name="${tocheck}"/>
+ <exclude name="**/bzip2/*.java"/>
+ <exclude name="**/CVSPass.java"/>
+ </fileset>
+ </checkstyle>
+ </sequential>
</target>
- <target name="htmlreport" description="--> generates a html checkstyle report">
+ <target name="htmlreport" description="--> generates a html checkstyle report" unless="antlr.present">
<xslt in="${checkstyle.raw}" style="${stylesheet.html}"
out="${checkstyle.reportdir}/html/output.txt">
<param name="basedir" expression="${checkstyle.basedir}"/>
@@ -119,7 +154,7 @@
</xslt>
</target>
- <target name="textreport" description="--> generates a text checkstyle report">
+ <target name="textreport" description="--> generates a text checkstyle report" unless="antlr.present">
<xslt in="${checkstyle.raw}" style="${stylesheet.text}"
out="${checkstyle.reportdir}/report.txt">
</xslt>
@@ -130,7 +165,7 @@
<echo>${report}</echo>
</target>
- <target name="xdocreport" description="--> generates a xdoc checkstyle report">
+ <target name="xdocreport" description="--> generates a xdoc checkstyle report" unless="antlr.present">
<xslt in="${checkstyle.raw}" style="${stylesheet.xdoc}"
out="${checkstyle.reportdir}/xdocs/index.xml">
<param name="basedir" expression="${checkstyle.basedir}"/>
@@ -145,11 +180,34 @@
</target>
<target name="simiancheck" description="--> runs the check for duplicates">
- <simian>
+ <available property="simian.jar.present" file="${simian.lib.dir}/simian-${simian.version}.jar"/>
+ <sequential unless:set="simian.jar.present">
+ <mkdir dir="${simian.lib.dir}"/>
+ <get src="${simian.uri}" dest="${simian.lib.dir}"/>
+ <gunzip src="${simian.lib.dir}/simian-${simian.version}.tar.gz" dest="${simian.lib.dir}/simian-${simian.version}.tar"/>
+ <untar src="${simian.lib.dir}/simian-${simian.version}.tar" dest="${simian.lib.dir}">
+ <patternset>
+ <include name="**/simian*.jar"/>
+ <include name="**/simian*.xsl"/>
+ </patternset>
+ <flattenmapper/>
+ </untar>
+ </sequential>
+
+ <taskdef resource="simiantask.properties">
+ <classpath>
+ <fileset dir="${simian.lib.dir}" includes="*.jar"/>
+ </classpath>
+ </taskdef>
+ <mkdir dir="${simian.report.dir}"/>
+ <simian failureProperty="simian.duplicates.found">
<fileset dir="${java.dir}" />
+ <formatter type="plain" toFile="${simian.report.dir}/simian-log.txt"/>
+ <formatter type="xml" toFile="${simian.report.dir}/simian-log.xml"/>
</simian>
+ <xslt in="${simian.report.dir}/simian-log.xml" style="${simian.lib.dir}/simian.xsl" out="${simian.report.dir}/simian.html"/>
</target>
-
+
<target name="fixTS" description="--> fix checkstyle errors 'Line has trailing spaces'">
<fail message="Define path to java file 'path'">
<condition><not><isset property="path"/></not></condition>
@@ -163,11 +221,11 @@
<fail message="Define path to java file 'path'">
<condition><not><isset property="path"/></not></condition>
</fail>
- <fixcrlf srcdir="src/main" includes="${path}" javafiles="yes" tab="remove" tablength="4"/>
+ <fixcrlf srcdir="src/main" includes="${path}" javafiles="yes" tab="remove" tablength="4"/>
</target>
<target name="findbugs" description="--> checks Ant codebase with Findbugs" depends="init-ivy,build" xmlns:fb="http://findbugs.sourceforge.net/">
- <ivy:cachepath organisation="com.google.code.findbugs" module="findbugs-ant" revision="1.3.9"
+ <ivy:cachepath organisation="com.google.code.findbugs" module="findbugs-ant" revision="3.0.0"
inline="true" conf="default" pathid="findbugs.real.classpath" transitive="true"/>
<!-- Load the Findbugs AntTasks -->
<taskdef uri="http://findbugs.sourceforge.net/" resource="edu/umd/cs/findbugs/anttask/tasks.properties" classpathref="findbugs.real.classpath" />
diff --git a/contributors.xml b/contributors.xml
index ee049cb..ade30f9 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -1153,6 +1153,10 @@
<last>Rossmueller</last>
</name>
<name>
+ <first>Olivier</first>
+ <last>Parent</last>
+ </name>
+ <name>
<first>Omer</first>
<last>Shapira</last>
</name>
diff --git a/docs.xml b/docs.xml
index f49e70f..1cb7806 100644
--- a/docs.xml
+++ b/docs.xml
@@ -17,9 +17,7 @@
-->
<project name="docs" default="txt2html">
- <available property="jdk1.5+" classname="java.net.Proxy"/>
<target name="txt2html">
- <fail unless="jdk1.5+" message="Tomcat BuildUtils requires Java5+"/>
<property name="build.dir" value="build"/>
<tempfile property="temp.dir"/>
<mkdir dir="${temp.dir}/org/apache/tomcat/buildutil"/>
diff --git a/fetch.xml b/fetch.xml
index 8442d2a..f8e0bf9 100644
--- a/fetch.xml
+++ b/fetch.xml
@@ -199,6 +199,12 @@
<echoproperties />
</target>
+ <target name="ivy"
+ description="load Ivy dependency manager"
+ depends="init">
+ <f2 project="org.apache.ivy" archive="ivy" />
+ </target>
+
<target name="logging"
description="load logging libraries"
depends="init">
@@ -328,8 +334,12 @@
<get src="ftp://ftp.software.ibm.com/software/awdtools/netrexx/NetRexx.zip" dest="${temp.dir}/NetRexx.zip" skipexisting="true"/>
</target>
+ <target name="xz" depends="init" description="loads XZ for Java">
+ <f2 project="org.tukaani" archive="xz"/>
+ </target>
+
<target name="all"
description="load all the libraries (except jython)"
- depends="logging,junit,xml,networking,regexp,antlr,bcel,jdepend,bsf,debugging,script,javamail,jspc,jai,netrexx" />
+ depends="ivy,logging,junit,xml,networking,regexp,antlr,bcel,jdepend,bsf,debugging,script,javamail,jspc,jai,xz,netrexx" />
</project>
diff --git a/lib/libraries.properties b/lib/libraries.properties
index f2805fd..21961f3 100644
--- a/lib/libraries.properties
+++ b/lib/libraries.properties
@@ -31,6 +31,7 @@
#versions of different libraries. Please keep in alphabetical order, except
#when a specific dependency forces them to be out-of-order
+ivy.version=2.4.0
antlr.version=2.7.7
bcel.version=5.1
bsf.version=2.4.0
@@ -60,6 +61,7 @@
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/manual/Tasks/apt.html b/manual/Tasks/apt.html
deleted file mode 100644
index 4bdd9a9..0000000
--- a/manual/Tasks/apt.html
+++ /dev/null
@@ -1,179 +0,0 @@
-<!--
- 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.
--->
-<html lang="en-us"><head>
-<meta http-equiv="Content-Language" content="en-us"><link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
-<title>Apt Task</title></head>
-
-<body>
-
-<h2><a name="Apt">Apt</a></h2>
-<h3>Description</h3>
-<p>Runs the annotation processor tool (apt), and then optionally compiles
- the original code, and any generated source code.
- <p>This task runs on Java 1.5 to Java 1.7.</p>
- <p>Apt is deprecated in Java 1.6, which can run annotation
- processors as part of javac, and removed from the distribution in Java 1.8.
- The task will fire an exception when attempting to run under Java 1.8.</p>
-
-
-<p>This task inherits from the <a href="javac.html">Javac Task</a>, and thus
- supports nearly all of the same attributes, and subelements.
- There is one special case, the <tt>fork</tt> attribute, which is present
- but which can only be set to <tt>true</tt>. That is, apt only works as
- a forked process.
- </p>
- <p>
- In addition, it supports
- the following addition items:</p>
-
-<h3>Parameters</h3>
-<table border="1" cellpadding="2" cellspacing="0">
- <tbody><tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">compile</td>
- <td valign="top">After running the Apt, should the code be compiled. (see the
- <code>-nocompile</code> flag on the Apt executable)</td>
- <td align="center" valign="top">No, defaults to false.</td>
- </tr>
- <tr>
- <td valign="top">factory</td>
- <td valign="top">The fully qualified classname of the AnnotationProcessFactory to be used
- to construct annotation processors. This represents the <code>-factory</code>
- command line flag of the Apt executable.</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">factorypathref</td>
- <td valign="top">The reference id of the path used to find the classes needed by the
- AnnotationProcessorFactory (and the location of the factory itself).
- This represents the <code>-factorypath</code> flag on the Apt executable.</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">preprocessdir</td>
- <td valign="top">The directory used for preprocessing. This is the directory where the
- generated source code will be place. This represents the <code>-s</code> flag on
- the Apt executable.</td>
- <td align="center" valign="top">No</td>
- </tr>
-</tbody></table>
-
-<h3>Parameters specified as nested elements</h3>
-
-
-<h4>factorypath</h4>
-
-<p>You can specify the path used to find the classes needed by the AnnotationProcessorFactory
- at runtime, using this element. It is represents as a generic path like structure. This
- represents the <code>-factorypath</code> flag on the Apt executable.</p>
-
-
-<h4>option</h4>
-
-<p>Used to represent a generic option to pass to Apt. This represents the <code>-A</code> flag on the
- Apt executable. You can specify zero or more <code><option></code> elements.</p>
-
-<table border="1" cellpadding="2" cellspacing="0">
-<tbody><tr>
- <td valign="top" width="12%"><b>Attribute</b></td>
- <td valign="top" width="78%"><b>Description</b></td>
- <td valign="top" width="10%"><b>Required</b></td>
-</tr>
- <tr>
- <td valign="top">name</td>
- <td align="center">The name of the option</td>
- <td align="center">Yes.</td>
- </tr>
- <tr>
- <td valign="top">value</td>
- <td align="center">The value to set the option to</td>
- <td align="center">Yes.</td>
- </tr>
-</tbody></table>
-
-<h3>Examples</h3>
-<blockquote><pre>
-<apt srcdir="${src}"
- destdir="${build}"
- classpath="xyz.jar"
- debug="on"
- compile="true"
- factory="com.mycom.MyAnnotationProcessorFactory"
- factorypathref="my.factorypath.id"
- preprocessdir="${preprocess.dir}">
-</apt>
-</pre></blockquote>
-<p>compiles all <code>.java</code> files under the <code>${src}</code>
-directory, and stores
-the <code>.class</code> files in the <code>${build}</code> directory.
-The classpath used includes <code>xyz.jar</code>, and compiling with
-debug information is on. It also forces the generated source code to
-be compiled. The generated source code will be placed in
-<code>${preprocess.dir}</code> directory, using the class
-<code>com.mycom.MyAnnotationProcessorFactory</code> to supply
-AnnotationProcessor instances.</p>
-
-
-<h3>Notes</h3>
-
-<p>
-The inherited "fork" attribute is set to true by default; please do not change it.
-</p>
-
-<p>
-The inherited "compiler" attribute is ignored, as it is forced to use the Apt compiler
-</p>
-
-<p>Using the Apt compiler with the "compile" option set to "true"
- forces you to use Sun's Apt compiler, which will use the JDK's Javac compiler.
- If you wish to use another compiler, you will first need run the Apt processor
- with the "compile" flag set to "false", and then use a
- <code><javac></code> task to compile first your original source code, and then the
- generated source code:</p>
-
-<blockquote><pre>
-<apt srcdir="${src}"
- destdir="${build}"
- classpath="xyz.jar"
- debug="true"
- compile="false"
- factory="com.mycom.MyAnnotationProcessorFactory"
- factorypathref="my.factorypath.id"
- preprocessdir="${preprocess.dir}">
-</apt>
-
-<javac srcdir="${src}"
- destdir="${build}"
- classpath="xyz.jar"
- debug="on"/>
-
-<javac srcdir="${preprocess.dir}"
- destdir="${build}"
- classpath="xyz.jar"
- debug="true"/>
-</pre></blockquote>
-
-This may involve more build file coding, but the speedup gained from switching
-to jikes may justify the effort.
-<p>
-</p>
-
-</body></html>
diff --git a/manual/Tasks/attrib.html b/manual/Tasks/attrib.html
index a26f0c5..ab09f65 100644
--- a/manual/Tasks/attrib.html
+++ b/manual/Tasks/attrib.html
@@ -57,6 +57,9 @@
the Windows command, you can use the task's os attribute and set its
value to your current os.</p>
+<p>See the <a href="setpermissions.html">setpermissions</a> task for a
+ platform independent alternative.</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
diff --git a/manual/Tasks/chmod.html b/manual/Tasks/chmod.html
index 74e71d0..59ecc5a 100644
--- a/manual/Tasks/chmod.html
+++ b/manual/Tasks/chmod.html
@@ -63,6 +63,9 @@
the Unix command, you can use the task's os attribute and set its
value to your current os.</p>
+<p>See the <a href="setpermissions.html">setpermissions</a> task for a
+ platform independent alternative.</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
diff --git a/manual/Tasks/conditions.html b/manual/Tasks/conditions.html
index 08d0bcc..b1c1c31 100644
--- a/manual/Tasks/conditions.html
+++ b/manual/Tasks/conditions.html
@@ -537,6 +537,11 @@
<td valign="top" align="center">No</td>
</tr>
<tr>
+ <td valign="top">encoding</td>
+ <td valign="top">The encoding of the script source. <em>since Ant 1.10.2.</em></td>
+ <td valign="top" align="center">No - defaults to default JVM encoding</td>
+ </tr>
+ <tr>
<td valign="top">setbeans</td>
<td valign="top">whether to have all properties, references and targets as
global variables in the script. <em>since Ant 1.8.0</em></td>
diff --git a/manual/Tasks/get.html b/manual/Tasks/get.html
index a2c9b7e..e63b59d 100644
--- a/manual/Tasks/get.html
+++ b/manual/Tasks/get.html
@@ -170,6 +170,29 @@
name will be skipped. If the returned name is a relative path, it
will be considered relative to the <em>dest</em> attribute.</p>
+<h4>header</h4>
+<p>Any arbitrary number of HTTP headers can be added to a request.<br/>
+ The attributes of a nested <pre><header/> </pre> node are as follow:
+<p></p>
+
+<table width="60%" border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">name</td>
+ <td valign="top">The name or key of this header. Cannot be null or empty. Leading and trailing spaces are removed</td>
+ <td align="center" valign="top">Yes</td>
+ </tr>
+ <tr>
+ <td valign="top">value</td>
+ <td valign="top">The value to assign to the header. Cannot be null or empty. Leading and trailing spaces are removed</td>
+ <td align="center" valign="top">Yes</td>
+ </tr>
+</table>
+
<h3>Examples</h3>
<pre> <get src="http://ant.apache.org/" dest="help/index.html"/></pre>
<p>Gets the index page of http://ant.apache.org/, and stores it in the file <code>help/index.html</code>.</p>
@@ -234,6 +257,16 @@
<url url="http://ant.apache.org/faq.html"/>
</get>
</pre>
+
+<p>With custom HTTP headers</p>
+<pre>
+<get src="http://ant.apache.org/index.html" dest="downloads">
+ <header name="header1" value="headerValue1" />
+ <header name="header2" value="headerValue2" />
+ <header name="header3" value="headerValue3" />
+</get>
+</pre>
+
<p>Gets the index and FAQ pages of http://ant.apache.org/, and stores
them in the directory <code>downloads</code> which will be created if
necessary.</p>
diff --git a/manual/Tasks/jar.html b/manual/Tasks/jar.html
index 1df2ee0..6920eff 100644
--- a/manual/Tasks/jar.html
+++ b/manual/Tasks/jar.html
@@ -90,6 +90,11 @@
<p>To cryptographically sign your JAR file, use the <a href="signjar.html">SignJar task</a> on the JAR that you create from this task.</p>
+<p>For creating a simple version of a <a target="_blank" href="http://openjdk.java.net/jeps/238">JEP-238 multi release jar</a>,
+you don't need any special tools. Just set the required manifest entry and place the files where required, as you could see
+in the <a href="#jep238-example">JEP238-example</a>. If you want to tune this kind of jar, e.g. decreasing the size by deleting
+'same' classes from the versions-branches, you have to do more ...</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -583,6 +588,36 @@
</pre></blockquote>
+<a name="jep238-example"/>
+<h4>JEP238 example: a Multi-Release JAR Files</h4>
+<p>
+ Here we want to create a <i>Multi-Release JAR File</i> according the specification
+ <a target="_blank" href="http://openjdk.java.net/jeps/238">JEP-238</a>.
+ It defines on top of a JAR the possibility to place additional or overwriting classes
+ in a jar, which are available according to the Java version you run.<br>
+ Basically it sais, that you have to set the manifest entry <tt>Multi-Release: true</tt>
+ and place all additional or overwriting classes in
+ <tt>META-INF/versions/<i>number</i>/package-structure</tt>, e.g.
+ <tt>META-INF/versions/9/org/apache/ant/MyClass.class</tt>
+</p>
+<p>
+ In this example we expect that the normal classes are compiled into
+ <code>${java.classes}</code> and the Java9 classes are compiled into
+ <code>${java9.classes}</code>.
+</p>
+<blockquote><pre>
+ <jar destfile="mrjar.jar">
+ <manifest>
+ <!-- special mf-entry according to the spec -->
+ <attribute name="Multi-Release" value="true"/>
+ </manifest>
+ <!-- directory structure according to the spec ... -->
+ <!-- ... default classes loadable by old (<Java9) versions -->
+ <fileset dir="${java.classes}"/>
+ <!-- ... per release classes, require Java9+ for loadable via standard ClassLoader -->
+ <zipfileset prefix="META-INF/versions/9/" dir="${java9.classes}"/>
+ </jar>
+</pre></blockquote>
</body>
</html>
diff --git a/manual/Tasks/javah.html b/manual/Tasks/javah.html
index 4d3979b..bc49d77 100644
--- a/manual/Tasks/javah.html
+++ b/manual/Tasks/javah.html
@@ -46,15 +46,14 @@
name="implementationvalues">Here are the choices of the attribute</a>:</p>
<ul>
<li>default - the default compiler for the platform.</li>
- <li>sun (the standard compiler of the JDK) - default when not
- running on Kaffee or gcj/gij or Java9.</li>
+ <li>sun (the standard compiler of the JDK)</li>
<li>kaffeh (the native standard compiler of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li>
<li>gcjh (the native standard compiler
of <a href="http://gcc.gnu.org/java/"
target="_top">gcj and gij</a>) <em>since Apache Ant 1.8.2</em></li>
<li>forking - runs the javah executable via its command line
- interface in a separate process. Default when running on
- Java9. <em>since Ant 1.9.8</em></li>
+ interface in a separate process. Default when not running on
+ Kaffee or gcj/gij <em>since Ant 1.9.8</em></li>
</ul>
<p><b>Note:</b> if you are using this task to work on multiple files
diff --git a/manual/Tasks/native2ascii.html b/manual/Tasks/native2ascii.html
index ecc065a..1017714 100644
--- a/manual/Tasks/native2ascii.html
+++ b/manual/Tasks/native2ascii.html
@@ -62,13 +62,12 @@
<a name="implementationvalues">Here are the choices of the attribute</a>:</p>
<ul>
<li>default - the default converter for the platform - kaffee
- when run on Kaffee, builtin if JDK9 or newer is detected, sun
- otherwise.</li>
- <li>sun (the standard converter of the JDK < 9)</li>
+ when run on Kaffee, builtin otherwise.</li>
+ <li>sun (used to be the standard converter of the JDK < 9)</li>
<li>kaffe (the standard converter
of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li>
- <li>builtin - Ant's internal implementation used for
- JDK9+. <em>since ant 1.9.8</em></li>
+ <li>builtin - Ant's internal implementation. <em>since ant
+ 1.9.8</em></li>
</ul>
<table border="1" cellpadding="2" cellspacing="0">
diff --git a/manual/Tasks/pack.html b/manual/Tasks/pack.html
index 60ae1e5..b673333 100644
--- a/manual/Tasks/pack.html
+++ b/manual/Tasks/pack.html
@@ -19,16 +19,22 @@
<head>
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
-<title>GZip/BZip2 Tasks</title>
+<title>GZip/BZip2/XZ Tasks</title>
</head>
<body>
<h2><a name="pack">GZip/BZip2</a></h2>
<h3>Description</h3>
-<p>Packs a resource using the GZip or BZip2 algorithm.
+<p>Packs a resource using the GZip, BZip2 or XZ algorithm.
The output file is only generated if it doesn't exist or the source
resource is newer.</p>
+
+<p>XZ compression support has been added with Apache Ant 1.10.1 and
+depends on external libraries not included in the Ant distribution.
+See <a href="../install.html#librarydependencies">Library
+Dependencies</a> for more information.</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -38,7 +44,7 @@
</tr>
<tr>
<td valign="top">src</td>
- <td valign="top">the file to gzip/bzip.</td>
+ <td valign="top">the file to gzip/bzip/xz.</td>
<td align="center" valign="top">Yes, or a nested resource collection.</td>
</tr>
<tr>
@@ -64,6 +70,9 @@
<bzip2 src="test.tar" destfile="test.tar.bz2"/>
</pre></blockquote>
<blockquote><pre>
+<xz src="test.tar" destfile="test.tar.xz"/>
+</pre></blockquote>
+<blockquote><pre>
<gzip destfile="archive.tar.gz">
<url url="http://example.org/archive.tar"/>
</gzip>
diff --git a/manual/Tasks/script.html b/manual/Tasks/script.html
index fb00822..d111124 100644
--- a/manual/Tasks/script.html
+++ b/manual/Tasks/script.html
@@ -103,6 +103,11 @@
<td valign="top" align="center">No</td>
</tr>
<tr>
+ <td valign="top">encoding</td>
+ <td valign="top">The encoding of the script as a file. <em>since Ant 1.10.2.</em></td>
+ <td valign="top" align="center">No - defaults to default JVM encoding</td>
+ </tr>
+ <tr>
<td valign="top">setbeans</td>
<td valign="top">
This attribute controls whether to set variables for
@@ -282,7 +287,7 @@
// Access to Ant-Properties by their names
dir = <font color=blue>project</font>.getProperty("fs.dir");
includes = <font color=blue>MyProject</font>.getProperty("fs.includes");
- excludes = <font color=blue>self.getProject()</font> .<font color=blue>getProperty("fs.excludes")</font>;
+ excludes = <font color=blue>self.getProject()</font>.<font color=blue>getProperty("fs.excludes")</font>;
// Create a <fileset dir="" includes=""/>
fs = project.<font color=blue>createDataType("fileset")</font>;
diff --git a/manual/Tasks/scriptdef.html b/manual/Tasks/scriptdef.html
index 38c3fff..f593e61 100644
--- a/manual/Tasks/scriptdef.html
+++ b/manual/Tasks/scriptdef.html
@@ -116,6 +116,20 @@
<td valign="top" align="center">No</td>
</tr>
<tr>
+ <td valign="top">encoding</td>
+ <td valign="top">The encoding of the script as a file. <em>since Ant 1.10.2.</em></td>
+ <td valign="top" align="center">No - defaults to default JVM encoding</td>
+ </tr>
+ <tr>
+ <td valign="top">compiled</td>
+ <td valign="top">If true, the script is compiled before the first
+ evaluation for faster multiple executions, on the condition that the <em>manager</em> is "javax" and the
+ target engine implements <code>javax.script.Compilable</code>.
+ Note that the <code>bsf</code> manager may automatically compiles the script.
+ <em>since Ant 1.10.2.</em></td>
+ <td valign="top" align="center">No - defaults to false</td>
+ </tr>
+ <tr>
<td valign="top">uri</td>
<td valign="top">
The XML namespace uri that this definition should live in.
diff --git a/manual/Tasks/setpermissions.html b/manual/Tasks/setpermissions.html
new file mode 100644
index 0000000..22a6fb8
--- /dev/null
+++ b/manual/Tasks/setpermissions.html
@@ -0,0 +1,109 @@
+<!--
+ 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.
+-->
+<html>
+
+<head>
+<meta http-equiv="Content-Language" content="en-us">
+<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
+<title>SetPermissions Task</title>
+</head>
+
+<body>
+
+<h2><a name="setpermissions">SetPermissions</a></h2>
+<p><em>Since Ant 1.10.0.</em></p>
+<h3>Description</h3>
+<p>Changes the file permissions using Java's NIO support for
+ permissions.</p>
+<p>This task provides a subset of the platform specific abilities of
+ <a href="chmod.html">chmod</a> and <a href="attrib.html">attrib</a>
+ in a platform independent way.</p>
+<p>If no permissions are specified either via the mode or the
+ permissions attribute, then all permissions will be removed from the
+ nested resources.</p>
+<p>The task accepts aribitrary resources as part of the nested
+ resource collections, but not all resources support setting
+ permissions. This task won't do anything for resources that don't
+ support setting permissions - for example URLs.</p>
+<p>The permissions are applied to all resources contained within the
+ nested resources collections. You may want to ensure the collection
+ only returns files or directories if you want different sets of
+ permissions to apply to either type of resource.</p>
+
+<h3>Parameters</h3>
+<table border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">permissions</td>
+ <td valign="top">The permissions to set as comma separated list of
+ names
+ of <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/PosixFilePermission.html">PosixFilePermission</a>
+ values.</td>
+ <td valign="top" align="center">No</td>
+ </tr>
+ <tr>
+ <td valign="top">mode</td>
+ <td valign="top">The permissions to set as tradional Unix
+ three-digit octal number.</td>
+ <td valign="top" align="center">No</td>
+ </tr>
+ <tr>
+ <td valign="top">nonPosixMode</td>
+ <td valign="top">What to do if changing the permissions of a file
+ is not possible because the file-system doesn't support POSIX
+ file permissions. Possible options are <code>fail</code> (fail
+ the build), <code>pass</code> (just log an
+ error), <code>tryDosOrFail</code> (at least try to set the
+ read-only flag on DOS file systems, fail if that isn't possible
+ either) and <code>tryDosOrPass</code> (at least try to set the
+ read-only flag on DOS file systems, just log an error if that
+ isn't possible either).</td>
+ <td valign="top" align="center">No, defaults to <code>fail</code></td>
+ </tr>
+ <tr>
+ <td valign="top">failonerror</td>
+ <td valign="top">Whether to stop the build if setting permissions
+ fails.</td>
+ <td valign="top" align="center">No, defaults to true</td>
+ </tr>
+</table>
+<h3>Parameters specified as nested elements</h3>
+
+<h4>any resource collection</h4>
+<p><a href="../Types/resources.html#collection">Resource
+Collection</a>s are used to select groups of resources.</p>
+<h3>Examples</h3>
+ <blockquote><pre>
+<setpermissions mode="755">
+ <file file="${dist}/start.sh"/>
+</setpermissions>
+ </pre></blockquote>
+<p>makes the "start.sh" file readable and executable for
+ anyone and in addition writable by the owner.</p>
+ <blockquote><pre>
+<setpermissions permissions="OWNER_READ,OWNER_WRITE,OWNER_EXECUTE,OTHERS_READ,OTHERS_EXECUTE,GROUP_READ,GROUP_EXECUTE">
+ <file file="${dist}/start.sh"/>
+</setpermissions>
+ </pre></blockquote>
+<p>makes the "start.sh" file readable and executable for
+ anyone and in addition writable by the owner.</p>
+</body>
+</html>
diff --git a/manual/Tasks/unpack.html b/manual/Tasks/unpack.html
index dcc88a9..f7def5d 100644
--- a/manual/Tasks/unpack.html
+++ b/manual/Tasks/unpack.html
@@ -24,17 +24,22 @@
<body>
-<h2><a name="unpack">GUnzip/BUnzip2</a></h2>
+<h2><a name="unpack">GUnzip/BUnzip2/UnXZ</a></h2>
<h3>Description</h3>
-<p>Expands a resource packed using GZip or BZip2.</p>
+<p>Expands a resource packed using GZip, BZip2 or XZ.</p>
<p>If <i>dest</i> is a directory the name of the destination file is
-the same as <i>src</i> (with the ".gz" or ".bz2"
+the same as <i>src</i> (with the ".gz", ".bz2" or ".xz"
extension removed if present). If <i>dest</i> is omitted, the parent
dir of <i>src</i> is taken. The file is only expanded if the source
resource is newer than the destination file, or when the destination file
does not exist.</p>
+<p>XZ compression support has been added with Apache Ant 1.10.1 and
+depends on external libraries not included in the Ant distribution.
+See <a href="../install.html#librarydependencies">Library
+Dependencies</a> for more information.</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -70,6 +75,10 @@
</pre></blockquote>
<p>expands <i>test.tar.bz2</i> to <i>test.tar</i></p>
<blockquote><pre>
+<uncz src="test.tar.xz"/>
+</pre></blockquote>
+<p>expands <i>test.tar.xz</i> to <i>test.tar</i></p>
+<blockquote><pre>
<gunzip src="test.tar.gz" dest="test2.tar"/>
</pre></blockquote>
<p>expands <i>test.tar.gz</i> to <i>test2.tar</i></p>
@@ -104,12 +113,12 @@
</pre>
<p>The same is also true for <code><bunzip2></code> and
-<code><bzip2resource></code>. <code><copy></code> offers
-additional features like <a
-href="../Types/filterchain.html">filtering files</a> on the fly,
-allowing a file to be mapped to multiple destinations, preserving the
-last modified time or a configurable file system timestamp
-granularity.</p>
+<code><bzip2resource></code> or <code>%lt;unxz></code>
+and <code>%lt;xzresource></code>. <code><copy></code> offers
+additional features like <a href="../Types/filterchain.html">filtering
+files</a> on the fly, allowing a file to be mapped to multiple
+destinations, preserving the last modified time or a configurable file
+system timestamp granularity.</p>
diff --git a/manual/Types/filterchain.html b/manual/Types/filterchain.html
index 90dd74b..4c5f94e 100644
--- a/manual/Types/filterchain.html
+++ b/manual/Types/filterchain.html
@@ -1566,6 +1566,11 @@
<td vAlign=top align="center">No</td>
</tr>
<tr>
+ <td valign="top">encoding</td>
+ <td valign="top">The encoding of the script as a file. <em>since Ant 1.10.2.</em></td>
+ <td valign="top" align="center">No - defaults to default JVM encoding</td>
+ </tr>
+ <tr>
<td valign="top">setbeans</td>
<td valign="top">whether to have all properties, references and targets as
global variables in the script. <em>since Ant 1.8.0</em></td>
diff --git a/manual/Types/mapper.html b/manual/Types/mapper.html
index 5aff311..1da85dc 100644
--- a/manual/Types/mapper.html
+++ b/manual/Types/mapper.html
@@ -806,6 +806,11 @@
<td align="center" valign="top">No</td>
</tr>
<tr>
+ <td valign="top">encoding</td>
+ <td valign="top">The encoding of the script as a file. <em>since Ant 1.10.2.</em></td>
+ <td valign="top" align="center">No - defaults to default JVM encoding</td>
+ </tr>
+ <tr>
<td valign="top">setbeans</td>
<td valign="top">whether to have all properties, references and targets as
global variables in the script. <em>since Ant 1.8.0</em></td>
diff --git a/manual/Types/resources.html b/manual/Types/resources.html
index 8ba77aa..b90ee23 100644
--- a/manual/Types/resources.html
+++ b/manual/Types/resources.html
@@ -49,6 +49,7 @@
<li><a href="#string">string</a> - a text string.</li>
<li><a href="#tarentry">tarentry</a> - an entry in a tar file.</li>
<li><a href="#url">url</a> - a URL.</li>
+ <li><a href="#xzresource">xzresource</a> - an XZ compressed resource.</li>
<li><a href="#zipentry">zipentry</a> - an entry in a zip file.</li>
</ul>
@@ -277,6 +278,18 @@
A single element resource collection must be specified as a nested
element.</p>
+<h4><a name="xzresource">xzresource</a></h4>
+
+<p>This is not a stand-alone resource, but a wrapper around another
+resource providing compression of the resource's contents on the fly.
+A single element resource collection must be specified as a nested
+element.</p>
+
+<p>XZ compression support has been added with Apache Ant 1.10.1 and
+depends on external libraries not included in the Ant distribution.
+See <a href="../install.html#librarydependencies">Library
+Dependencies</a> for more information.</p>
+
<h4><a name="url">url</a></h4>
<p>Represents a URL.</p>
diff --git a/manual/Types/selectors.html b/manual/Types/selectors.html
index 402c711..db2ec48 100644
--- a/manual/Types/selectors.html
+++ b/manual/Types/selectors.html
@@ -92,6 +92,12 @@
Select files if they are readable.</li>
<li><a href="#writable"><code><writable></code></a> -
Select files if they are writable.</li>
+ <li><a href="#executable"><code><executable></code></a> -
+ Select files if they are executable.</li>
+ <li><a href="#symlink"><code><symlink></code></a> -
+ Select files if they are symlink.</li>
+ <li><a href="#ownedBy"><code><ownedBy></code></a> -
+ Select files if they are owned by a given user.</li>
</ul>
<h4><a name="containsselect">Contains Selector</a></h4>
@@ -1018,6 +1024,49 @@
but the Java VM cannot detect this state, this selector will
still select the file.</p>
+ <h4><a name="executable">Executable Selector</a></h4>
+
+ <p>The <code><executable></code> selector selects only files
+ that are executable. Ant only invokes
+ <code>java.nio.file.Files#isExecutable</code> so if a file is not executable
+ but the Java VM cannot detect this state, this selector will
+ still select the file.</p>
+
+ <p><em>Since Ant 1.10.0</em></p>
+
+ <h4><a name="symlink">Symlink Selector</a></h4>
+
+ <p>The <code><symlink></code> selector selects only files
+ that are symbolic links. Ant only invokes
+ <code>java.nio.file.Files#isSymbolicLink</code> so if a file
+ is a symbolic link but the Java VM cannot detect this state,
+ this selector will not select the file.</p>
+
+ <p><em>Since Ant 1.10.0</em></p>
+
+ <h4><a name="ownedBy">OwnedBy Selector</a></h4>
+
+ <p>The <code><ownedBy></code> selector selects only files
+ that are owned by the given user. Ant only invokes
+ <code>java.nio.file.Files#getOwner</code> so if a file system
+ doesn't support the operation this selector will not select
+ the file.</p>
+
+ <p><em>Since Ant 1.10.0</em></p>
+
+ <table border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">owner</td>
+ <td valign="top">Username of the expected owner</td>
+ <td valign="top" align="center">yes</td>
+ </tr>
+ </table>
+
<h4><a name="scriptselector">Script Selector</a></h4>
<p>
@@ -1059,6 +1108,11 @@
<td valign="top" align="center">no</td>
</tr>
<tr>
+ <td valign="top">encoding</td>
+ <td valign="top">The encoding of the script as a file. <em>since Ant 1.10.2.</em></td>
+ <td valign="top" align="center">No - defaults to default JVM encoding</td>
+ </tr>
+ <tr>
<td valign="top">setbeans</td>
<td valign="top">whether to have all properties, references and targets as
global variables in the script.</td>
diff --git a/manual/cover.html b/manual/cover.html
index 15ae811..e4912d9 100644
--- a/manual/cover.html
+++ b/manual/cover.html
@@ -19,14 +19,14 @@
<head>
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" type="text/css" href="stylesheets/style.css">
-<title>Apache Ant 1.9.10 User Manual</title>
+<title>Apache Ant 1.10.2 User Manual</title>
</head>
<body bgcolor="#FFFFFF">
<div align="center">
<h1><img src="images/ant_logo_large.gif" width="190" height="120"></h1>
- <h1>Apache Ant™ 1.9.10 Manual</h1>
- <p align="left">This is the manual for version 1.9.10 of
+ <h1>Apache Ant™ 1.10.2 Manual</h1>
+ <p align="left">This is the manual for version 1.10.2 of
<a target="_top" href="http://ant.apache.org/index.html">Apache Ant</a>.
If your version
of Ant (as verified with <tt>ant -version</tt>) is older or newer than this
diff --git a/manual/credits.html b/manual/credits.html
index 85e92b6..f6cd947 100644
--- a/manual/credits.html
+++ b/manual/credits.html
@@ -62,7 +62,7 @@
</ul>
<center>
-<p>Version: 1.9.10</p>
+<p>Version: 1.10.2</p>
</center>
diff --git a/manual/install.html b/manual/install.html
index 818b168..51ab721 100644
--- a/manual/install.html
+++ b/manual/install.html
@@ -1018,6 +1018,12 @@
<td><a href="https://jai.dev.java.net/"
target="_top">https://jai.dev.java.net/</a></td>
</tr>
+ <tr>
+ <td>XZ - XZ for Java <b>1.6 or later</b></td>
+ <td>xz and unxz tasks, xzresource, xz compression in tar/untar</td>
+ <td><a href="http://www.tukaani.org/xz/java.html"
+ target="_top">http://www.tukaani.org/xz/java.html</a></td>
+ </tr>
</table>
<br>
<h2><a name="Troubleshooting">Troubleshooting</a></h2>
diff --git a/manual/tasklist.html b/manual/tasklist.html
index 6578e55..5829b4d 100644
--- a/manual/tasklist.html
+++ b/manual/tasklist.html
@@ -40,7 +40,6 @@
<li><a href="Tasks/antstructure.html">AntStructure</a></li>
<li><a href="Tasks/antversion.html">AntVersion</a></li>
<li><a href="Tasks/apply.html">Apply/<i>ExecOn</i></a></li>
-<li><a href="Tasks/apt.html">Apt</a></li>
<li><a href="Tasks/attrib.html">Attrib</a></li>
<li><a href="Tasks/augment.html">Augment</a></li>
<li><a href="Tasks/available.html">Available</a></li>
@@ -148,6 +147,7 @@
<li><a href="Tasks/rexec.html">RExec</a></li>
<li><a href="Tasks/rmic.html">Rmic</a></li>
<li><a href="Tasks/rpm.html">Rpm</a></li>
+<li><a href="Tasks/setpermissions.html">SetPermissions</a></li>
<li><a href="Tasks/schemavalidate.html">SchemaValidate</a></li>
<li><a href="Tasks/scp.html">Scp</a></li>
<li><a href="Tasks/script.html">Script</a></li>
@@ -178,6 +178,7 @@
<li><a href="Tasks/unzip.html">Unjar</a></li>
<li><a href="Tasks/unzip.html">Untar</a></li>
<li><a href="Tasks/unzip.html">Unwar</a></li>
+<li><a href="Tasks/unpack.html">UnXZ</a></li>
<li><a href="Tasks/unzip.html">Unzip</a></li>
<li><a href="Tasks/uptodate.html">Uptodate</a></li>
<li><a href="Tasks/verifyjar.html">VerifyJar</a></li>
@@ -188,6 +189,7 @@
<li><a href="Tasks/wljspc.html">Weblogic JSP Compiler</a></li>
<li><a href="Tasks/xmlproperty.html">XmlProperty</a></li>
<li><a href="Tasks/xmlvalidate.html">XmlValidate</a></li>
+<li><a href="Tasks/pack.html">XZ</a></li>
<li><a href="Tasks/style.html">XSLT/<i>Style</i></a></li>
<li><a href="Tasks/zip.html">Zip</a></li>
</ul>
diff --git a/manual/tasksoverview.html b/manual/tasksoverview.html
index 99aa11b..776082c 100644
--- a/manual/tasksoverview.html
+++ b/manual/tasksoverview.html
@@ -67,13 +67,13 @@
</tr>
<tr valign="top">
- <td nowrap><a href="Tasks/unpack.html">BUnzip2</a></td>
- <td><p>Expands a file packed using GZip or BZip2.</p></td>
+ <td nowrap><a href="Tasks/unpack.html">GUnzip/BUnzip2/UnXZ</a></td>
+ <td><p>Expands a file packed using GZip, BZip2 or XZ.</p></td>
</tr>
<tr valign="top">
- <td nowrap><a href="Tasks/pack.html">BZip2</a></td>
- <td><p>Packs a file using the GZip or BZip2 algorithm. This task
+ <td nowrap><a href="Tasks/pack.html">GZip/BZip2/XZ</a></td>
+ <td><p>Packs a file using the GZip, BZip2 or XZ algorithm. This task
does not do any dependency checking; the output file is always
generated</p></td>
</tr>
@@ -232,12 +232,6 @@
</tr>
<tr valign="top">
- <td nowrap><a href="Tasks/apt.html">Apt</a></td>
- <td><p>Runs the annotation processor tool (apt), and then optionally compiles
- the original code, and any generated source code.</p></td>
- </tr>
-
- <tr valign="top">
<td nowrap><a href="Tasks/jspc.html">JspC</a></td>
<td><p>Runs the JSP compiler. It can be used to precompile JSP pages
for fast initial invocation of JSP pages, deployment on a server without
@@ -582,6 +576,11 @@
</tr>
<tr valign="top">
+ <td nowrap><a href="Tasks/setpermissions.html">SetPermissions</a></td>
+ <td><p>Changes the permissions of a collection of resources.</p></td>
+ </tr>
+
+ <tr valign="top">
<td nowrap><a href="Tasks/sync.html">Sync</a></td>
<td><p>Synchronize two directory trees.</p></td>
</tr>
diff --git a/release/ivy.xml b/release/ivy.xml
index fe9cfd8..c146ea1 100644
--- a/release/ivy.xml
+++ b/release/ivy.xml
@@ -20,7 +20,7 @@
xsi:noNamespaceSchemaLocation=
"http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="org/apache"
- module="ant" revision="1.9.10"/>
+ module="ant" revision="1.10.2"/>
<publications xmlns:e="urn:ant.apache.org:ivy-extras">
<artifact name="ant-parent" type="pom" ext="pom"/>
<artifact name="ant-parent" type="pom.asc" ext="pom.asc"/>
@@ -158,6 +158,12 @@
<artifact name="ant-testutil" type="jar.asc" ext="jar.asc"/>
<artifact name="ant-testutil" type="source" ext="jar" e:classifier="sources" />
<artifact name="ant-testutil" type="source.asc" ext="jar.asc" e:classifier="sources" />
+ <artifact name="ant-xz" type="pom" ext="pom"/>
+ <artifact name="ant-xz" type="pom.asc" ext="pom.asc"/>
+ <artifact name="ant-xz" type="jar" ext="jar"/>
+ <artifact name="ant-xz" type="jar.asc" ext="jar.asc"/>
+ <artifact name="ant-xz" type="source" ext="jar" e:classifier="sources" />
+ <artifact name="ant-xz" type="source.asc" ext="jar.asc" e:classifier="sources" />
</publications>
<dependencies/>
</ivy-module>
diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100644
index 0000000..482880b
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,6 @@
+sonar.projectKey=ant-master
+sonar.projectName=Apache Ant
+sonar.sources=src/main
+sonar.tests=src/tests/junit
+sonar.projectVersion=1.10.0-SNAPSHOT
+sonar.java.source=8
diff --git a/sonarqube.xml b/sonarqube.xml
new file mode 100644
index 0000000..4fae4f7
--- /dev/null
+++ b/sonarqube.xml
@@ -0,0 +1,26 @@
+<project default="sonar" basedir=".">
+
+ <!-- gets overridden by the jenkins job -->
+ <property name="sonar.host.url" value="http://localhost:9000" />
+
+ <!-- source SonarQube project properties -->
+ <property file="sonar-project.properties"/>
+
+ <property name="downloads" location="build/downloads"/>
+ <property name="sonarqube-ant-task-jar" location="${downloads}/sonarqube-ant-task.jar"/>
+ <property name="sonarqube-ant-task-url"
+ value="https://sonarsource.bintray.com/Distribution/sonarqube-ant-task/sonarqube-ant-task-2.5.jar"/>
+
+ <target name="download">
+ <mkdir dir="${downloads}"/>
+ <get dest="${sonarqube-ant-task-jar}" src="${sonarqube-ant-task-url}"/>
+ </target>
+
+ <target name="sonar" depends="download">
+ <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
+ <classpath path="${sonarqube-ant-task-jar}" />
+ </taskdef>
+
+ <sonar:sonar xmlns:sonar="antlib:org.sonar.ant"/>
+ </target>
+</project>
diff --git a/src/etc/poms/ant-antlr/pom.xml b/src/etc/poms/ant-antlr/pom.xml
index 7eb2863..f0b960c 100644
--- a/src/etc/poms/ant-antlr/pom.xml
+++ b/src/etc/poms/ant-antlr/pom.xml
@@ -27,13 +27,13 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-antlr</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + ANTLR</name>
<description>antlr specific task.
The implementation forks a java process, therefore the antlr jar file is only needed at runtime</description>
@@ -41,7 +41,7 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<optional>true</optional>
<scope>compile</scope>
</dependency>
diff --git a/src/etc/poms/ant-apache-bcel/pom.xml b/src/etc/poms/ant-apache-bcel/pom.xml
index c526eab..c27da12 100644
--- a/src/etc/poms/ant-apache-bcel/pom.xml
+++ b/src/etc/poms/ant-apache-bcel/pom.xml
@@ -27,19 +27,19 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-bcel</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + BCEL</name>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-apache-bsf/pom.xml b/src/etc/poms/ant-apache-bsf/pom.xml
index 0975ce4..5fdea3f 100644
--- a/src/etc/poms/ant-apache-bsf/pom.xml
+++ b/src/etc/poms/ant-apache-bsf/pom.xml
@@ -27,19 +27,19 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-bsf</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + BSF</name>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-apache-log4j/pom.xml b/src/etc/poms/ant-apache-log4j/pom.xml
index a0397dc..c689dd0 100644
--- a/src/etc/poms/ant-apache-log4j/pom.xml
+++ b/src/etc/poms/ant-apache-log4j/pom.xml
@@ -26,19 +26,19 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-log4j</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + Log4J</name>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-apache-oro/pom.xml b/src/etc/poms/ant-apache-oro/pom.xml
index cb1a487..0977d80 100644
--- a/src/etc/poms/ant-apache-oro/pom.xml
+++ b/src/etc/poms/ant-apache-oro/pom.xml
@@ -27,19 +27,19 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-oro</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + Apache Oro</name>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-apache-regexp/pom.xml b/src/etc/poms/ant-apache-regexp/pom.xml
index 117d588..6ae1064 100644
--- a/src/etc/poms/ant-apache-regexp/pom.xml
+++ b/src/etc/poms/ant-apache-regexp/pom.xml
@@ -26,19 +26,19 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-regexp</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + Apache Regexp</name>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-apache-resolver/pom.xml b/src/etc/poms/ant-apache-resolver/pom.xml
index 5a3188f..013f098 100644
--- a/src/etc/poms/ant-apache-resolver/pom.xml
+++ b/src/etc/poms/ant-apache-resolver/pom.xml
@@ -26,19 +26,19 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-resolver</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + Apache Resolver</name>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-apache-xalan2/pom.xml b/src/etc/poms/ant-apache-xalan2/pom.xml
index daf124e..81fb681 100644
--- a/src/etc/poms/ant-apache-xalan2/pom.xml
+++ b/src/etc/poms/ant-apache-xalan2/pom.xml
@@ -26,20 +26,20 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-xalan2</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + Xalan 2</name>
<description>contains Xalan2-specific features</description>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-commons-logging/pom.xml b/src/etc/poms/ant-commons-logging/pom.xml
index 5d042a5..0274c03 100644
--- a/src/etc/poms/ant-commons-logging/pom.xml
+++ b/src/etc/poms/ant-commons-logging/pom.xml
@@ -26,20 +26,20 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-commons-logging</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + Commons Logging</name>
<description>Ant Listener based on commons-logging</description>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-commons-net/pom.xml b/src/etc/poms/ant-commons-net/pom.xml
index d03b6ec..b2534cc 100644
--- a/src/etc/poms/ant-commons-net/pom.xml
+++ b/src/etc/poms/ant-commons-net/pom.xml
@@ -26,20 +26,20 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-commons-net</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + Commons Net</name>
<description>ftp, rexec and telnet tasks</description>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-jai/pom.xml b/src/etc/poms/ant-jai/pom.xml
index a156dc3..239f672 100644
--- a/src/etc/poms/ant-jai/pom.xml
+++ b/src/etc/poms/ant-jai/pom.xml
@@ -27,13 +27,13 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jai</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + JAI</name>
<description>image task and corresponding types.
</description>
@@ -41,7 +41,7 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-javamail/pom.xml b/src/etc/poms/ant-javamail/pom.xml
index a080277..21a0304 100644
--- a/src/etc/poms/ant-javamail/pom.xml
+++ b/src/etc/poms/ant-javamail/pom.xml
@@ -26,13 +26,13 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-javamail</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + JavaMail</name>
<description>implementation of the mail task based on javamail.
Required to send emails to SMTP servers using user/password combinations
@@ -41,7 +41,7 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-jdepend/pom.xml b/src/etc/poms/ant-jdepend/pom.xml
index d57b779..bb71997 100644
--- a/src/etc/poms/ant-jdepend/pom.xml
+++ b/src/etc/poms/ant-jdepend/pom.xml
@@ -27,13 +27,13 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jdepend</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + JDepend</name>
<description>task jdepend invoking the jdepend parser. There is also a version 2.9.1 of the
jdepend parser available on the maven repository</description>
@@ -41,7 +41,7 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-jmf/pom.xml b/src/etc/poms/ant-jmf/pom.xml
index eec1dca..d5fcf43 100644
--- a/src/etc/poms/ant-jmf/pom.xml
+++ b/src/etc/poms/ant-jmf/pom.xml
@@ -26,13 +26,13 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jmf</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + JMF</name>
<description>contains the sound task and a soundplayer listener
download the dependency from http://java.sun.com/products/java-media/jmf/</description>
@@ -40,7 +40,7 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
diff --git a/src/etc/poms/ant-jsch/pom.xml b/src/etc/poms/ant-jsch/pom.xml
index 19477b0..b277d57 100644
--- a/src/etc/poms/ant-jsch/pom.xml
+++ b/src/etc/poms/ant-jsch/pom.xml
@@ -26,13 +26,13 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + JSch</name>
<description>contains the sshexec and scp tasks
</description>
@@ -40,7 +40,7 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-junit/pom.xml b/src/etc/poms/ant-junit/pom.xml
index f0b5f80..4e0f9f8 100644
--- a/src/etc/poms/ant-junit/pom.xml
+++ b/src/etc/poms/ant-junit/pom.xml
@@ -26,20 +26,20 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-junit</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + JUnit</name>
<description>contains the junit and junirreport tasks</description>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-junit4/pom.xml b/src/etc/poms/ant-junit4/pom.xml
index 5966cc5..ad55409 100644
--- a/src/etc/poms/ant-junit4/pom.xml
+++ b/src/etc/poms/ant-junit4/pom.xml
@@ -26,20 +26,20 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-junit4</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + JUnit 4</name>
<description>contains JUnit 4.x support</description>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-launcher/pom.xml b/src/etc/poms/ant-launcher/pom.xml
index cb5886a..36e2a6f 100644
--- a/src/etc/poms/ant-launcher/pom.xml
+++ b/src/etc/poms/ant-launcher/pom.xml
@@ -27,13 +27,13 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-launcher</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant Launcher</name>
<build>
<plugins>
diff --git a/src/etc/poms/ant-netrexx/pom.xml b/src/etc/poms/ant-netrexx/pom.xml
index bc5b82d..3c71be0 100644
--- a/src/etc/poms/ant-netrexx/pom.xml
+++ b/src/etc/poms/ant-netrexx/pom.xml
@@ -26,13 +26,13 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-netrexx</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + NetRexx</name>
<description>NetRexxC task
dependency can be downloaded from http://www.ibm.com/software/awdtools/netrexx/download.html</description>
@@ -40,7 +40,7 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- Processed too early, before maven-antrun-plugin gets a chance to work:
diff --git a/src/etc/poms/ant-swing/pom.xml b/src/etc/poms/ant-swing/pom.xml
index 9202675..50c6160 100644
--- a/src/etc/poms/ant-swing/pom.xml
+++ b/src/etc/poms/ant-swing/pom.xml
@@ -27,20 +27,20 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-swing</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant + Swing</name>
<description>a listener and a splash task based on Swing</description>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
diff --git a/src/etc/poms/ant-testutil/pom.xml b/src/etc/poms/ant-testutil/pom.xml
index 3ae9d98..59c73b6 100644
--- a/src/etc/poms/ant-testutil/pom.xml
+++ b/src/etc/poms/ant-testutil/pom.xml
@@ -27,20 +27,20 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-testutil</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant Test Utilities</name>
<description>test utility classes</description>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/src/etc/poms/ant-xz/pom.xml b/src/etc/poms/ant-xz/pom.xml
new file mode 100644
index 0000000..258ed90
--- /dev/null
+++ b/src/etc/poms/ant-xz/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!--
+ This POM has been created manually by the Ant Development Team.
+ Please contact us if you are not satisfied with the data contained in this POM.
+ URL : http://ant.apache.org
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-parent</artifactId>
+ <relativePath>../pom.xml</relativePath>
+ <version>1.10.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <url>http://ant.apache.org/</url>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-xz</artifactId>
+ <version>1.10.2-SNAPSHOT</version>
+ <name>Apache Ant + XZ for Java</name>
+ <description>contains the xz compression support</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.10.2-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.tukaani</groupId>
+ <artifactId>xz</artifactId>
+ <version>1.6</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>org/apache/tools/ant/taskdefs/optional/xz/*</include>
+ <include>org/apache/tools/ant/types/optional/xz/*</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ <sourceDirectory>../../../../src/main</sourceDirectory>
+ <testSourceDirectory>../../../../src/testcases</testSourceDirectory>
+ <outputDirectory>../../../../target/${project.artifactId}/classes</outputDirectory>
+ <testOutputDirectory>../../../../target/${project.artifactId}/testcases</testOutputDirectory>
+ <directory>../../../../target/${project.artifactId}</directory>
+ </build>
+</project>
diff --git a/src/etc/poms/ant/pom.xml b/src/etc/poms/ant/pom.xml
index 8a7b8ec..755d0c8 100644
--- a/src/etc/poms/ant/pom.xml
+++ b/src/etc/poms/ant/pom.xml
@@ -27,19 +27,19 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<name>Apache Ant Core</name>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-launcher</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -98,46 +98,48 @@
<configuration>
<excludes>
<exclude>org/apache/tools/ant/filters/util/JavaClassHelper*</exclude>
- <exclude>org/apache/tools/ant/types/resolver/**</exclude>
- <exclude>org/apache/tools/ant/listener/Log4jListener*</exclude>
- <exclude>org/apache/tools/ant/listener/CommonsLoggingListener*</exclude>
- <exclude>org/apache/tools/ant/util/regexp/JakartaRegexp*</exclude>
- <exclude>org/apache/tools/ant/util/regexp/JakartaOro*</exclude>
- <exclude>org/apache/tools/ant/taskdefs/email/MimeMailer*</exclude>
+ <exclude>org/apache/tools/ant/filters/util/JavaClassHelper*</exclude>
<exclude>org/apache/tools/ant/launch/**</exclude>
+ <exclude>org/apache/tools/ant/listener/CommonsLoggingListener*</exclude>
+ <exclude>org/apache/tools/ant/listener/Log4jListener*</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/email/MimeMailer*</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/optional/NetRexxC*</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/optional/Script*</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/optional/Xalan2TraceSupport*</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/optional/image/*</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/optional/jdepend/*</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/optional/junit/*</exclude>
<exclude>org/apache/tools/ant/taskdefs/optional/net/FTP*</exclude>
<exclude>org/apache/tools/ant/taskdefs/optional/net/RExec*</exclude>
<exclude>org/apache/tools/ant/taskdefs/optional/net/TelnetTask*</exclude>
- <exclude>org/apache/tools/ant/taskdefs/optional/junit/*</exclude>
- <exclude>org/apache/tools/ant/taskdefs/optional/ssh/*</exclude>
- <exclude>org/apache/tools/ant/taskdefs/optional/image/*</exclude>
- <exclude>org/apache/tools/ant/types/optional/image/*</exclude>
- <exclude>org/apache/tools/ant/taskdefs/optional/Script*</exclude>
<exclude>org/apache/tools/ant/taskdefs/optional/script/**</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/optional/ssh/*</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/optional/xz/*</exclude>
<exclude>org/apache/tools/ant/types/optional/*Script*</exclude>
+ <exclude>org/apache/tools/ant/types/optional/image/*</exclude>
+ <exclude>org/apache/tools/ant/types/optional/xz/*</exclude>
+ <exclude>org/apache/tools/ant/types/resolver/**</exclude>
<exclude>org/apache/tools/ant/util/ScriptRunner.java</exclude>
- <exclude>org/apache/tools/ant/util/optional/ScriptRunner.java</exclude>
- <exclude>org/apache/tools/ant/filters/util/JavaClassHelper*</exclude>
<exclude>org/apache/tools/ant/util/depend/bcel/*</exclude>
- <exclude>org/apache/tools/ant/taskdefs/optional/NetRexxC*</exclude>
- <exclude>org/apache/tools/ant/taskdefs/optional/Xalan2TraceSupport*</exclude>
- <exclude>org/apache/tools/ant/taskdefs/optional/jdepend/*</exclude>
+ <exclude>org/apache/tools/ant/util/optional/ScriptRunner.java</exclude>
+ <exclude>org/apache/tools/ant/util/regexp/JakartaOro*</exclude>
+ <exclude>org/apache/tools/ant/util/regexp/JakartaRegexp*</exclude>
</excludes>
<testExcludes>
<exclude>org/apache/tools/ant/filters/util/JavaClassHelper*</exclude>
- <exclude>org/apache/tools/ant/types/resolver/**</exclude>
- <exclude>org/apache/tools/ant/util/Script*</exclude>
- <exclude>org/apache/tools/ant/listener/Log4jListener*</exclude>
- <exclude>org/apache/tools/ant/listener/CommonsLoggingListener*</exclude>
- <exclude>org/apache/tools/ant/util/regexp/JakartaRegexp*</exclude>
- <exclude>org/apache/tools/ant/util/regexp/JakartaOro*</exclude>
- <exclude>org/apache/tools/ant/util/regexp/Jdk14Regexp*</exclude>
- <exclude>org/apache/tools/ant/taskdefs/email/MimeMailer*</exclude>
<exclude>org/apache/tools/ant/launch/**</exclude>
+ <exclude>org/apache/tools/ant/listener/CommonsLoggingListener*</exclude>
+ <exclude>org/apache/tools/ant/listener/Log4jListener*</exclude>
<exclude>org/apache/tools/ant/taskdefs/StyleTest*</exclude>
+ <exclude>org/apache/tools/ant/taskdefs/email/MimeMailer*</exclude>
<exclude>org/apache/tools/ant/taskdefs/optional/junit/</exclude>
<exclude>org/apache/tools/ant/taskdefs/optional/net/FTP*</exclude>
<exclude>org/apache/tools/ant/taskdefs/optional/ssh/*</exclude>
+ <exclude>org/apache/tools/ant/types/resolver/**</exclude>
+ <exclude>org/apache/tools/ant/util/Script*</exclude>
+ <exclude>org/apache/tools/ant/util/regexp/JakartaOro*</exclude>
+ <exclude>org/apache/tools/ant/util/regexp/JakartaRegexp*</exclude>
+ <exclude>org/apache/tools/ant/util/regexp/Jdk14Regexp*</exclude>
</testExcludes>
</configuration>
</plugin>
diff --git a/src/etc/poms/pom.xml b/src/etc/poms/pom.xml
index bbb0ddb..5d48b1a 100644
--- a/src/etc/poms/pom.xml
+++ b/src/etc/poms/pom.xml
@@ -25,7 +25,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
- <version>1.9.10-SNAPSHOT</version>
+ <version>1.10.2-SNAPSHOT</version>
<packaging>pom</packaging>
<description>master POM</description>
<licenses>
@@ -102,6 +102,7 @@
<module>ant-netrexx</module>
<module>ant-swing</module>
<module>ant-testutil</module>
+ <module>ant-xz</module>
</modules>
<dependencies>
<dependency>
@@ -123,8 +124,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.8</source>
+ <target>1.8</target>
</configuration>
</plugin>
<plugin>
diff --git a/src/etc/testcases/core/antclassloader.xml b/src/etc/testcases/core/antclassloader.xml
index cafc823..045428d 100644
--- a/src/etc/testcases/core/antclassloader.xml
+++ b/src/etc/testcases/core/antclassloader.xml
@@ -56,11 +56,7 @@
package org.example;
public class Foo {}
]]></echo>
- <available property="jdk1.6+" classname="java.net.CookieStore"/>
- <condition property="source" value="6">
- <isset property="jdk1.6+"/>
- </condition>
- <property name="source" value="1.4"/>
+ <property name="source" value="8"/>
<javac srcdir="${tmp.dir.nonascii}"
destdir="${tmp.dir.nonascii}" source="${source}"/>
<tempfile property="test.jar" destdir="${tmp.dir}" suffix="test" prefix=".jar" deleteonexit="true"/>
diff --git a/src/etc/testcases/taskdefs/conditions/antversion.xml b/src/etc/testcases/taskdefs/conditions/antversion.xml
index ae274c8..f4d2e7e 100644
--- a/src/etc/testcases/taskdefs/conditions/antversion.xml
+++ b/src/etc/testcases/taskdefs/conditions/antversion.xml
@@ -32,11 +32,10 @@
<fail>
<condition>
<not>
- <antversion exactly="1.9.10" />
+ <antversion exactly="1.10.2" />
</not>
</condition>
- Should be exactly 1.9.10
-
+ Should be exactly 1.10.2
</fail>
</target>
@@ -45,10 +44,10 @@
<fail>
<condition>
<not>
- <antversion atleast="1.9.10" />
+ <antversion atleast="1.9.8" />
</not>
</condition>
- Should be at least 1.9.10
+ Should be at least 1.9.8
</fail>
</target>
@@ -57,10 +56,10 @@
<fail>
<condition>
<not>
- <antversion exactly="1.9.10" />
+ <antversion exactly="1.9.8" />
</not>
</condition>
- Should be exactly 1.9.10
+ Should be exactly 1.9.8
</fail>
</target>
</project>
diff --git a/src/etc/testcases/taskdefs/expected/asf-logo.gif.xz b/src/etc/testcases/taskdefs/expected/asf-logo.gif.xz
new file mode 100644
index 0000000..139eea4
--- /dev/null
+++ b/src/etc/testcases/taskdefs/expected/asf-logo.gif.xz
Binary files differ
diff --git a/src/etc/testcases/taskdefs/get.xml b/src/etc/testcases/taskdefs/get.xml
index b74e92a..188febd 100644
--- a/src/etc/testcases/taskdefs/get.xml
+++ b/src/etc/testcases/taskdefs/get.xml
@@ -98,6 +98,34 @@
</fail>
</target>
+ <target name="testTwoHeadersAreAddedOK">
+ <get src="http://www.apache.org/" dest="get.tmp">
+ <header name="header1" value="header1Value"/>
+ <header name="header2" value="header2Value"/>
+ </get>
+ </target>
+
+ <target name="testEmptyHeadersAreNeverAdded">
+ <get src="http://www.apache.org/" dest="get.tmp">
+ <header name="" value="headerValue"/>
+ <header name="header2" value=""/>
+ </get>
+ </target>
+
+ <target name="testThatWhenMoreThanOneHeaderHaveSameNameOnlyLastOneIsAdded">
+ <get src="http://www.apache.org/" dest="get.tmp">
+ <header name="header1" value="headerValue1"/>
+ <header name="header1" value="headerValue2"/>
+ <header name="header1" value="headerValue3"/>
+ </get>
+ </target>
+
+ <target name="testHeaderSpaceTrimmed">
+ <get src="http://www.apache.org/" dest="get.tmp">
+ <header name=" header1 " value=" headerValue1 "/>
+ </get>
+ </target>
+
<target name="cleanup">
<delete>
<fileset dir="${basedir}" includes="get.tmp" />
diff --git a/src/etc/testcases/taskdefs/optional/junit.xml b/src/etc/testcases/taskdefs/optional/junit.xml
index cc66e20..314ba87 100644
--- a/src/etc/testcases/taskdefs/optional/junit.xml
+++ b/src/etc/testcases/taskdefs/optional/junit.xml
@@ -339,11 +339,7 @@
public void bad() {
throw new RuntimeException("failed");}
}</echo>
- <available property="jdk1.6+" classname="java.net.CookieStore"/>
- <condition property="source" value="6">
- <isset property="jdk1.6+"/>
- </condition>
- <property name="source" value="5"/>
+ <property name="source" value="8"/>
<javac srcdir="${tmp.dir}" destdir="${tmp.dir}" includes="T1.java,T2.java"
source="${source}">
diff --git a/src/etc/testcases/taskdefs/optional/script.xml b/src/etc/testcases/taskdefs/optional/script.xml
index 841f70d..c098289 100644
--- a/src/etc/testcases/taskdefs/optional/script.xml
+++ b/src/etc/testcases/taskdefs/optional/script.xml
@@ -17,6 +17,10 @@
-->
<project name="testproject" default="def" basedir=".">
+ <import file="../../buildfiletest-base.xml"/>
+
+ <property name="root" location="../../../../.."/>
+
<target name="def">
<fail>This build-file is intended to be run from the test cases</fail>
</target>
@@ -43,4 +47,22 @@
]]></script>
</target>
+ <target name="useSrcAndEncoding">
+ <mkdir dir="${output}" />
+ <property name="useSrcAndEncoding.encoding" value="UTF-8"/>
+ <property name="useSrcAndEncoding.reader.encoding" value="${useSrcAndEncoding.encoding}"
+ description="Set a different encoding to raise a failure (ex. ISO-8859-1)" />
+ <property name="useSrcAndEncoding.file" location="${output}/script.useSrcAndEncoding.js"/>
+ <property name="useSrcAndEncoding.expectedProp" value="eacute [é]" />
+
+ <echo file="${useSrcAndEncoding.file}" encoding="${useSrcAndEncoding.encoding}"
+ message="project.setNewProperty('useSrcAndEncoding.prop', '${useSrcAndEncoding.expectedProp}');"/>
+
+ <script language="javascript" src="${useSrcAndEncoding.file}" encoding="${useSrcAndEncoding.reader.encoding}"/>
+ <condition property="useSrcAndEncoding.testOK" >
+ <equals arg1="${useSrcAndEncoding.expectedProp}" arg2="${useSrcAndEncoding.prop}" />
+ </condition>
+ <fail message="expected <${useSrcAndEncoding.expectedProp}> but was <${useSrcAndEncoding.prop}>" unless="useSrcAndEncoding.testOK" />
+ </target>
+
</project>
\ No newline at end of file
diff --git a/src/etc/testcases/taskdefs/optional/script/heavy-script.js b/src/etc/testcases/taskdefs/optional/script/heavy-script.js
new file mode 100644
index 0000000..63c166d
--- /dev/null
+++ b/src/etc/testcases/taskdefs/optional/script/heavy-script.js
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ *
+ */
+
+var functions = [
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },function (value) { return value; },
+];
+
+var v = 'a';
+for(var i in functions) {
+ v = functions[i](v);
+}
+
+var echo = project.createTask("echo");
+echo.setMessage("heavy-script done");
+echo.perform();
diff --git a/src/etc/testcases/taskdefs/optional/script/scriptdef.xml b/src/etc/testcases/taskdefs/optional/script/scriptdef.xml
index 0d051ea..3b54e3e 100644
--- a/src/etc/testcases/taskdefs/optional/script/scriptdef.xml
+++ b/src/etc/testcases/taskdefs/optional/script/scriptdef.xml
@@ -17,6 +17,10 @@
-->
<project name="testproject" default="def" basedir=".">
+ <import file="../../../buildfiletest-base.xml"/>
+
+ <property name="root" location="../../../../../.."/>
+
<target name="def">
<fail>This build-file is intended to be run from the test cases</fail>
</target>
@@ -141,5 +145,85 @@
</scripttest>
</target>
+ <target name="useBeanshell">
+ <script language="beanshell"><![CDATA[
+ self.log("I'm here", org.apache.tools.ant.Project.MSG_INFO);
+ ]]></script>
+ </target>
+
+ <target name="useSrcAndEncoding">
+ <mkdir dir="${output}" />
+ <property name="useSrcAndEncoding.encoding" value="UTF-8"/>
+ <property name="useSrcAndEncoding.reader.encoding" value="${useSrcAndEncoding.encoding}"
+ description="Set a different encoding to raise a failure (ex. ISO-8859-1)" />
+ <property name="useSrcAndEncoding.file" location="${output}/script.useSrcAndEncoding.js"/>
+ <property name="useSrcAndEncoding.expectedProp" value="eacute [é]" />
+
+ <echo file="${useSrcAndEncoding.file}" encoding="${useSrcAndEncoding.encoding}"
+ message="project.setNewProperty('useSrcAndEncoding.prop', '${useSrcAndEncoding.expectedProp}');"/>
+
+ <scriptdef name="useSrcAndEncoding" language="javascript" src="${useSrcAndEncoding.file}" encoding="${useSrcAndEncoding.reader.encoding}"/>
+ <useSrcAndEncoding/>
+
+ <condition property="useSrcAndEncoding.testOK" >
+ <equals arg1="${useSrcAndEncoding.expectedProp}" arg2="${useSrcAndEncoding.prop}" />
+ </condition>
+ <fail message="expected <${useSrcAndEncoding.expectedProp}> but was <${useSrcAndEncoding.prop}>" unless="useSrcAndEncoding.testOK" />
+ </target>
+
+ <target name="useCompiled">
+
+ <!-- Test with 'javax' manager, 'bsf' manager already compiles the script. -->
+ <scriptdef manager="javax" name="heavyscript" language="javascript" src="heavy-script.js" encoding="UTF-8" compiled="true" />
+
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+ <heavyscript />
+
+ </target>
+
+ <target name="useNotCompiled">
+
+ <scriptdef manager="javax" name="heavyscriptNotCompiled" language="javascript" src="heavy-script.js" encoding="UTF-8" compiled="false" />
+
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+ <heavyscriptNotCompiled />
+
+ </target>
</project>
diff --git a/src/etc/testcases/taskdefs/rmic/rmic.xml b/src/etc/testcases/taskdefs/rmic/rmic.xml
index 4670f43..1ef900d 100644
--- a/src/etc/testcases/taskdefs/rmic/rmic.xml
+++ b/src/etc/testcases/taskdefs/rmic/rmic.xml
@@ -212,12 +212,6 @@
</condition>
<property name="rmic.compiler" value="sun"/>
<available property="wlrmic.present" classname="weblogic.rmic"/>
- <condition property="rmic6.present">
- <and>
- <isset property="rmic.present"/>
- <available classname="java.util.ServiceLoader"/>
- </and>
- </condition>
</target>
<target name="testDefault" depends="init">
@@ -435,23 +429,6 @@
<assertBaseCompiled/>
</target>
- <!--
- This test stamps on the XML parser settings on java6, so it is disabled.
- -->
- <target name="testXnew" if="rmic.present" unless="rmic6.present" depends="init">
- <base-rmic compiler="${rmic.compiler}">
- <compilerarg value="-Xnew"/>
- </base-rmic>
- <assertBaseCompiled/>
- </target>
-
- <target name="testXnewDest" if="rmic.present" unless="rmic6.present" depends="init">
- <dest-rmic compiler="${rmic.compiler}">
- <compilerarg value="-Xnew"/>
- </dest-rmic>
- <assertBaseCompiledInDest/>
- </target>
-
<target name="testXnewForked" if="rmic.present" depends="init">
<base-rmic compiler="forking">
<compilerarg value="-Xnew"/>
diff --git a/src/etc/testcases/types/assertions.xml b/src/etc/testcases/types/assertions.xml
index dee7ce7..a849a0b 100644
--- a/src/etc/testcases/types/assertions.xml
+++ b/src/etc/testcases/types/assertions.xml
@@ -21,11 +21,7 @@
<import file="../buildfiletest-base.xml"/>
<target name="setUp">
- <available property="jdk1.6+" classname="java.net.CookieStore"/>
- <condition property="source" value="6">
- <isset property="jdk1.6+"/>
- </condition>
- <property name="source" value="1.4"/>
+ <property name="source" value="8"/>
<mkdir dir="${output}"/>
<javac srcdir="${src.dir}"
includes="*.java"
diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java
index 9fa9eae..f4ee2b0 100644
--- a/src/main/org/apache/tools/ant/AntClassLoader.java
+++ b/src/main/org/apache/tools/ant/AntClassLoader.java
@@ -74,6 +74,10 @@
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
+ static {
+ registerAsParallelCapable();
+ }
+
/**
* An enumeration of all resources of a given name found within the
* classpath of this class loader. This enumeration is used by the
@@ -493,19 +497,13 @@
+ pathComponent.lastModified() + "-" + pathComponent.length();
String classpath = pathMap.get(absPathPlusTimeAndLength);
if (classpath == null) {
- JarFile jarFile = null;
- try {
- jarFile = new JarFile(pathComponent);
+ try (JarFile jarFile = new JarFile(pathComponent)) {
final Manifest manifest = jarFile.getManifest();
if (manifest == null) {
return;
}
classpath = manifest.getMainAttributes()
.getValue(Attributes.Name.CLASS_PATH);
- } finally {
- if (jarFile != null) {
- jarFile.close();
- }
}
if (classpath == null) {
classpath = "";
@@ -1411,12 +1409,7 @@
*/
public synchronized void cleanup() {
for (final Enumeration<JarFile> e = jarFiles.elements(); e.hasMoreElements();) {
- final JarFile jarFile = e.nextElement();
- try {
- jarFile.close();
- } catch (final IOException ioe) {
- // ignore
- }
+ FileUtils.close(e.nextElement());
}
jarFiles = new Hashtable<File, JarFile>();
if (project != null) {
@@ -1586,8 +1579,7 @@
}
private static boolean readFully(final File f, final byte[] b) throws IOException {
- final FileInputStream fis = new FileInputStream(f);
- try {
+ try (FileInputStream fis = new FileInputStream(f)) {
final int len = b.length;
int count = 0, x = 0;
while (count != len) {
@@ -1598,8 +1590,6 @@
count += x;
}
return count == len;
- } finally {
- fis.close();
}
}
diff --git a/src/main/org/apache/tools/ant/Diagnostics.java b/src/main/org/apache/tools/ant/Diagnostics.java
index 4ad57a0..9cd1f81 100644
--- a/src/main/org/apache/tools/ant/Diagnostics.java
+++ b/src/main/org/apache/tools/ant/Diagnostics.java
@@ -42,6 +42,7 @@
import org.apache.tools.ant.util.JAXPUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
import org.apache.tools.ant.util.ProxySetup;
+import org.apache.tools.ant.util.java15.ProxyDiagnostics;
import org.xml.sax.XMLReader;
/**
@@ -691,25 +692,10 @@
printProperty(out, ProxySetup.SOCKS_PROXY_USERNAME);
printProperty(out, ProxySetup.SOCKS_PROXY_PASSWORD);
- if (JavaEnvUtils.getJavaVersionNumber() < JAVA_1_5_NUMBER) {
- return;
- }
printProperty(out, ProxySetup.USE_SYSTEM_PROXIES);
- final String proxyDiagClassname = "org.apache.tools.ant.util.java15.ProxyDiagnostics";
- try {
- Class<?> proxyDiagClass = Class.forName(proxyDiagClassname);
- Object instance = proxyDiagClass.newInstance();
- out.println("Java1.5+ proxy settings:");
- out.println(instance.toString());
- } catch (ClassNotFoundException e) {
- //not included, do nothing
- } catch (IllegalAccessException e) {
- //not included, do nothing
- } catch (InstantiationException e) {
- //not included, do nothing
- } catch (NoClassDefFoundError e) {
- // not included, to nothing
- }
+ ProxyDiagnostics proxyDiag = new ProxyDiagnostics();
+ out.println("Java1.5+ proxy settings:");
+ out.println(proxyDiag.toString());
}
}
diff --git a/src/main/org/apache/tools/ant/MagicNames.java b/src/main/org/apache/tools/ant/MagicNames.java
index bc39a25..336c3bc 100644
--- a/src/main/org/apache/tools/ant/MagicNames.java
+++ b/src/main/org/apache/tools/ant/MagicNames.java
@@ -56,6 +56,12 @@
public static final String SCRIPT_REPOSITORY = "org.apache.ant.scriptrepo";
/**
+ * The name of the script cache used by the script runner.
+ * Value {@value}
+ */
+ public static final String SCRIPT_CACHE = "org.apache.ant.scriptcache";
+
+ /**
* The name of the reference to the System Class Loader.
* Value {@value}
**/
diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java
index 34dddb2..17f2467 100644
--- a/src/main/org/apache/tools/ant/Project.java
+++ b/src/main/org/apache/tools/ant/Project.java
@@ -930,8 +930,8 @@
setPropertyInternal(MagicNames.ANT_JAVA_VERSION, javaVersion);
// sanity check
- if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_5)) {
- throw new BuildException("Ant cannot work on Java prior to 1.5");
+ if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_8)) {
+ throw new BuildException("Ant cannot work on Java prior to 1.8");
}
log("Detected Java version: " + javaVersion + " in: "
+ System.getProperty("java.home"), MSG_VERBOSE);
diff --git a/src/main/org/apache/tools/ant/filters/Native2AsciiFilter.java b/src/main/org/apache/tools/ant/filters/Native2AsciiFilter.java
index 2e764ae..5631534 100644
--- a/src/main/org/apache/tools/ant/filters/Native2AsciiFilter.java
+++ b/src/main/org/apache/tools/ant/filters/Native2AsciiFilter.java
@@ -39,6 +39,7 @@
this.reverse = reverse;
}
+ @Override
public String filter(String line) {
return reverse
? Native2AsciiUtils.ascii2native(line)
diff --git a/src/main/org/apache/tools/ant/launch/Locator.java b/src/main/org/apache/tools/ant/launch/Locator.java
index 4640e70..2e8c37d 100644
--- a/src/main/org/apache/tools/ant/launch/Locator.java
+++ b/src/main/org/apache/tools/ant/launch/Locator.java
@@ -23,6 +23,7 @@
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.Locale;
@@ -59,10 +60,6 @@
private static final int SPACE = 0x20;
private static final int DEL = 0x7F;
- /**
- * encoding used to represent URIs
- */
- public static final String URI_ENCODING = "UTF-8";
// stolen from org.apache.xerces.impl.XMLEntityManager#getUserDir()
// of the Xerces-J team
// which ASCII characters need to be escaped
@@ -315,11 +312,11 @@
} else if (c >= 0x0000 && c < 0x0080) {
sb.write(c);
} else { // #50543
- byte[] bytes = String.valueOf(c).getBytes(URI_ENCODING);
+ byte[] bytes = String.valueOf(c).getBytes(StandardCharsets.UTF_8);
sb.write(bytes, 0, bytes.length);
}
}
- return sb.toString(URI_ENCODING);
+ return sb.toString(StandardCharsets.UTF_8.name());
}
/**
@@ -327,10 +324,9 @@
* The URI is escaped
* @param path String to encode.
* @return The encoded string, according to URI norms
- * @throws UnsupportedEncodingException if UTF-8 is not available
* @since Ant 1.7
*/
- public static String encodeURI(String path) throws UnsupportedEncodingException {
+ public static String encodeURI(String path) {
int i = 0;
int len = path.length();
int ch = 0;
@@ -362,7 +358,7 @@
// get UTF-8 bytes for the remaining sub-string
byte[] bytes = null;
byte b;
- bytes = path.substring(i).getBytes(URI_ENCODING);
+ bytes = path.substring(i).getBytes(StandardCharsets.UTF_8);
len = bytes.length;
// for each byte
diff --git a/src/main/org/apache/tools/ant/loader/AntClassLoader2.java b/src/main/org/apache/tools/ant/loader/AntClassLoader2.java
index 1a4cac6..4838b0d 100644
--- a/src/main/org/apache/tools/ant/loader/AntClassLoader2.java
+++ b/src/main/org/apache/tools/ant/loader/AntClassLoader2.java
@@ -25,6 +25,10 @@
* Just use {@link AntClassLoader} itself.
*/
public class AntClassLoader2 extends AntClassLoader {
+ static {
+ registerAsParallelCapable();
+ }
+
/** No args constructor. */
public AntClassLoader2() {
}
diff --git a/src/main/org/apache/tools/ant/loader/AntClassLoader5.java b/src/main/org/apache/tools/ant/loader/AntClassLoader5.java
index 15c29df..873e48a 100644
--- a/src/main/org/apache/tools/ant/loader/AntClassLoader5.java
+++ b/src/main/org/apache/tools/ant/loader/AntClassLoader5.java
@@ -27,6 +27,10 @@
* Just use {@link AntClassLoader} itself.
*/
public class AntClassLoader5 extends AntClassLoader {
+ static {
+ registerAsParallelCapable();
+ }
+
/**
* Creates a classloader for the given project using the classpath given.
*
diff --git a/src/main/org/apache/tools/ant/taskdefs/Apt.java b/src/main/org/apache/tools/ant/taskdefs/Apt.java
deleted file mode 100644
index 52154a8..0000000
--- a/src/main/org/apache/tools/ant/taskdefs/Apt.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * 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;
-
-import java.io.File;
-import java.util.Vector;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.compilers.AptExternalCompilerAdapter;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Reference;
-import org.apache.tools.ant.util.JavaEnvUtils;
-
-/**
- * Apt Task for running the Annotation processing tool for JDK 1.5. It derives
- * from the existing Javac task, and forces the compiler based on whether we're
- * executing internally, or externally.
- *
- * @since Ant 1.7
- */
-
-
-public class Apt
- extends Javac {
- private boolean compile = true;
- private String factory;
- private Path factoryPath;
- private Vector<Option> options = new Vector<Option>();
- private File preprocessDir;
- /** The name of the apt tool. */
- public static final String EXECUTABLE_NAME = "apt";
- /** An warning message when ignoring compiler attribute. */
- public static final String ERROR_IGNORING_COMPILER_OPTION
- = "Ignoring compiler attribute for the APT task, as it is fixed";
- /** A warning message if used with java < 1.5. */
- public static final String ERROR_WRONG_JAVA_VERSION
- = "Apt task requires Java 1.5+";
-
- /**
- * exposed for debug messages
- */
- public static final String WARNING_IGNORING_FORK =
- "Apt only runs in its own JVM; fork=false option ignored";
-
- /**
- * The nested option element.
- */
- public static final class Option {
- private String name;
- private String value;
-
- /** Constructor for Option */
- public Option() {
- //default
- }
-
- /**
- * Get the name attribute.
- * @return the name attribute.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Set the name attribute.
- * @param name the name of the option.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Get the value attribute.
- * @return the value attribute.
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Set the value attribute.
- * @param value the value of the option.
- */
- public void setValue(String value) {
- this.value = value;
- }
- }
-
- /**
- * Constructor for Apt task.
- * This sets the apt compiler adapter as the compiler in the super class.
- */
- public Apt() {
- super();
- super.setCompiler(AptExternalCompilerAdapter.class.getName());
- super.setFork(true);
- }
-
- /**
- * Get the name of the apt executable.
- *
- * @return the name of the executable.
- */
- public String getAptExecutable() {
- String exe = getExecutable();
- return exe != null ? exe :
- JavaEnvUtils.getJdkExecutable(EXECUTABLE_NAME);
- }
-
- /**
- * Set the compiler.
- * This is not allowed and a warning log message is made.
- * @param compiler not used.
- */
- public void setCompiler(String compiler) {
- log(ERROR_IGNORING_COMPILER_OPTION, Project.MSG_WARN);
- }
-
- /**
- * Set the fork attribute.
- * Non-forking APT is highly classpath dependent and appears to be too
- * brittle to work. The sole reason this attribute is retained
- * is the superclass does it
- * @param fork if false; warn the option is ignored.
- */
- public void setFork(boolean fork) {
- if (!fork) {
- log(WARNING_IGNORING_FORK, Project.MSG_WARN);
- }
- }
-
- /**
- * Get the compiler class name.
- * @return the compiler class name.
- */
- public String getCompiler() {
- return super.getCompiler();
- }
-
- /**
- * Get the compile option for the apt compiler.
- * If this is false the "-nocompile" argument will be used.
- * @return the value of the compile option.
- */
- public boolean isCompile() {
- return compile;
- }
-
- /**
- * Set the compile option for the apt compiler.
- * Default value is true.
- * @param compile if true set the compile option.
- */
- public void setCompile(boolean compile) {
- this.compile = compile;
- }
-
- /**
- * Get the factory option for the apt compiler.
- * If this is non-null the "-factory" argument will be used.
- * @return the value of the factory option.
- */
- public String getFactory() {
- return factory;
- }
-
- /**
- * Set the factory option for the apt compiler.
- * Default value is null.
- * @param factory the classname of the factory.
- */
- public void setFactory(String factory) {
- this.factory = factory;
- }
-
- /**
- * Add a reference to a path to the factoryPath attribute.
- * @param ref a reference to a path.
- */
- public void setFactoryPathRef(Reference ref) {
- createFactoryPath().setRefid(ref);
- }
-
- /**
- * Add a path to the factoryPath attribute.
- * @return a path to be configured.
- */
- public Path createFactoryPath() {
- if (factoryPath == null) {
- factoryPath = new Path(getProject());
- }
- return factoryPath.createPath();
- }
-
- /**
- * Get the factory path attribute.
- * If this is not null, the "-factorypath" argument will be used.
- * The default value is null.
- * @return the factory path attribute.
- */
- public Path getFactoryPath() {
- return factoryPath;
- }
-
- /**
- * Create a nested option.
- * @return an option to be configured.
- */
- public Option createOption() {
- Option opt = new Option();
- options.add(opt);
- return opt;
- }
-
- /**
- * Get the options to the compiler.
- * Each option will use '"-E" name ["=" value]' argument.
- * @return the options.
- */
- public Vector<Option> getOptions() {
- return options;
- }
-
- /**
- * Get the preprocessdir attribute.
- * This corresponds to the "-s" argument.
- * The default value is null.
- * @return the preprocessdir attribute.
- */
- public File getPreprocessDir() {
- return preprocessDir;
- }
-
- /**
- * Set the preprocessdir attribute.
- * @param preprocessDir where to place processor generated source files.
- */
- public void setPreprocessDir(File preprocessDir) {
- this.preprocessDir = preprocessDir;
- }
-
- /**
- * Do the compilation.
- * @throws BuildException on error.
- */
- public void execute()
- throws BuildException {
- if (JavaEnvUtils.getJavaVersionNumber() >= 18) {
- throw new BuildException("apt does not exist under Java 1.8 and higher");
- }
- super.execute();
- }
-}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java
index 83f3b6b..674a535 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Get.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Get.java
@@ -36,6 +36,7 @@
import org.apache.tools.ant.Main;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.email.Header;
import org.apache.tools.ant.types.Mapper;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection;
@@ -44,6 +45,10 @@
import org.apache.tools.ant.types.resources.URLResource;
import org.apache.tools.ant.util.FileNameMapper;
import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.StringUtils;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
/**
* Gets a particular file from a URL source.
@@ -90,6 +95,9 @@
DEFAULT_AGENT_PREFIX + "/"
+ Main.getShortAntVersion());
+ // Store headers as key/value pair without duplicate in keyz
+ private Map<String, String> headers = new LinkedHashMap<String, String>();
+
/**
* Does the work.
*
@@ -483,6 +491,21 @@
}
/**
+ * Add a nested header
+ * @param header to be added
+ *
+ */
+ public void addConfiguredHeader(Header header) {
+ if (header != null) {
+ String key = StringUtils.trimToNull(header.getName());
+ String value = StringUtils.trimToNull(header.getValue());
+ if (key != null && value != null) {
+ this.headers.put(key, value);
+ }
+ }
+ }
+
+ /**
* Define the mapper to map source to destination files.
* @return a mapper to be configured.
* @exception BuildException if more than one mapper is defined.
@@ -726,6 +749,14 @@
connection.setRequestProperty("Accept-Encoding", GZIP_CONTENT_ENCODING);
}
+
+ for (final Map.Entry<String, String> header : headers.entrySet()) {
+ //we do not log the header value as it may contain sensitive data like passwords
+ log(String.format("Adding header '%s' ", header.getKey()));
+ connection.setRequestProperty(header.getKey(), header.getValue());
+ }
+
+
if (connection instanceof HttpURLConnection) {
((HttpURLConnection) connection)
.setInstanceFollowRedirects(false);
diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java
index 330b5dd..bea5e86 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Jar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java
@@ -349,13 +349,7 @@
}
return null;
} finally {
- if (zf != null) {
- try {
- zf.close();
- } catch (IOException e) {
- // TODO - log an error? throw an exception?
- }
- }
+ FileUtils.close(zf);
}
}
@@ -388,13 +382,7 @@
}
return false;
} finally {
- if (zf != null) {
- try {
- zf.close();
- } catch (IOException e) {
- // TODO - log an error? throw an exception?
- }
- }
+ FileUtils.close(zf);
}
}
@@ -1143,9 +1131,7 @@
protected static void grabFilesAndDirs(String file, List<String> dirs,
List<String> files)
throws IOException {
- org.apache.tools.zip.ZipFile zf = null;
- try {
- zf = new org.apache.tools.zip.ZipFile(file, "utf-8");
+ try (org.apache.tools.zip.ZipFile zf = new org.apache.tools.zip.ZipFile(file, "utf-8")) {
Enumeration<org.apache.tools.zip.ZipEntry> entries = zf.getEntries();
HashSet<String> dirSet = new HashSet<String>();
while (entries.hasMoreElements()) {
@@ -1165,10 +1151,6 @@
}
}
dirs.addAll(dirSet);
- } finally {
- if (zf != null) {
- zf.close();
- }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java
index 23c19dd..b7f1bbc 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
@@ -1471,8 +1471,7 @@
continue;
}
log("Creating empty " + pkgInfoClass);
- final OutputStream os = new FileOutputStream(pkgInfoClass);
- try {
+ try (OutputStream os = new FileOutputStream(pkgInfoClass)) {
os.write(PACKAGE_INFO_CLASS_HEADER);
final byte[] name = pkg.getBytes("UTF-8");
final int length = name.length + /* "/package-info" */ 13;
@@ -1480,8 +1479,6 @@
os.write((byte) length % 256);
os.write(name);
os.write(PACKAGE_INFO_CLASS_FOOTER);
- } finally {
- os.close();
}
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java b/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java
index ed16cf3..bc69c06 100644
--- a/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java
+++ b/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java
@@ -23,6 +23,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.util.FileUtils;
/**
* Logs standard output and error of a subprocess to the log system of ant.
@@ -59,12 +60,7 @@
*/
public void stop() {
super.stop();
- try {
- getErr().close();
- getOut().close();
- } catch (IOException e) {
- // plain impossible
- throw new BuildException(e);
- }
+ FileUtils.close(getErr());
+ FileUtils.close(getOut());
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java b/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java
index 4a4f231..f605bd5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java
@@ -115,11 +115,8 @@
if (pathEntry.isDirectory() && !relPath.endsWith("/")) {
relPath = relPath + '/';
}
- try {
- relPath = Locator.encodeURI(relPath);
- } catch (UnsupportedEncodingException exc) {
- throw new BuildException(exc);
- }
+ relPath = Locator.encodeURI(relPath);
+
// Manifest's ClassPath: attribute always uses forward
// slashes '/', and is space-separated. Ant will properly
// format it on 72 columns with proper line continuation
diff --git a/src/main/org/apache/tools/ant/taskdefs/Pack.java b/src/main/org/apache/tools/ant/taskdefs/Pack.java
index daabd6b..59a998f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Pack.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Pack.java
@@ -177,11 +177,8 @@
*/
protected void zipResource(Resource resource, OutputStream zOut)
throws IOException {
- InputStream rIn = resource.getInputStream();
- try {
+ try (InputStream rIn = resource.getInputStream()) {
zipFile(rIn, zOut);
- } finally {
- rIn.close();
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java
index ccfb356..db2d9d4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Property.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Property.java
@@ -533,13 +533,8 @@
Properties props = new Properties();
log("Loading " + url, Project.MSG_VERBOSE);
try {
- InputStream is = url.openStream();
- try {
+ try (InputStream is = url.openStream()) {
loadProperties(props, is, url.getFile().endsWith(".xml"));
- } finally {
- if (is != null) {
- is.close();
- }
}
addProperties(props);
} catch (IOException ex) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java
index 4b68198..1b6cb37 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Replace.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java
@@ -354,7 +354,7 @@
* a StringBuffer. Compatible with the Replacefilter.
* @since 1.7
*/
- private class FileInput /* JDK 5: implements Closeable */ {
+ private class FileInput implements AutoCloseable {
private StringBuffer outputBuffer;
private final InputStream is;
private Reader reader;
@@ -418,7 +418,7 @@
* Replacefilter.
* @since 1.7
*/
- private class FileOutput /* JDK 5: implements Closeable */ {
+ private class FileOutput implements AutoCloseable {
private StringBuffer inputBuffer;
private final OutputStream os;
private Writer writer;
@@ -667,26 +667,19 @@
File temp = FILE_UTILS.createTempFile("rep", ".tmp",
src.getParentFile(), false, true);
try {
- FileInput in = new FileInput(src);
- try {
- FileOutput out = new FileOutput(temp);
- try {
- out.setInputBuffer(buildFilterChain(in.getOutputBuffer()));
+ try (FileInput in = new FileInput(src);
+ FileOutput out = new FileOutput(temp)) {
+ out.setInputBuffer(buildFilterChain(in.getOutputBuffer()));
- while (in.readChunk()) {
- if (processFilterChain()) {
- out.process();
- }
+ while (in.readChunk()) {
+ if (processFilterChain()) {
+ out.process();
}
-
- flushFilterChain();
-
- out.flush();
- } finally {
- out.close();
}
- } finally {
- in.close();
+
+ flushFilterChain();
+
+ out.flush();
}
boolean changes = (replaceCount != repCountStart);
if (changes) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
index d913566..d9b7fb4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
+++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
@@ -704,19 +704,11 @@
}
} finally {
try {
- if (getStatement() != null) {
- getStatement().close();
- }
+ FileUtils.close(getStatement());
} catch (SQLException ex) {
// ignore
}
- try {
- if (getConnection() != null) {
- getConnection().close();
- }
- } catch (SQLException ex) {
- // ignore
- }
+ FileUtils.close(getConnection());
}
log(goodSql + " of " + totalSql + " SQL statements executed successfully");
@@ -846,13 +838,7 @@
throw e;
}
} finally {
- if (resultSet != null) {
- try {
- resultSet.close();
- } catch (SQLException e) {
- //ignore
- }
- }
+ FileUtils.close(resultSet);
}
}
@@ -866,13 +852,8 @@
*/
@Deprecated
protected void printResults(PrintStream out) throws SQLException {
- ResultSet rs = getStatement().getResultSet();
- try {
+ try (ResultSet rs = getStatement().getResultSet()) {
printResults(rs, out);
- } finally {
- if (rs != null) {
- rs.close();
- }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/SetPermissions.java b/src/main/org/apache/tools/ant/taskdefs/SetPermissions.java
new file mode 100644
index 0000000..052c569
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/SetPermissions.java
@@ -0,0 +1,231 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.DosFileAttributeView;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.Set;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.Resources;
+import org.apache.tools.ant.util.PermissionUtils;
+import org.apache.tools.ant.util.StringUtils;
+
+/**
+ * Sets {@link PosixFilePermission}s for resources.
+ *
+ * <p>This task provides a subset of {@link Chmod}'s and {@link
+ * org.apache.tools.ant.taskdefs.optional.windows.Attrib}'s abilities
+ * in less platform dependent way.</p>
+ *
+ * <p>It requires a file system that supports PosixFilePermissions for
+ * its full potential. It can optionally fall back to
+ * DosFilePermissions (only changing the readonly state) on file
+ * systems that don't support POSIX permissions. See {@link
+ * SetPermissions.NonPosixMode}</p>
+ *
+ * @since Ant 1.10.0
+ */
+public class SetPermissions extends Task {
+ private final Set<PosixFilePermission> permissions =
+ EnumSet.noneOf(PosixFilePermission.class);
+ private Resources resources = null;
+ private boolean failonerror = true;
+ private NonPosixMode nonPosixMode = NonPosixMode.fail;
+
+ /**
+ * Options for dealing with file systems that don't support POSIX
+ * permissions.
+ */
+ public enum NonPosixMode {
+ /** Fail the build. */
+ fail,
+ /** Log an error and go on. */
+ pass,
+ /**
+ * Try DosFilePermissions - setting the read-only flag - and
+ * fail the build if that fails as well.
+ */
+ tryDosOrFail,
+ /**
+ * Try DosFilePermissions - setting the read-only flag - and
+ * log an error and go on if that fails as well.
+ */
+ tryDosOrPass;
+ }
+
+ /**
+ * Adds permissions as a comma separated list.
+ * @param perms comma separated list of names of {@link PosixFilePermission}s.
+ */
+ public void setPermissions(String perms) {
+ if (perms != null) {
+ Arrays.stream(perms.split(",")) //NOSONAR
+ .map(String::trim)
+ .filter(s -> !s.isEmpty())
+ .map(s -> Enum.valueOf(PosixFilePermission.class, s))
+ .forEach(permissions::add);
+ }
+ }
+
+ /**
+ * A 3 digit octal string, specify the user, group and
+ * other modes in the standard Unix fashion;
+ * @param octalString a <code>String</code> value
+ */
+ public void setMode(String octalString) {
+ int mode = Integer.parseInt(octalString, 8);
+ permissions.addAll(PermissionUtils.permissionsFromMode(mode));
+ }
+
+ /**
+ * Set whether to fail when errors are encountered. If false, note errors
+ * to the output but keep going. Default is true.
+ * <p>Only applies to IO and SecurityExceptions, see {@link
+ * #setNonPosixMode} for ways to deal with file-systems that don't
+ * support PosixPermissions.</p>
+ * @param failonerror true or false.
+ */
+ public void setFailOnError(final boolean failonerror) {
+ this.failonerror = failonerror;
+ }
+
+ /**
+ * Set what to do if changing the permissions of a file is not
+ * possible because the file-system doesn't support POSIX file
+ * permissions.
+ * <p>The default is {@link NonPosixMode#fail}.</p>
+ * @param m what to do if changing the permissions of a file is not possible
+ */
+ public void setNonPosixMode(NonPosixMode m) {
+ this.nonPosixMode = m;
+ }
+
+ /**
+ * Adds a collection of resources to set permissions on.
+ * @param rc a resource collection
+ */
+ public void add(ResourceCollection rc) {
+ if (resources == null) {
+ resources = new Resources();
+ }
+ resources.add(rc);
+ }
+
+ public void execute() {
+ if (resources == null) {
+ throw new BuildException("At least one resource-collection is required");
+ }
+ Resource currentResource = null;
+ try {
+ for (Resource r : resources) {
+ currentResource = r;
+ try {
+ PermissionUtils.setPermissions(r, permissions, this::posixPermissionsNotSupported);
+ } catch (IOException ioe) {
+ maybeThrowException(ioe, "Failed to set permissions on '%s' due to %s", r, ioe.getMessage());
+ }
+ }
+ } catch (ClassCastException cce) {
+ maybeThrowException(null,
+ "some specified permissions are not of type PosixFilePermission: %s",
+ StringUtils.join(permissions, ", "));
+ } catch (SecurityException se) {
+ maybeThrowException(null,
+ "the SecurityManager denies role accessUserInformation or write access for SecurityManager.checkWrite for resource '%s'",
+ currentResource);
+ } catch (BuildException be) {
+ // maybe thrown by callback method this::posixPermissionsNotSupported.
+ maybeThrowException(be, be.getMessage());
+ }
+ }
+
+ private void maybeThrowException(Exception exc, String msgFormat, Object... msgArgs) {
+ String msg = String.format(msgFormat, msgArgs);
+ if (failonerror) {
+ if (exc instanceof BuildException) {
+ throw (BuildException)exc;
+ } else {
+ throw new BuildException(msg, exc);
+ }
+ } else {
+ log("Warning: " + msg, Project.MSG_ERR);
+ }
+ }
+
+ private void posixPermissionsNotSupported(Path p) {
+ String msg = String.format("the associated path '%s' does"
+ + " not support the PosixFileAttributeView", p);
+ switch (nonPosixMode) {
+ case fail:
+ throw new BuildException(msg);
+ case pass:
+ log("Warning: " + msg, Project.MSG_ERR);
+ break;
+ case tryDosOrFail:
+ tryDos(p, true);
+ break;
+ case tryDosOrPass:
+ tryDos(p, false);
+ break;
+ }
+ }
+
+ private void tryDos(Path p, boolean failIfDosIsNotSupported) {
+ log("Falling back to DosFileAttributeView");
+ boolean readOnly = !isWritable();
+ DosFileAttributeView view = Files.getFileAttributeView(p, DosFileAttributeView.class);
+ if (view != null) {
+ try {
+ view.setReadOnly(readOnly);
+ } catch (IOException ioe) {
+ maybeThrowException(ioe, "Failed to set permissions on '%s' due to %s",
+ p, ioe.getMessage());
+ } catch (SecurityException uoe) {
+ maybeThrowException(null, "the SecurityManager denies role "
+ + "accessUserInformation or write access for "
+ + "SecurityManager.checkWrite for resource '%s'",
+ p);
+ }
+ } else {
+ String msg = String.format("the associated path '%s' does"
+ + " not support the DosFileAttributeView", p);
+ if (failIfDosIsNotSupported) {
+ throw new BuildException(msg);
+ } else {
+ log("Warning: " + msg, Project.MSG_ERR);
+ }
+ }
+ }
+
+ private boolean isWritable() {
+ return permissions.contains(PosixFilePermission.OWNER_WRITE)
+ || permissions.contains(PosixFilePermission.GROUP_WRITE)
+ || permissions.contains(PosixFilePermission.OTHERS_WRITE);
+ }
+}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Tar.java b/src/main/org/apache/tools/ant/taskdefs/Tar.java
index 9754702..815477a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Tar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Tar.java
@@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -230,6 +232,7 @@
* <li> none - no compression
* <li> gzip - Gzip compression
* <li> bzip2 - Bzip2 compression
+ * <li>xz - XZ compression, requires XZ for Java
* </ul>
* @param mode the compression method.
*/
@@ -971,7 +974,11 @@
* BZIP2 compression
*/
private static final String BZIP2 = "bzip2";
-
+ /**
+ * XZ compression
+ * @since 1.10.1
+ */
+ private static final String XZ = "xz";
/**
* Default constructor
@@ -987,7 +994,7 @@
*/
@Override
public String[] getValues() {
- return new String[] {NONE, GZIP, BZIP2 };
+ return new String[] {NONE, GZIP, BZIP2, XZ };
}
/**
@@ -1003,6 +1010,8 @@
final String v = getValue();
if (GZIP.equals(v)) {
return new GZIPOutputStream(ostream);
+ } else if (XZ.equals(v)) {
+ return newXZOutputStream(ostream);
} else {
if (BZIP2.equals(v)) {
ostream.write('B');
@@ -1012,5 +1021,28 @@
}
return ostream;
}
+
+ private static OutputStream newXZOutputStream(OutputStream ostream)
+ throws BuildException {
+ try {
+ Class<?> fClazz = Class.forName("org.tukaani.xz.FilterOptions");
+ Class<?> oClazz = Class.forName("org.tukaani.xz.LZMA2Options");
+ Class<? extends OutputStream> sClazz =
+ Class.forName("org.tukaani.xz.XZOutputStream")
+ .asSubclass(OutputStream.class);
+ Constructor<? extends OutputStream> c =
+ sClazz.getConstructor(OutputStream.class, fClazz);
+ return c.newInstance(ostream, oClazz.newInstance());
+ } catch (ClassNotFoundException ex) {
+ throw new BuildException("xz compression requires the XZ for Java library",
+ ex);
+ } catch (NoSuchMethodException
+ | InstantiationException
+ | IllegalAccessException
+ | InvocationTargetException
+ ex) {
+ throw new BuildException("failed to create XZOutputStream", ex);
+ }
+ }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Untar.java b/src/main/org/apache/tools/ant/taskdefs/Untar.java
index 8343aec..c3e6e15 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Untar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Untar.java
@@ -23,6 +23,8 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.zip.GZIPInputStream;
import org.apache.tools.ant.BuildException;
@@ -70,6 +72,7 @@
* <li>none - no compression
* <li>gzip - Gzip compression
* <li>bzip2 - Bzip2 compression
+ * <li>xz - XZ compression, requires XZ for Java
* </ul>
*
* @param method compression method
@@ -190,6 +193,11 @@
* BZIP2 compression
*/
private static final String BZIP2 = "bzip2";
+ /**
+ * XZ compression
+ * @since 1.10.1
+ */
+ private static final String XZ = "xz";
/**
@@ -206,7 +214,7 @@
* @return valid values
*/
public String[] getValues() {
- return new String[] {NONE, GZIP, BZIP2};
+ return new String[] {NONE, GZIP, BZIP2, XZ};
}
/**
@@ -226,6 +234,8 @@
final String v = getValue();
if (GZIP.equals(v)) {
return new GZIPInputStream(istream);
+ } else if (XZ.equals(v)) {
+ return newXZInputStream(istream);
} else {
if (BZIP2.equals(v)) {
final char[] magic = new char[] {'B', 'Z'};
@@ -240,5 +250,26 @@
}
return istream;
}
+
+ private static InputStream newXZInputStream(InputStream istream)
+ throws BuildException {
+ try {
+ Class<? extends InputStream> clazz =
+ Class.forName("org.tukaani.xz.XZInputStream")
+ .asSubclass(InputStream.class);
+ Constructor<? extends InputStream> c =
+ clazz.getConstructor(InputStream.class);
+ return c.newInstance(istream);
+ } catch (ClassNotFoundException ex) {
+ throw new BuildException("xz uncompression requires the XZ for Java library",
+ ex);
+ } catch (NoSuchMethodException
+ | InstantiationException
+ | IllegalAccessException
+ | InvocationTargetException
+ ex) {
+ throw new BuildException("failed to create XZInputStream", ex);
+ }
+ }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/WhichResource.java b/src/main/org/apache/tools/ant/taskdefs/WhichResource.java
index 3f315a8..d19918a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/WhichResource.java
+++ b/src/main/org/apache/tools/ant/taskdefs/WhichResource.java
@@ -135,11 +135,10 @@
getProject().log("using system classpath: " + classpath,
Project.MSG_DEBUG);
}
- AntClassLoader loader = null;
- try {
- loader = AntClassLoader.newAntClassLoader(getProject().getCoreLoader(),
- getProject(),
- classpath, false);
+ try (AntClassLoader loader =
+ AntClassLoader.newAntClassLoader(getProject().getCoreLoader(),
+ getProject(),
+ classpath, false)) {
String loc = null;
if (classname != null) {
//convert a class name into a resource
@@ -162,10 +161,6 @@
loc = url.toExternalForm();
getProject().setNewProperty(property, loc);
}
- } finally {
- if (loader != null) {
- loader.cleanup();
- }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java
index 5d68b2f..580176f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Zip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java
@@ -1915,14 +1915,11 @@
getLocation());
}
- final FileInputStream fIn = new FileInputStream(file);
- try {
+ try (FileInputStream fIn = new FileInputStream(file)) {
// ZIPs store time with a granularity of 2 seconds, round up
zipFile(fIn, zOut, vPath,
file.lastModified() + (roundUp ? ROUNDUP_MILLIS : 0),
null, mode);
- } finally {
- fIn.close();
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java
deleted file mode 100644
index 9503ac0..0000000
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * 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.compilers;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Apt;
-import org.apache.tools.ant.types.Commandline;
-import org.apache.tools.ant.types.Path;
-
-
-/**
- * <p>The implementation of the apt compiler for JDK 1.5.</p>
- *
- * <p>As usual, the low level entry points for Java tools are neither documented or
- * stable; this entry point may change from that of 1.5.0_01-b08 without any
- * warning at all. The IDE decompile of the tool entry points is as follows:</p>
- * <pre>
- * public class Main {
- * public Main() ;
- *
- * public static transient void main(String... strings);
- *
- * public static transient int process(String... strings);
- *
- * public static transient int process(PrintWriter printWriter,
- * String... strings);
- * public static transient int process(
- * AnnotationProcessorFactory annotationProcessorFactory,
- * String... strings);
- *
- * public static transient int process(
- * AnnotationProcessorFactory annotationProcessorFactory,
- * PrintWriter printWriter,
- * String... strings);
- * private static transient int processing(
- * AnnotationProcessorFactory annotationProcessorFactory,
- * PrintWriter printWriter,
- * String... strings) ;
- * }
- * </pre>
- *
- * This Adapter is designed to run Apt in-JVM, an option that is not actually
- * exposed to end-users, because it was too brittle during beta testing; classpath
- * problems being the core issue.
- *
- * @since Ant 1.7
- */
-public class AptCompilerAdapter extends DefaultCompilerAdapter {
-
- /**
- * Integer returned by the Apt compiler to indicate success.
- */
- private static final int APT_COMPILER_SUCCESS = 0;
- /**
- * class in tools.jar that implements APT
- */
- public static final String APT_ENTRY_POINT = "com.sun.tools.apt.Main";
-
- /**
- * method used to compile.
- */
- public static final String APT_METHOD_NAME = "process";
-
- /**
- * Get the facade task that fronts this adapter
- *
- * @return task instance
- * @see DefaultCompilerAdapter#getJavac()
- */
- protected Apt getApt() {
- return (Apt) getJavac();
- }
-
- /**
- * Using the front end arguments, set up the command line to run Apt
- *
- * @param apt task
- * @param cmd command that is set up with the various switches from the task
- * options
- */
- static void setAptCommandlineSwitches(final Apt apt, final Commandline cmd) {
-
- if (!apt.isCompile()) {
- cmd.createArgument().setValue("-nocompile");
- }
-
- // Process the factory class
- final String factory = apt.getFactory();
- if (factory != null) {
- cmd.createArgument().setValue("-factory");
- cmd.createArgument().setValue(factory);
- }
-
- // Process the factory path
- final Path factoryPath = apt.getFactoryPath();
- if (factoryPath != null) {
- cmd.createArgument().setValue("-factorypath");
- cmd.createArgument().setPath(factoryPath);
- }
-
- final File preprocessDir = apt.getPreprocessDir();
- if (preprocessDir != null) {
- cmd.createArgument().setValue("-s");
- cmd.createArgument().setFile(preprocessDir);
- }
-
- // Process the processor options
- final Vector options = apt.getOptions();
- final Enumeration elements = options.elements();
- Apt.Option opt;
- StringBuffer arg = null;
- while (elements.hasMoreElements()) {
- opt = (Apt.Option) elements.nextElement();
- arg = new StringBuffer();
- arg.append("-A").append(opt.getName());
- if (opt.getValue() != null) {
- arg.append("=").append(opt.getValue());
- }
- cmd.createArgument().setValue(arg.toString());
- }
- }
-
- /**
- * using our front end task, set up the command line switches
- *
- * @param cmd command line to set up
- */
- protected void setAptCommandlineSwitches(final Commandline cmd) {
- final Apt apt = getApt();
- setAptCommandlineSwitches(apt, cmd);
- }
-
- /**
- * Run the compilation.
- * @return true on success.
- * @throws BuildException if the compilation has problems.
- */
- public boolean execute() throws BuildException {
- attributes.log("Using apt compiler", Project.MSG_VERBOSE);
- //set up the javac options
- final Commandline cmd = setupModernJavacCommand();
- //then add the Apt options
- setAptCommandlineSwitches(cmd);
-
- //finally invoke APT
- // Use reflection to be able to build on all JDKs:
- try {
- final Class c = Class.forName(APT_ENTRY_POINT);
- final Object compiler = c.newInstance();
- final Method compile = c.getMethod(APT_METHOD_NAME,
- new Class[]{(new String[]{}).getClass()});
- final int result = ((Integer) compile.invoke
- (compiler, new Object[]{cmd.getArguments()}))
- .intValue();
- return (result == APT_COMPILER_SUCCESS);
- } catch (final BuildException be) {
- //rethrow build exceptions
- throw be;
- } catch (final Exception ex) {
- //cast everything else to a build exception
- throw new BuildException("Error starting apt compiler",
- ex, location);
- }
- }
-}
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/AptExternalCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/AptExternalCompilerAdapter.java
deleted file mode 100644
index dadb55b..0000000
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/AptExternalCompilerAdapter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.compilers;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Apt;
-import org.apache.tools.ant.types.Commandline;
-
-/**
- * The implementation of the apt compiler for JDK 1.5 using an external process
- *
- * @since Ant 1.7
- */
-public class AptExternalCompilerAdapter extends DefaultCompilerAdapter {
-
-
- /**
- * Get the facade task that fronts this adapter
- *
- * @return task instance
- * @see DefaultCompilerAdapter#getJavac()
- */
- protected Apt getApt() {
- return (Apt) getJavac();
- }
-
- /**
- * Performs a compile using the Javac externally.
- * @return true the compilation was successful.
- * @throws BuildException if there is a problem.
- */
- public boolean execute() throws BuildException {
- attributes.log("Using external apt compiler", Project.MSG_VERBOSE);
-
-
- // Setup the apt executable
- Apt apt = getApt();
- Commandline cmd = new Commandline();
- cmd.setExecutable(apt.getAptExecutable());
- setupModernJavacCommandlineSwitches(cmd);
- AptCompilerAdapter.setAptCommandlineSwitches(apt, cmd);
- int firstFileName = cmd.size();
- //add the files
- logAndAddFilesToCompile(cmd);
-
- //run
- return 0 == executeExternalCompile(cmd.getCommandline(),
- firstFileName,
- true);
-
- }
-
-}
-
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
index d6a69ec..43a40e0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
@@ -23,6 +23,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.util.FileUtils;
/**
* Condition to wait for a TCP/IP socket to have a listener. Its attributes are:
@@ -73,13 +74,7 @@
} catch (IOException e) {
return false;
} finally {
- if (s != null) {
- try {
- s.close();
- } catch (IOException ioe) {
- // Intentionally left blank
- }
- }
+ FileUtils.close(s);
}
return true;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java
index 713de0c..e9b755d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java
@@ -22,6 +22,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.PumpStreamHandler;
+import org.apache.tools.ant.util.FileUtils;
/**
* A dummy stream handler that just passes stuff to the parser.
@@ -49,13 +50,8 @@
public void stop() {
super.stop();
- try {
- getErr().close();
- getOut().close();
- } catch (final IOException e) {
- // plain impossible
- throw new BuildException(e);
- }
+ FileUtils.close(getErr());
+ FileUtils.close(getOut());
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties
index 9cf1499..8db1ebc 100644
--- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties
+++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties
@@ -19,7 +19,6 @@
antstructure=org.apache.tools.ant.taskdefs.AntStructure
antversion=org.apache.tools.ant.taskdefs.condition.AntVersion
apply=org.apache.tools.ant.taskdefs.Transform
-apt=org.apache.tools.ant.taskdefs.Apt
attributenamespacedef=org.apache.tools.ant.taskdefs.AttributeNamespaceDef
augment=org.apache.tools.ant.taskdefs.AugmentReference
available=org.apache.tools.ant.taskdefs.Available
@@ -92,6 +91,7 @@
resourcecount=org.apache.tools.ant.taskdefs.ResourceCount
retry=org.apache.tools.ant.taskdefs.Retry
rmic=org.apache.tools.ant.taskdefs.Rmic
+setpermissions=org.apache.tools.ant.taskdefs.SetPermissions
sequential=org.apache.tools.ant.taskdefs.Sequential
signjar=org.apache.tools.ant.taskdefs.SignJar
sleep=org.apache.tools.ant.taskdefs.Sleep
@@ -108,6 +108,7 @@
unjar=org.apache.tools.ant.taskdefs.Expand
untar=org.apache.tools.ant.taskdefs.Untar
unwar=org.apache.tools.ant.taskdefs.Expand
+unxz=org.apache.tools.ant.taskdefs.optional.xz.Unxz
unzip=org.apache.tools.ant.taskdefs.Expand
uptodate=org.apache.tools.ant.taskdefs.UpToDate
waitfor=org.apache.tools.ant.taskdefs.WaitFor
@@ -115,6 +116,7 @@
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/email/Header.java b/src/main/org/apache/tools/ant/taskdefs/email/Header.java
index 6bcfb66..aaee693 100644
--- a/src/main/org/apache/tools/ant/taskdefs/email/Header.java
+++ b/src/main/org/apache/tools/ant/taskdefs/email/Header.java
@@ -19,7 +19,9 @@
package org.apache.tools.ant.taskdefs.email;
/**
- * Class representing a generic e-mail header.
+ * Class representing a generic key-value header.
+ * TODO: This should be moved out of the email package
+ *
* @since Ant 1.7
*/
public class Header {
diff --git a/src/main/org/apache/tools/ant/taskdefs/email/Message.java b/src/main/org/apache/tools/ant/taskdefs/email/Message.java
index c121f5d..a73fdfa 100644
--- a/src/main/org/apache/tools/ant/taskdefs/email/Message.java
+++ b/src/main/org/apache/tools/ant/taskdefs/email/Message.java
@@ -126,17 +126,13 @@
: new BufferedWriter(new OutputStreamWriter(ps));
if (messageSource != null) {
// Read message from a file
- Reader freader = getReader(messageSource);
-
- try {
- BufferedReader in = new BufferedReader(freader);
+ try (Reader freader = getReader(messageSource);
+ BufferedReader in = new BufferedReader(freader)) {
String line = null;
while ((line = in.readLine()) != null) {
out.write(getProject().replaceProperties(line));
out.newLine();
}
- } finally {
- freader.close();
}
} else {
out.write(getProject().replaceProperties(buffer.substring(0)));
diff --git a/src/main/org/apache/tools/ant/taskdefs/email/PlainMailer.java b/src/main/org/apache/tools/ant/taskdefs/email/PlainMailer.java
index 20524ac..3b1f95b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/email/PlainMailer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/email/PlainMailer.java
@@ -147,16 +147,13 @@
int length;
final int maxBuf = 1024;
byte[] buf = new byte[maxBuf];
- FileInputStream finstr = new FileInputStream(file);
- try {
- BufferedInputStream in = new BufferedInputStream(finstr, buf.length);
+ try (FileInputStream finstr = new FileInputStream(file);
+ BufferedInputStream in = new BufferedInputStream(finstr, buf.length)) {
while ((length = in.read(buf)) != -1) {
out.write(buf, 0, length);
}
- } finally {
- finstr.close();
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/email/UUMailer.java b/src/main/org/apache/tools/ant/taskdefs/email/UUMailer.java
index d6542be..03af678 100644
--- a/src/main/org/apache/tools/ant/taskdefs/email/UUMailer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/email/UUMailer.java
@@ -40,16 +40,11 @@
+ "readable.");
}
- FileInputStream finstr = new FileInputStream(file);
-
- try {
- BufferedInputStream in = new BufferedInputStream(finstr);
+ try (FileInputStream finstr = new FileInputStream(file);
+ BufferedInputStream in = new BufferedInputStream(finstr)) {
UUEncoder encoder = new UUEncoder(file.getName());
encoder.encode(in, out);
-
- } finally {
- finstr.close();
}
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
index 605b336..2ed40e5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
@@ -422,17 +422,12 @@
* @since Ant 1.6
*/
protected boolean is272() {
- AntClassLoader l = null;
- try {
- l = getProject().createClassLoader(commandline.getClasspath());
+ try (AntClassLoader l =
+ getProject().createClassLoader(commandline.getClasspath())) {
l.loadClass("antlr.Version");
return true;
} catch (ClassNotFoundException e) {
return false;
- } finally {
- if (l != null) {
- l.cleanup();
- }
}
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
index 02106a9..9ad9feb 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
@@ -192,27 +192,16 @@
if (propertyfile.exists()) {
log("Updating property file: "
+ propertyfile.getAbsolutePath());
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(propertyfile);
- BufferedInputStream bis = new BufferedInputStream(fis);
+ try (FileInputStream fis = new FileInputStream(propertyfile);
+ BufferedInputStream bis = new BufferedInputStream(fis)) {
properties.load(bis);
- } finally {
- if (fis != null) {
- fis.close();
- }
}
} else {
log("Creating new property file: "
+ propertyfile.getAbsolutePath());
- FileOutputStream out = null;
- try {
- out = new FileOutputStream(propertyfile.getAbsolutePath());
+ try (FileOutputStream out =
+ new FileOutputStream(propertyfile.getAbsolutePath())) {
out.flush();
- } finally {
- if (out != null) {
- out.close();
- }
}
}
} catch (IOException ioe) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
index d088096..40b7b5d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
@@ -356,13 +356,13 @@
try {
boolean changes = false;
- InputStream is = new FileInputStream(f);
- try {
- Reader r = encoding != null ? new InputStreamReader(is, encoding) : new InputStreamReader(is);
- OutputStream os = new FileOutputStream(temp);
+ try (InputStream is = new FileInputStream(f);
+ OutputStream os = new FileOutputStream(temp)) {
+ Reader r = null;
+ Writer w = null;
try {
- Writer w = encoding != null ? new OutputStreamWriter(os, encoding) : new OutputStreamWriter(os);
-
+ r = encoding != null ? new InputStreamReader(is, encoding) : new InputStreamReader(is);
+ w = encoding != null ? new OutputStreamWriter(os, encoding) : new OutputStreamWriter(os);
log("Replacing pattern '" + regex.getPattern(getProject())
+ "' with '" + subs.getExpression(getProject())
+ "' in '" + f.getPath() + "'" + (byline ? " by line" : "")
@@ -426,15 +426,10 @@
} else {
changes = multilineReplace(r, w, options);
}
-
- r.close();
- w.close();
-
} finally {
- os.close();
+ FileUtils.close(r);
+ FileUtils.close(w);
}
- } finally {
- is.close();
}
if (changes) {
log("File has changed; saving the updated file", Project.MSG_VERBOSE);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Script.java b/src/main/org/apache/tools/ant/taskdefs/optional/Script.java
index 2b8d9f6..de6bf5a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/Script.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/Script.java
@@ -130,4 +130,15 @@
public void setSetBeans(boolean setBeans) {
helper.setSetBeans(setBeans);
}
+
+ /**
+ * Set the encoding of the script from an external file ; optional.
+ *
+ * @param encoding the encoding of the file containing the script source.
+ * @since Ant 1.10.2
+ */
+ public void setEncoding(String encoding) {
+ helper.setEncoding(encoding);
+ }
+
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
index 605aba9..f2fcd9a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
@@ -301,17 +301,11 @@
// and avoid keeping the handle until the object is garbaged.
// (always keep control), otherwise you won't be able to delete
// the file quickly on windows.
- InputStream xslStream = null;
- try {
- xslStream
- = new BufferedInputStream(stylesheet.getInputStream());
+ try (InputStream xslStream =
+ new BufferedInputStream(stylesheet.getInputStream())) {
templatesModTime = stylesheet.getLastModified();
final Source src = getSource(xslStream, stylesheet);
templates = getFactory().newTemplates(src);
- } finally {
- if (xslStream != null) {
- xslStream.close();
- }
}
}
@@ -672,8 +666,7 @@
private void applyReflectionHackForExtensionMethods() {
// Jigsaw doesn't allow reflection to work, so we can stop trying
- if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_7)
- && !JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
+ if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
try { // #51668, #52382
final Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing");
_isNotSecureProcessing.setAccessible(true);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
index 05c043d..26b49a2 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
@@ -287,42 +287,40 @@
*/
public void execute() throws BuildException {
try {
- int fileProcessed = 0;
- if (file == null && (filesets.size() == 0)) {
- throw new BuildException(
- "Specify at least one source - " + "a file or a fileset.");
- }
+ int fileProcessed = 0;
+ if (file == null && (filesets.size() == 0)) {
+ throw new BuildException(
+ "Specify at least one source - " + "a file or a fileset.");
+ }
-
-
- if (file != null) {
- if (file.exists() && file.canRead() && file.isFile()) {
- doValidate(file);
- fileProcessed++;
- } else {
- String errorMsg = "File " + file + " cannot be read";
- if (failOnError) {
- throw new BuildException(errorMsg);
+ if (file != null) {
+ if (file.exists() && file.canRead() && file.isFile()) {
+ doValidate(file);
+ fileProcessed++;
} else {
- log(errorMsg, Project.MSG_ERR);
+ String errorMsg = "File " + file + " cannot be read";
+ if (failOnError) {
+ throw new BuildException(errorMsg);
+ } else {
+ log(errorMsg, Project.MSG_ERR);
+ }
}
}
- }
- final int size = filesets.size();
- for (int i = 0; i < size; i++) {
+ final int size = filesets.size();
+ for (int i = 0; i < size; i++) {
- FileSet fs = (FileSet) filesets.elementAt(i);
- DirectoryScanner ds = fs.getDirectoryScanner(getProject());
- String[] files = ds.getIncludedFiles();
+ FileSet fs = (FileSet) filesets.elementAt(i);
+ DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+ String[] files = ds.getIncludedFiles();
- for (int j = 0; j < files.length; j++) {
- File srcFile = new File(fs.getDir(getProject()), files[j]);
- doValidate(srcFile);
- fileProcessed++;
+ for (int j = 0; j < files.length; j++) {
+ File srcFile = new File(fs.getDir(getProject()), files[j]);
+ doValidate(srcFile);
+ fileProcessed++;
+ }
}
- }
- onSuccessfulValidation(fileProcessed);
+ onSuccessfulValidation(fileProcessed);
} finally {
cleanup();
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java
index 341f670..d490955 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java
@@ -96,9 +96,7 @@
}
} finally {
FileUtils.close(inStream);
- if (zipFile != null) {
- zipFile.close();
- }
+ FileUtils.close(zipFile);
}
} catch (IOException ioe) {
// ignore
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
index 2cf335c..f46af0a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
@@ -379,9 +379,7 @@
if (checkPath != null) {
// now determine which jars each class depends upon
classpathDependencies = new Hashtable();
- AntClassLoader loader = null;
- try {
- loader = getProject().createClassLoader(checkPath);
+ try (AntClassLoader loader = getProject().createClassLoader(checkPath)) {
Hashtable classpathFileCache = new Hashtable();
Object nullFileMarker = new Object();
@@ -443,10 +441,6 @@
}
}
}
- } finally {
- if (loader != null) {
- loader.cleanup();
- }
}
} else {
log("No classpath to check", Project.MSG_DEBUG);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/DirectoryIterator.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/DirectoryIterator.java
index af28c96..fbb963e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/DirectoryIterator.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/DirectoryIterator.java
@@ -130,10 +130,8 @@
} else {
// we have a file. create a stream for it
- FileInputStream inFileStream
- = new FileInputStream(element);
-
- try {
+ try (FileInputStream inFileStream
+ = new FileInputStream(element)) {
if (element.getName().endsWith(".class")) {
// create a data input stream from the jar
@@ -144,8 +142,6 @@
nextElement = javaClass;
}
- } finally {
- inFileStream.close();
}
}
} else {
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
index 81fe805..0d9bd13 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
@@ -19,6 +19,7 @@
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -681,10 +682,7 @@
log("Looking for GenIC class in classpath: "
+ classpath.toString(), Project.MSG_VERBOSE);
- AntClassLoader cl = null;
-
- try {
- cl = classpath.getProject().createClassLoader(classpath);
+ try (AntClassLoader cl = classpath.getProject().createClassLoader(classpath)) {
try {
cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
@@ -723,10 +721,6 @@
+ "' not found in classpath.",
Project.MSG_VERBOSE);
}
- } finally {
- if (cl != null) {
- cl.cleanup();
- }
}
return null;
}
@@ -778,12 +772,7 @@
* @throws BuildException if a temp directory cannot be created.
*/
private File createTempDir() throws IOException {
- File tmpDir = File.createTempFile("genic", null, null);
- tmpDir.delete();
- if (!tmpDir.mkdir()) {
- throw new IOException("Cannot create the temporary directory '" + tmpDir + "'.");
- }
- return tmpDir;
+ return Files.createTempDirectory("genic").toFile();
}
/**
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
index 7fae8b3..6495e97 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
@@ -866,24 +866,10 @@
throw new BuildException(msg, ioe);
} finally {
- // need to close files and perhaps rename output
- if (genericJar != null) {
- try {
- genericJar.close();
- } catch (IOException closeException) {
- // empty
- }
- }
-
- if (wlJar != null) {
- try {
- wlJar.close();
- } catch (IOException closeException) {
- // empty
- }
- }
-
+ FileUtils.close(genericJar);
+ FileUtils.close(wlJar);
FileUtils.close(newJarStream);
+
if (newJarStream != null) {
try {
FILE_UTILS.rename(newWLJarFile, weblogicJarFile);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
index 7114610..da84f24 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
@@ -832,23 +832,10 @@
throw new BuildException(msg, ioe);
} finally {
// need to close files and perhaps rename output
- if (genericJar != null) {
- try {
- genericJar.close();
- } catch (IOException closeException) {
- // Ignore
- }
- }
-
- if (wasJar != null) {
- try {
- wasJar.close();
- } catch (IOException closeException) {
- // Ignore
- }
- }
-
+ FileUtils.close(genericJar);
+ FileUtils.close(wasJar);
FileUtils.close(newJarStream);
+
if (newJarStream != null) {
try {
FILE_UTILS.rename(newwasJarFile, websphereJarFile);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java
index ce66050..00d4599 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java
@@ -29,6 +29,7 @@
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.util.FileUtils;
/**
* A set of useful methods relating to extensions.
@@ -142,7 +143,7 @@
} catch (final Exception e) {
throw new BuildException(e.getMessage(), e);
} finally {
- close(jarFile);
+ FileUtils.close(jarFile);
}
}
@@ -215,17 +216,8 @@
} catch (final IOException ioe) {
throw new BuildException(ioe.getMessage(), ioe);
} finally {
- close(jarFile);
+ FileUtils.close(jarFile);
}
}
- private static void close(JarFile device) {
- if (null != device) {
- try {
- device.close();
- } catch (IOException e) {
- //ignore
- }
- }
- }
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java
index 999110f..86713da 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java
@@ -425,12 +425,11 @@
String packagePrefix = null;
String mainClass = null;
- AntClassLoader l = null;
- try {
- l = AntClassLoader.newAntClassLoader(null, null,
- path
- .concatSystemClasspath("ignore"),
- true);
+ try (AntClassLoader l =
+ AntClassLoader.newAntClassLoader(null, null,
+ path
+ .concatSystemClasspath("ignore"),
+ true)) {
String javaccClass = COM_PACKAGE + COM_JAVACC_CLASS;
InputStream is = l.getResourceAsStream(javaccClass.replace('.', '/')
+ ".class");
@@ -498,10 +497,6 @@
throw new BuildException("unknown task type " + type);
}
return packagePrefix + mainClass;
- } finally {
- if (l != null) {
- l.cleanup();
- }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javah/ForkingJavah.java b/src/main/org/apache/tools/ant/taskdefs/optional/javah/ForkingJavah.java
index c12f594..a537669 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/javah/ForkingJavah.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/javah/ForkingJavah.java
@@ -45,6 +45,7 @@
* @return true if the compilation was successful.
* @throws BuildException if there is an error.
*/
+ @Override
public boolean compile(Javah javah) throws BuildException {
Commandline cmd = SunJavah.setupJavahCommand(javah);
Project project = javah.getProject();
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java b/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
index cc4419c..481a97d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
@@ -44,10 +44,8 @@
return Kaffeh.IMPLEMENTATION_NAME;
} else if (JavaEnvUtils.isGij()) {
return Gcjh.IMPLEMENTATION_NAME;
- } else if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
- return ForkingJavah.IMPLEMENTATION_NAME;
}
- return SunJavah.IMPLEMENTATION_NAME;
+ return ForkingJavah.IMPLEMENTATION_NAME;
}
/**
@@ -89,9 +87,7 @@
} else if ((JavaEnvUtils.isGij() && choice == null)
|| Gcjh.IMPLEMENTATION_NAME.equals(choice)) {
return new Gcjh();
- } else if ((JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)
- && choice == null)
- || ForkingJavah.IMPLEMENTATION_NAME.equals(choice)) {
+ } else if (ForkingJavah.IMPLEMENTATION_NAME.equals(choice)) {
return new ForkingJavah();
} else if (SunJavah.IMPLEMENTATION_NAME.equals(choice)) {
return new SunJavah();
@@ -102,9 +98,7 @@
.createClassLoader(classpath));
}
- // This default has been good enough until Ant 1.6.3, so stick
- // with it
- return new SunJavah();
+ return new ForkingJavah();
}
/**
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
index 0c143cf..5d45cfc 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
@@ -222,8 +222,7 @@
if (!f.exists()) {
return;
}
- ZipFile zipf = new ZipFile(f);
- try {
+ try (ZipFile zipf = new ZipFile(f)) {
Enumeration entries = zipf.entries();
while (entries.hasMoreElements()) {
@@ -268,8 +267,6 @@
output.closeEntry();
}
}
- } finally {
- zipf.close();
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
index 4274bf0..9832e3e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
@@ -439,13 +439,10 @@
File dest = getActualDestDir();
- AntClassLoader al = null;
- try {
+ try (AntClassLoader al = getProject().createClassLoader(compilerClasspath)) {
//bind to a compiler
JspCompilerAdapter compiler =
- JspCompilerAdapterFactory
- .getCompiler(compilerName, this,
- al = getProject().createClassLoader(compilerClasspath));
+ JspCompilerAdapterFactory.getCompiler(compilerName, this, al);
//if we are a webapp, hand off to the compiler, which had
//better handle it
@@ -514,10 +511,6 @@
log("all files are up to date", Project.MSG_VERBOSE);
}
}
- } finally {
- if (al != null) {
- al.cleanup();
- }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
index f0becac..80ed601 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
@@ -166,17 +166,11 @@
* @since Ant 1.6.2
*/
private boolean isTomcat5x() {
- AntClassLoader l = null;
- try {
- l = getProject().createClassLoader(getClasspath());
+ try (AntClassLoader l = getProject().createClassLoader(getClasspath())) {
l.loadClass("org.apache.jasper.tagplugins.jstl.If");
return true;
} catch (ClassNotFoundException e) {
return false;
- } finally {
- if (l != null) {
- l.cleanup();
- }
}
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
index fd7a321..ca47074 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
@@ -176,12 +176,9 @@
protected void setXmlfile(File xmlfile) throws BuildException {
try {
DocumentBuilder builder = privateDBFactory.newDocumentBuilder();
- InputStream in = new FileInputStream(xmlfile);
- try {
+ try (InputStream in = new FileInputStream(xmlfile)) {
Document doc = builder.parse(in);
setXmlDocument(doc);
- } finally {
- in.close();
}
} catch (Exception e) {
throw new BuildException("Error while parsing document: " + xmlfile, e);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
index edf63b6..6a69d23 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
@@ -21,7 +21,6 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
@@ -1393,12 +1392,10 @@
if (!cmd.haveClasspath()) {
return;
}
- AntClassLoader loader = null;
- try {
- loader =
- AntClassLoader.newAntClassLoader(null, getProject(),
- cmd.createClasspath(getProject()),
- true);
+ try (AntClassLoader loader =
+ AntClassLoader.newAntClassLoader(null, getProject(),
+ cmd.createClasspath(getProject()),
+ true)) {
final String projectResourceName =
LoaderUtils.classNameToResource(Project.class.getName());
URL previous = null;
@@ -1419,10 +1416,6 @@
} catch (final Exception ex) {
// Ignore exception
}
- } finally {
- if (loader != null) {
- loader.cleanup();
- }
}
}
@@ -1757,23 +1750,17 @@
* @since 1.9.8
*/
private boolean hasJunit(final Path path) {
- AntClassLoader loader = null;
- try {
- loader = AntClassLoader.newAntClassLoader(
+ try (AntClassLoader loader = AntClassLoader.newAntClassLoader(
null,
getProject(),
path,
- true);
+ true)) {
try {
loader.loadClass("junit.framework.Test");
return true;
} catch (final Exception ex) {
return false;
}
- } finally {
- if (loader != null) {
- loader.close();
- }
}
}
@@ -1788,11 +1775,7 @@
for (String path : modulePath.list()) {
final File modulePathEntry = getProject().resolveFile(path);
if (modulePathEntry.isDirectory() && !hasModuleInfo(modulePathEntry)) {
- final File[] modules = modulePathEntry.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.toLowerCase(Locale.ENGLISH).endsWith(".jar");
- }
- });
+ final File[] modules = modulePathEntry.listFiles((dir,name)->name.toLowerCase(Locale.ENGLISH).endsWith(".jar"));
if (modules != null) {
for (File module : modules) {
expanded.add(new Path(getProject(), String.format(
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
index 4f76c96..97e2647 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
@@ -213,9 +213,8 @@
* @throws IOException thrown if there is an error while writing the content.
*/
protected void writeDOMTree(Document doc, File file) throws IOException {
- OutputStream os = new FileOutputStream(file);
- try {
- PrintWriter wri = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(os), "UTF8"));
+ try (OutputStream os = new FileOutputStream(file);
+ PrintWriter wri = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(os), "UTF8"))) {
wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
(new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " ");
wri.flush();
@@ -223,8 +222,6 @@
if (wri.checkError()) {
throw new IOException("Error while writing DOM content");
}
- } finally {
- os.close();
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/BuiltinNative2Ascii.java b/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/BuiltinNative2Ascii.java
index db91a26..36e46c3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/BuiltinNative2Ascii.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/BuiltinNative2Ascii.java
@@ -31,7 +31,6 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.optional.Native2Ascii;
-import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.Native2AsciiUtils;
import org.apache.tools.ant.util.StringUtils;
@@ -44,23 +43,14 @@
static final String IMPLEMENTATION_NAME = "builtin";
+ @Override
public final boolean convert(Native2Ascii args, File srcFile,
File destFile) throws BuildException {
boolean reverse = args.getReverse();
String encoding = args.getEncoding();
- BufferedReader input = null;
- try {
- input = getReader(srcFile, encoding, reverse);
- try {
- Writer output = getWriter(destFile, encoding, reverse);
- try {
- translate(input, output, reverse);
- } finally {
- FileUtils.close(output);
- }
- } finally {
- FileUtils.close(input);
- }
+ try (BufferedReader input = getReader(srcFile, encoding, reverse);
+ Writer output = getWriter(destFile, encoding, reverse)) {
+ translate(input, output, reverse);
return true;
} catch (IOException ex) {
throw new BuildException("Exception trying to translate data", ex);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java b/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
index e8bd74d..74bb323 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
@@ -43,9 +43,6 @@
if (shouldUseKaffee()) {
return KaffeNative2Ascii.IMPLEMENTATION_NAME;
}
- if (shouldUseSun()) {
- return SunNative2Ascii.IMPLEMENTATION_NAME;
- }
return BuiltinNative2Ascii.IMPLEMENTATION_NAME;
}
@@ -85,8 +82,7 @@
if ((shouldUseKaffee() && choice == null)
|| KaffeNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
return new KaffeNative2Ascii();
- } else if ((shouldUseSun() && choice == null)
- || SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
+ } else if (SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
return new SunNative2Ascii();
} else if (BuiltinNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
return new BuiltinNative2Ascii();
@@ -121,11 +117,4 @@
private static final boolean shouldUseKaffee() {
return JavaEnvUtils.isKaffe() || JavaEnvUtils.isClasspathBased();
}
-
- private static final boolean shouldUseSun() {
- return JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)
- || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)
- || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)
- || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8);
- }
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java b/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
index ac9eb88..7e62549 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
@@ -40,7 +40,7 @@
import org.apache.tools.ant.util.ScriptRunnerHelper;
/**
- * Define a task using a script
+ * Defines a task using a script.
*
* @since Ant 1.6
*/
@@ -67,7 +67,7 @@
/**
* Set the project.
- * @param project the project that this def belows to.
+ * @param project the project that this definition belongs to.
*/
public void setProject(Project project) {
super.setProject(project);
@@ -76,7 +76,7 @@
}
/**
- * set the name under which this script will be activated in a build
+ * Sets the name under which this script will be activated in a build
* file
*
* @param name the name of the script
@@ -104,7 +104,7 @@
private String name;
/**
- * Set the attribute name
+ * Sets the attribute name
*
* @param name the attribute name
*/
@@ -114,7 +114,7 @@
}
/**
- * Add an attribute definition to this script.
+ * Adds an attribute definition to this script.
*
* @param attribute the attribute definition.
*/
@@ -136,7 +136,7 @@
private String className;
/**
- * set the tag name for this nested element
+ * Sets the tag name for this nested element
*
* @param name the name of this nested element
*/
@@ -145,7 +145,7 @@
}
/**
- * Set the type of this element. This is the name of an
+ * Sets the type of this element. This is the name of an
* Ant task or type which is to be used when this element is to be
* created. This is an alternative to specifying the class name directly
*
@@ -157,7 +157,7 @@
}
/**
- * Set the classname of the class to be used for the nested element.
+ * Sets the classname of the class to be used for the nested element.
* This specifies the class directly and is an alternative to specifying
* the Ant type name.
*
@@ -170,7 +170,7 @@
}
/**
- * Add a nested element definition.
+ * Adds a nested element definition.
*
* @param nestedElement the nested element definition.
*/
@@ -179,7 +179,7 @@
}
/**
- * Define the script.
+ * Defines the script.
*/
public void execute() {
if (name == null) {
@@ -188,10 +188,15 @@
}
if (helper.getLanguage() == null) {
- throw new BuildException("<scriptdef> requires a language attribute "
+ throw new BuildException("scriptdef requires a language attribute "
+ "to specify the script language");
}
+ if (helper.getSrc() == null && helper.getEncoding() != null) {
+ throw new BuildException("scriptdef requires a src attribute "
+ + "if the encoding is set");
+ }
+
// Check if need to set the loader
if (getAntlibClassLoader() != null || hasCpDelegate()) {
helper.setClassLoader(createLoader());
@@ -237,7 +242,6 @@
+ "attributes");
}
-
nestedElementMap.put(nestedElement.name, nestedElement);
}
@@ -253,7 +257,7 @@
}
/**
- * Find or create the script repository - it is stored in the project.
+ * Finds or creates the script repository - it is stored in the project.
* This method is synchronized on the project under {@link MagicNames#SCRIPT_REPOSITORY}
* @return the current script repository registered as a reference.
*/
@@ -273,7 +277,7 @@
}
/**
- * Create a nested element to be configured.
+ * Creates a nested element to be configured.
*
* @param elementName the name of the nested element.
* @return object representing the element name.
@@ -318,7 +322,7 @@
}
/**
- * Execute the script.
+ * Executes the script.
*
* @param attributes collection of attributes
* @param elements a list of nested element values.
@@ -330,7 +334,7 @@
}
/**
- * Execute the script.
+ * Executes the script.
* This is called by the script instance to execute the script for this
* definition.
*
@@ -368,7 +372,17 @@
}
/**
- * Load the script from an external file ; optional.
+ * Defines the compilation feature ; optional.
+ *
+ * @param compiled enables the script compilation if available.
+ * @since Ant 1.10.2
+ */
+ public void setCompiled(boolean compiled) {
+ helper.setCompiled(compiled);
+ }
+
+ /**
+ * Loads the script from an external file ; optional.
*
* @param file the file containing the script source.
*/
@@ -377,7 +391,17 @@
}
/**
- * Set the script text.
+ * Sets the encoding of the script from an external file ; optional.
+ *
+ * @param encoding the encoding of the file containing the script source.
+ * @since Ant 1.10.2
+ */
+ public void setEncoding(String encoding) {
+ helper.setEncoding(encoding);
+ }
+
+ /**
+ * Sets the script text.
*
* @param text a component of the script text to be added.
*/
@@ -386,12 +410,11 @@
}
/**
- * Add any source resource.
- * @since Ant1.7.1
+ * Adds any source resource.
+ * @since Ant 1.7.1
* @param resource source of script
*/
public void add(ResourceCollection resource) {
helper.add(resource);
}
}
-
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java b/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
index d1675a8..92dd348 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
@@ -36,7 +36,7 @@
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project;
-
+import org.apache.tools.ant.util.FileUtils;
/**
@@ -137,9 +137,7 @@
audioClip.drain();
}
} finally {
- if (audioClip != null) {
- audioClip.close();
- }
+ FileUtils.close(audioClip);
}
} else {
project.log("Can't get data from file " + file.getName());
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
index a04dfef..7d49709 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
@@ -495,9 +495,7 @@
*/
private void writeToFile(final String from, final boolean append, final File to)
throws IOException {
- FileWriter out = null;
- try {
- out = new FileWriter(to.getAbsolutePath(), append);
+ try (FileWriter out = new FileWriter(to.getAbsolutePath(), append)) {
final StringReader in = new StringReader(from);
final char[] buffer = new char[BUFFER_SIZE];
int bytesRead;
@@ -509,10 +507,6 @@
out.write(buffer, 0, bytesRead);
}
out.flush();
- } finally {
- if (out != null) {
- out.close();
- }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/xz/Unxz.java b/src/main/org/apache/tools/ant/taskdefs/optional/xz/Unxz.java
new file mode 100644
index 0000000..a98ae6d
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/xz/Unxz.java
@@ -0,0 +1,93 @@
+/*
+ * 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.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.Unpack;
+import org.apache.tools.ant.util.FileUtils;
+import org.tukaani.xz.XZInputStream;
+
+/**
+ * Expands a file that has been compressed 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 Unxz extends Unpack {
+ private static final int BUFFER_SIZE = 8 * 1024;
+ private static final String DEFAULT_EXTENSION = ".xz";
+
+ /**
+ * Get the default extension.
+ * @return the value ".xz"
+ */
+ protected String getDefaultExtension() {
+ return DEFAULT_EXTENSION;
+ }
+
+ /**
+ * Implement the gunzipping.
+ */
+ protected void extract() {
+ if (srcResource.getLastModified() > dest.lastModified()) {
+ log("Expanding " + srcResource.getName() + " to "
+ + dest.getAbsolutePath());
+
+ FileOutputStream out = null;
+ XZInputStream zIn = null;
+ InputStream fis = null;
+ try {
+ out = new FileOutputStream(dest);
+ fis = srcResource.getInputStream();
+ zIn = new XZInputStream(fis);
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int count = 0;
+ do {
+ out.write(buffer, 0, count);
+ count = zIn.read(buffer, 0, buffer.length);
+ } while (count != -1);
+ } catch (IOException ioe) {
+ String msg = "Problem expanding xz " + ioe.getMessage();
+ throw new BuildException(msg, ioe, getLocation());
+ } finally {
+ FileUtils.close(fis);
+ FileUtils.close(out);
+ FileUtils.close(zIn);
+ }
+ }
+ }
+
+ /**
+ * Whether this task can deal with non-file resources.
+ *
+ * <p>This implementation returns true only.</p>
+ * @return true
+ */
+ protected boolean supportsNonFileResources() {
+ return true;
+ }
+}
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 0000000..d88f910
--- /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.
+ *
+ * <p>This implementation always returns true only.</p>
+ * @return true
+ */
+ protected boolean supportsNonFileResources() {
+ return true;
+ }
+}
diff --git a/src/main/org/apache/tools/ant/types/AbstractFileSet.java b/src/main/org/apache/tools/ant/types/AbstractFileSet.java
index e3b8aa8..92d5ace 100644
--- a/src/main/org/apache/tools/ant/types/AbstractFileSet.java
+++ b/src/main/org/apache/tools/ant/types/AbstractFileSet.java
@@ -36,18 +36,21 @@
import org.apache.tools.ant.types.selectors.DepthSelector;
import org.apache.tools.ant.types.selectors.DifferentSelector;
import org.apache.tools.ant.types.selectors.ExtendSelector;
+import org.apache.tools.ant.types.selectors.ExecutableSelector;
import org.apache.tools.ant.types.selectors.FileSelector;
import org.apache.tools.ant.types.selectors.FilenameSelector;
import org.apache.tools.ant.types.selectors.MajoritySelector;
import org.apache.tools.ant.types.selectors.NoneSelector;
import org.apache.tools.ant.types.selectors.NotSelector;
import org.apache.tools.ant.types.selectors.OrSelector;
+import org.apache.tools.ant.types.selectors.OwnedBySelector;
import org.apache.tools.ant.types.selectors.PresentSelector;
import org.apache.tools.ant.types.selectors.ReadableSelector;
import org.apache.tools.ant.types.selectors.SelectSelector;
import org.apache.tools.ant.types.selectors.SelectorContainer;
import org.apache.tools.ant.types.selectors.SelectorScanner;
import org.apache.tools.ant.types.selectors.SizeSelector;
+import org.apache.tools.ant.types.selectors.SymlinkSelector;
import org.apache.tools.ant.types.selectors.TypeSelector;
import org.apache.tools.ant.types.selectors.WritableSelector;
import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector;
@@ -806,6 +809,27 @@
}
/**
+ * @since 1.10.0
+ */
+ public void addExecutable(ExecutableSelector e) {
+ appendSelector(e);
+ }
+
+ /**
+ * @since 1.10.0
+ */
+ public void addSymlink(SymlinkSelector e) {
+ appendSelector(e);
+ }
+
+ /**
+ * @since 1.10.0
+ */
+ public void addOwnedBy(OwnedBySelector o) {
+ appendSelector(o);
+ }
+
+ /**
* Add an arbitrary selector.
* @param selector the <code>FileSelector</code> to add.
* @since Ant 1.6
diff --git a/src/main/org/apache/tools/ant/types/defaults.properties b/src/main/org/apache/tools/ant/types/defaults.properties
index 29771db..160c7a7 100644
--- a/src/main/org/apache/tools/ant/types/defaults.properties
+++ b/src/main/org/apache/tools/ant/types/defaults.properties
@@ -94,6 +94,7 @@
javaresource=org.apache.tools.ant.types.resources.JavaResource
multirootfileset=org.apache.tools.ant.types.resources.MultiRootFileSet
javaconstant=org.apache.tools.ant.types.resources.JavaConstantResource
+xzresource=org.apache.tools.ant.types.optional.xz.XzResource
#tokenizer implementations
linetokenizer=org.apache.tools.ant.util.LineTokenizer
diff --git a/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java b/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java
index df5a3ce..a4a288b 100644
--- a/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java
+++ b/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java
@@ -155,4 +155,14 @@
public void setSetBeans(boolean setBeans) {
helper.setSetBeans(setBeans);
}
+
+ /**
+ * Set the encoding of the script from an external file ; optional.
+ *
+ * @param encoding the encoding of the file containing the script source.
+ * @since Ant 1.10.2
+ */
+ public void setEncoding(String encoding) {
+ helper.setEncoding(encoding);
+ }
}
diff --git a/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java b/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java
index 3f6ec88..3b0f1a1 100644
--- a/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java
+++ b/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java
@@ -180,4 +180,14 @@
public void setSetBeans(boolean setBeans) {
helper.setSetBeans(setBeans);
}
+
+ /**
+ * Set the encoding of the script from an external file ; optional.
+ *
+ * @param encoding the encoding of the file containing the script source.
+ * @since Ant 1.10.2
+ */
+ public void setEncoding(String encoding) {
+ helper.setEncoding(encoding);
+ }
}
diff --git a/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java b/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java
index ca28f69..9225840 100644
--- a/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java
+++ b/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java
@@ -220,4 +220,13 @@
this.selected = selected;
}
+ /**
+ * Set the encoding of the script from an external file ; optional.
+ *
+ * @param encoding the encoding of the file containing the script source.
+ * @since Ant 1.10.2
+ */
+ public void setEncoding(String encoding) {
+ helper.setEncoding(encoding);
+ }
}
diff --git a/src/main/org/apache/tools/ant/types/optional/xz/XzResource.java b/src/main/org/apache/tools/ant/types/optional/xz/XzResource.java
new file mode 100644
index 0000000..dfd02e7
--- /dev/null
+++ b/src/main/org/apache/tools/ant/types/optional/xz/XzResource.java
@@ -0,0 +1,77 @@
+/*
+ * 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.types.optional.xz;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import org.apache.tools.ant.types.resources.CompressedResource;
+import org.tukaani.xz.LZMA2Options;
+import org.tukaani.xz.XZInputStream;
+import org.tukaani.xz.XZOutputStream;
+
+/**
+ * A XZ compressed resource.
+ *
+ * <p>Wraps around another resource, delegates all queries to that
+ * other resource but uncompresses/compresses streams on the fly.</p>
+ *
+ * @since Ant 1.10.1
+ */
+public class XzResource extends CompressedResource {
+
+ /** A no-arg constructor */
+ public XzResource() {
+ }
+
+ /**
+ * Constructor with another resource to wrap.
+ * @param other the resource to wrap.
+ */
+ public XzResource(org.apache.tools.ant.types.ResourceCollection other) {
+ super(other);
+ }
+
+ /**
+ * Decompress on the fly using java.util.zip.XZInputStream.
+ * @param in the stream to wrap.
+ * @return the wrapped stream.
+ * @throws IOException if there is a problem.
+ */
+ protected InputStream wrapStream(InputStream in) throws IOException {
+ return new XZInputStream(in);
+ }
+
+ /**
+ * Compress on the fly using java.util.zip.XZOutStream.
+ * @param out the stream to wrap.
+ * @return the wrapped stream.
+ * @throws IOException if there is a problem.
+ */
+ protected OutputStream wrapStream(OutputStream out) throws IOException {
+ return new XZOutputStream(out, new LZMA2Options());
+ }
+
+ /**
+ * Get the name of the compression method.
+ * @return the string "XZ".
+ */
+ protected String getCompressionName() {
+ return "XZ";
+ }
+}
diff --git a/src/main/org/apache/tools/ant/types/resources/ResourceList.java b/src/main/org/apache/tools/ant/types/resources/ResourceList.java
index da83ea9..fbb226c 100644
--- a/src/main/org/apache/tools/ant/types/resources/ResourceList.java
+++ b/src/main/org/apache/tools/ant/types/resources/ResourceList.java
@@ -196,16 +196,13 @@
crh.setFilterChains(filterChains);
crh.setProject(getProject());
Union streamResources = new Union();
- BufferedReader reader = new BufferedReader(crh.getAssembledReader());
- try {
+ try (BufferedReader reader = new BufferedReader(crh.getAssembledReader())) {
streamResources.setCache(true);
String line = null;
while ((line = reader.readLine()) != null) {
streamResources.add(parse(line));
}
- } finally {
- reader.close();
}
return streamResources;
diff --git a/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java b/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java
index b80816d..3039d48 100644
--- a/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java
+++ b/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java
@@ -313,6 +313,27 @@
}
/**
+ * @since 1.10.0
+ */
+ public void addExecutable(ExecutableSelector e) {
+ appendSelector(e);
+ }
+
+ /**
+ * @since 1.10.0
+ */
+ public void addSymlink(SymlinkSelector e) {
+ appendSelector(e);
+ }
+
+ /**
+ * @since 1.10.0
+ */
+ public void addOwnedBy(OwnedBySelector o) {
+ appendSelector(o);
+ }
+
+ /**
* add an arbitrary selector
* @param selector the selector to add
* @since Ant 1.6
diff --git a/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java b/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java
index 1edf085..3fcccd7 100644
--- a/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java
+++ b/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java
@@ -316,6 +316,27 @@
}
/**
+ * @since 1.10.0
+ */
+ public void addExecutable(ExecutableSelector e) {
+ appendSelector(e);
+ }
+
+ /**
+ * @since 1.10.0
+ */
+ public void addSymlink(SymlinkSelector e) {
+ appendSelector(e);
+ }
+
+ /**
+ * @since 1.10.0
+ */
+ public void addOwnedBy(OwnedBySelector o) {
+ appendSelector(o);
+ }
+
+ /**
* add an arbitrary selector
* @param selector the selector to add
* @since Ant 1.6
diff --git a/src/main/org/apache/tools/ant/types/selectors/ExecutableSelector.java b/src/main/org/apache/tools/ant/types/selectors/ExecutableSelector.java
new file mode 100644
index 0000000..891b795
--- /dev/null
+++ b/src/main/org/apache/tools/ant/types/selectors/ExecutableSelector.java
@@ -0,0 +1,51 @@
+/*
+ * 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.types.selectors;
+
+import java.nio.file.Files;
+import java.io.File;
+
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.resources.FileProvider;
+import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
+
+/**
+ * A selector that selects executable files.
+ *
+ * <p>Executable is defined in terms of {@link
+ * java.nio.file.Files#isExecutable}, this means the selector will
+ * accept any file that exists and is executable by the
+ * application.</p>
+ *
+ * @since Ant 1.10.0
+ */
+public class ExecutableSelector implements FileSelector, ResourceSelector {
+
+ public boolean isSelected(File basedir, String filename, File file) {
+ return file != null && Files.isExecutable(file.toPath());
+ }
+
+ public boolean isSelected(Resource r) {
+ FileProvider fp = r.as(FileProvider.class);
+ if (fp != null) {
+ return isSelected(null, null, fp.getFile());
+ }
+ return false;
+ }
+}
diff --git a/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java b/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java
new file mode 100644
index 0000000..32aaa8d
--- /dev/null
+++ b/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java
@@ -0,0 +1,78 @@
+/*
+ * 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.types.selectors;
+
+import java.nio.file.Files;
+import java.nio.file.attribute.UserPrincipal;
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.resources.FileProvider;
+import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
+
+/**
+ * A selector that selects files based on their owner.
+ *
+ * <p>Owner is defined in terms of {@link
+ * java.nio.file.Files#getOwner}, this means the selector will accept
+ * any file that exists and is owned by the given user. If the {@code
+ * getOwner} method throws an {@code UnsupportedOperattionException}
+ * the file in question is not included.</p>
+ *
+ * @since Ant 1.10.0
+ */
+public class OwnedBySelector implements FileSelector, ResourceSelector {
+
+ private String owner;
+
+ /**
+ * Sets the User-Name to look for.
+ * @param owner the user name
+ */
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ @Override
+ public boolean isSelected(File basedir, String filename, File file) {
+ if (owner == null) {
+ throw new BuildException("the owner attribute is required");
+ }
+ if (file != null) {
+ try {
+ UserPrincipal user = Files.getOwner(file.toPath());
+ return user != null && owner.equals(user.getName());
+ } catch (UnsupportedOperationException | IOException ex) {
+ // => not the expected owner
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isSelected(Resource r) {
+ FileProvider fp = r.as(FileProvider.class);
+ if (fp != null) {
+ return isSelected(null, null, fp.getFile());
+ }
+ return false;
+ }
+}
diff --git a/src/main/org/apache/tools/ant/types/selectors/SymlinkSelector.java b/src/main/org/apache/tools/ant/types/selectors/SymlinkSelector.java
new file mode 100644
index 0000000..28c3bcb
--- /dev/null
+++ b/src/main/org/apache/tools/ant/types/selectors/SymlinkSelector.java
@@ -0,0 +1,50 @@
+/*
+ * 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.types.selectors;
+
+import java.nio.file.Files;
+import java.io.File;
+
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.resources.FileProvider;
+import org.apache.tools.ant.types.resources.selectors.ResourceSelector;
+
+/**
+ * A selector that selects symbolic links.
+ *
+ * <p>Executable is defined in terms of {@link
+ * java.nio.file.Files#isSymbolicLink}, this means the selector will
+ * accept any file that exists and is a symbolic link.</p>
+ *
+ * @since Ant 1.10.0
+ */
+public class SymlinkSelector implements FileSelector, ResourceSelector {
+
+ public boolean isSelected(File basedir, String filename, File file) {
+ return file != null && Files.isSymbolicLink(file.toPath());
+ }
+
+ public boolean isSelected(Resource r) {
+ FileProvider fp = r.as(FileProvider.class);
+ if (fp != null) {
+ return isSelected(null, null, fp.getFile());
+ }
+ return false;
+ }
+}
diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java
index b22f517..0c314b2 100644
--- a/src/main/org/apache/tools/ant/util/FileUtils.java
+++ b/src/main/org/apache/tools/ant/util/FileUtils.java
@@ -1445,13 +1445,7 @@
* @param device output writer, can be null.
*/
public static void close(Writer device) {
- if (null != device) {
- try {
- device.close();
- } catch (IOException e) {
- //ignore
- }
- }
+ close((AutoCloseable) device);
}
/**
@@ -1461,13 +1455,7 @@
* @param device Reader, can be null.
*/
public static void close(Reader device) {
- if (null != device) {
- try {
- device.close();
- } catch (IOException e) {
- //ignore
- }
- }
+ close((AutoCloseable) device);
}
/**
@@ -1477,13 +1465,7 @@
* @param device stream, can be null.
*/
public static void close(OutputStream device) {
- if (null != device) {
- try {
- device.close();
- } catch (IOException e) {
- //ignore
- }
- }
+ close((AutoCloseable) device);
}
/**
@@ -1493,13 +1475,7 @@
* @param device stream, can be null.
*/
public static void close(InputStream device) {
- if (null != device) {
- try {
- device.close();
- } catch (IOException e) {
- //ignore
- }
- }
+ close((AutoCloseable) device);
}
/**
@@ -1510,13 +1486,7 @@
* @since Ant 1.8.0
*/
public static void close(Channel device) {
- if (null != device) {
- try {
- device.close();
- } catch (IOException e) {
- //ignore
- }
- }
+ close((AutoCloseable) device);
}
/**
@@ -1544,6 +1514,24 @@
}
/**
+ * Close an {@link AutoCloseable} without throwing any exception
+ * if something went wrong. Do not attempt to close it if the
+ * argument is null.
+ *
+ * @param ac AutoCloseable, can be null.
+ * @since Ant 1.10.0
+ */
+ public static void close(AutoCloseable ac) {
+ if (null != ac) {
+ try {
+ ac.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }
+
+ /**
* Delete the file with {@link File#delete()} if the argument is not null.
* Do nothing on a null argument.
* @param file file to delete.
diff --git a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
index a551c0f..84e82fd 100644
--- a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
+++ b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
@@ -258,8 +258,8 @@
* Compares the current Java version to the passed in String -
* assumes the argument is one of the constants defined in this
* class.
- * Note that Ant now requires JDK 1.5+ so {@link #JAVA_1_0} through
- * {@link #JAVA_1_4} need no longer be tested for.
+ * Note that Ant now requires JDK 1.8+ so {@link #JAVA_1_0} through
+ * {@link #JAVA_1_7} need no longer be tested for.
* @param version the version to check against the current version.
* @return true if the version of Java is the same as the given version.
* @since Ant 1.5
@@ -273,8 +273,8 @@
* Compares the current Java version to the passed in String -
* assumes the argument is one of the constants defined in this
* class.
- * Note that Ant now requires JDK 1.5+ so {@link #JAVA_1_0} through
- * {@link #JAVA_1_4} need no longer be tested for.
+ * Note that Ant now requires JDK 1.8+ so {@link #JAVA_1_0} through
+ * {@link #JAVA_1_7} need no longer be tested for.
* @param version the version to check against the current version.
* @return true if the version of Java is the same or higher than the
* given version.
diff --git a/src/main/org/apache/tools/ant/util/PermissionUtils.java b/src/main/org/apache/tools/ant/util/PermissionUtils.java
new file mode 100644
index 0000000..ad363f0
--- /dev/null
+++ b/src/main/org/apache/tools/ant/util/PermissionUtils.java
@@ -0,0 +1,237 @@
+/*
+ * 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.util;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.PosixFileAttributeView;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.resources.ArchiveResource;
+import org.apache.tools.ant.types.resources.FileProvider;
+
+/**
+ * Contains helper methods for dealing with {@link
+ * PosixFilePermission} or the traditional Unix mode representation of
+ * permissions.
+ *
+ * @since Ant 1.10.0
+ */
+public class PermissionUtils {
+
+ private PermissionUtils() { }
+
+ /**
+ * Translates a set of permissons into a Unix stat(2) {@code
+ * st_mode} result.
+ * @param permissions the permissions
+ * @param type the file type
+ * @return the "mode"
+ */
+ public static int modeFromPermissions(Set<PosixFilePermission> permissions,
+ FileType type) {
+ int mode;
+ switch (type) {
+ case SYMLINK:
+ mode = 012;
+ break;
+ case REGULAR_FILE:
+ mode = 010;
+ break;
+ case DIR:
+ mode = 004;
+ break;
+ default:
+ // OTHER could be a character or block device, a socket or a FIFO - so don't set anything
+ mode = 0;
+ break;
+ }
+ mode <<= 3;
+ mode <<= 3; // we don't support sticky, setuid, setgid
+ mode |= modeFromPermissions(permissions, "OWNER");
+ mode <<= 3;
+ mode |= modeFromPermissions(permissions, "GROUP");
+ mode <<= 3;
+ mode |= modeFromPermissions(permissions, "OTHERS");
+ return mode;
+ }
+
+ /**
+ * Translates a Unix stat(2) {@code st_mode} compatible value into
+ * a set of permissions.
+ * @param mode the "mode"
+ * @return set of permissions
+ */
+ public static Set<PosixFilePermission> permissionsFromMode(int mode) {
+ Set<PosixFilePermission> permissions = EnumSet.noneOf(PosixFilePermission.class);
+ addPermissions(permissions, "OTHERS", mode);
+ addPermissions(permissions, "GROUP", mode >> 3);
+ addPermissions(permissions, "OWNER", mode >> 6);
+ return permissions;
+ }
+
+ /**
+ * Sets permissions on a {@link Resource} - doesn't do anything
+ * for unsupported resource types.
+ *
+ * <p>Supported types are:</p>
+ * <ul>
+ * <li>any {@link FileProvider}</li>
+ * <li>{@link ArchiveResource}</li>
+ * </ul>
+ *
+ * @param resource the resource to set permissions for
+ * @param permissions the permissions
+ * @param posixNotSupportedCallback optional callback that is
+ * invoked for a file provider resource if the file-system holding
+ * the file doesn't support PosixFilePermissions. The Path
+ * corresponding to the file is passed to the callback.
+ */
+ public static void setPermissions(Resource r, Set<PosixFilePermission> permissions,
+ Consumer<Path> posixNotSupportedCallback)
+ throws IOException {
+ FileProvider f = r.as(FileProvider.class);
+ if (f != null) {
+ Path p = f.getFile().toPath();
+ PosixFileAttributeView view =
+ Files.getFileAttributeView(p, PosixFileAttributeView.class);
+ if (view != null) {
+ view.setPermissions(permissions);
+ } else if (posixNotSupportedCallback != null) {
+ posixNotSupportedCallback.accept(p);
+ }
+ } else if (r instanceof ArchiveResource) {
+ ((ArchiveResource) r).setMode(modeFromPermissions(permissions,
+ FileType.of(r)));
+ }
+ }
+
+ /**
+ * Sets permissions of a {@link Resource} - returns an empty set
+ * for unsupported resource types or file systems that don't
+ * support PosixFilePermissions and no fallback has been
+ * provided..
+ *
+ * <p>Supported types are:</p>
+ * <ul>
+ * <li>any {@link FileProvider}</li>
+ * <li>{@link ArchiveResource}</li>
+ * </ul>
+ *
+ * @param resource the resource to read permissions from
+ * @param posixNotSupportedFallback optional fallback function to provide
+ * permissions for file system that don't support
+ * PosixFilePermissions. The Path corresponding to the file is
+ * passed to the callback.
+ * @return the permissions
+ */
+ public static Set<PosixFilePermission> getPermissions(Resource r,
+ Function<Path, Set<PosixFilePermission>> posixNotSupportedFallback)
+ throws IOException {
+ FileProvider f = r.as(FileProvider.class);
+ if (f != null) {
+ Path p = f.getFile().toPath();
+ PosixFileAttributeView view =
+ Files.getFileAttributeView(p, PosixFileAttributeView.class);
+ if (view != null) {
+ return view.readAttributes().permissions();
+ } else if (posixNotSupportedFallback != null) {
+ return posixNotSupportedFallback.apply(p);
+ }
+ } else if (r instanceof ArchiveResource) {
+ return permissionsFromMode(((ArchiveResource) r).getMode());
+ }
+ return EnumSet.noneOf(PosixFilePermission.class);
+ }
+
+ private static long modeFromPermissions(Set<PosixFilePermission> permissions,
+ String prefix) {
+ long mode = 0;
+ if (permissions.contains(PosixFilePermission.valueOf(prefix + "_READ"))) {
+ mode |= 4;
+ }
+ if (permissions.contains(PosixFilePermission.valueOf(prefix + "_WRITE"))) {
+ mode |= 2;
+ }
+ if (permissions.contains(PosixFilePermission.valueOf(prefix + "_EXECUTE"))) {
+ mode |= 1;
+ }
+ return mode;
+ }
+
+ private static void addPermissions(Set<PosixFilePermission> permissions,
+ String prefix, long mode) {
+ if ((mode & 1) == 1) {
+ permissions.add(PosixFilePermission.valueOf(prefix + "_EXECUTE"));
+ }
+ if ((mode & 2) == 2) {
+ permissions.add(PosixFilePermission.valueOf(prefix + "_WRITE"));
+ }
+ if ((mode & 4) == 4) {
+ permissions.add(PosixFilePermission.valueOf(prefix + "_READ"));
+ }
+ }
+
+ /**
+ * The supported types of files, maps to the {@code isFoo} methods
+ * in {@link java.nio.file.attribute.BasicFileAttributes}.
+ */
+ public enum FileType {
+ /** A regular file. */
+ REGULAR_FILE,
+ /** A directory. */
+ DIR,
+ /** A symbolic link. */
+ SYMLINK,
+ /** Something that is neither a regular file nor a directory nor a symbolic link. */
+ OTHER;
+
+ /**
+ * Determines the file type of a {@link Path}.
+ */
+ public static FileType of(Path p) throws IOException {
+ BasicFileAttributes attrs =
+ Files.readAttributes(p, BasicFileAttributes.class);
+ if (attrs.isRegularFile()) {
+ return FileType.REGULAR_FILE;
+ } else if (attrs.isDirectory()) {
+ return FileType.DIR;
+ } else if (attrs.isSymbolicLink()) {
+ return FileType.SYMLINK;
+ }
+ return FileType.OTHER;
+ }
+
+ /**
+ * Determines the file type of a {@link Resource}.
+ */
+ public static FileType of(Resource r) {
+ if (r.isDirectory()) {
+ return FileType.DIR;
+ }
+ return FileType.REGULAR_FILE;
+ }
+ }
+}
diff --git a/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java b/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
index b8aa01a..f2b6017 100644
--- a/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
+++ b/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
@@ -19,12 +19,13 @@
import java.io.BufferedReader;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -34,6 +35,8 @@
import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.PropertyResource;
+import org.apache.tools.ant.types.resources.StringResource;
/**
* This is a common abstract base case for script runners.
@@ -51,6 +54,11 @@
/** Script content */
private String script = "";
+ private String encoding;
+
+ /** Enable script compilation. */
+ private boolean compiled;
+
/** Project this runner is used in */
private Project project;
@@ -187,6 +195,33 @@
}
/**
+ * Whether to use script compilation if available.
+ * @since Ant 1.10.2
+ * @param compiled if true, compile the script if possible.
+ */
+ public final void setCompiled(boolean compiled) {
+ this.compiled = compiled;
+ }
+
+ /**
+ * Get the compiled attribute.
+ * @since Ant 1.10.2
+ * @return the attribute.
+ */
+ public final boolean getCompiled() {
+ return compiled;
+ }
+
+ /**
+ * Set encoding of the script from an external file; optional.
+ * @since Ant 1.10.2
+ * @param encoding encoding of the external file containing the script source.
+ */
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ /**
* Load the script from an external file; optional.
* @param file the file containing the script source.
*/
@@ -195,32 +230,52 @@
if (!file.exists()) {
throw new BuildException("file " + filename + " not found.");
}
+
+ InputStream in = null;
try {
- readSource(new FileReader(file), filename);
+ in = new FileInputStream(file);
} catch (FileNotFoundException e) {
//this can only happen if the file got deleted a short moment ago
throw new BuildException("file " + filename + " not found.");
}
+
+ final Charset charset;
+ if (null == encoding) {
+ charset = null;
+ } else {
+ charset = Charset.forName(encoding);
+ }
+
+ try {
+ readSource(in, filename, charset);
+ } finally {
+ FileUtils.close(in);
+ }
}
/**
* Read some source in from the given reader
* @param reader the reader; this is closed afterwards.
* @param name the name to use in error messages
+ * @param charset the encoding for the reader, may be null.
*/
- private void readSource(Reader reader, String name) {
- BufferedReader in = null;
+ private void readSource(InputStream in, String name, Charset charset) {
+ Reader reader = null;
try {
- in = new BufferedReader(reader);
- script += FileUtils.safeReadFully(in);
+ if (null == charset) {
+ reader = new InputStreamReader(in);
+ } else {
+ reader = new InputStreamReader(in, charset);
+ }
+ reader = new BufferedReader(reader);
+ script += FileUtils.safeReadFully(reader);
} catch (IOException ex) {
throw new BuildException("Failed to read " + name, ex);
} finally {
- FileUtils.close(in);
+ FileUtils.close(reader);
}
}
-
/**
* Add a resource to the source list.
* @since Ant 1.7.1
@@ -228,6 +283,15 @@
* @throws BuildException if the resource cannot be read
*/
public void loadResource(Resource sourceResource) {
+ if (sourceResource instanceof StringResource) {
+ script += ((StringResource) sourceResource).getValue();
+ return;
+ }
+ if (sourceResource instanceof PropertyResource) {
+ script += ((PropertyResource) sourceResource).getValue();
+ return;
+ }
+
String name = sourceResource.toLongString();
InputStream in = null;
try {
@@ -236,9 +300,14 @@
throw new BuildException("Failed to open " + name, e);
} catch (UnsupportedOperationException e) {
throw new BuildException(
- "Failed to open " + name + " -it is not readable", e);
+ "Failed to open " + name + " - it is not readable", e);
}
- readSource(new InputStreamReader(in), name);
+
+ try {
+ readSource(in, name, (Charset) null);
+ } finally {
+ FileUtils.close(in);
+ }
}
/**
@@ -356,5 +425,4 @@
Thread.currentThread().setContextClassLoader(
origLoader);
}
-
}
diff --git a/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java b/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java
index 9e814d9..fc1be2a 100644
--- a/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java
+++ b/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java
@@ -31,9 +31,11 @@
public class ScriptRunnerHelper {
private ClasspathUtils.Delegate cpDelegate = null;
private File srcFile;
+ private String encoding;
private String manager = "auto";
private String language;
private String text;
+ private boolean compiled = false;
private boolean setBeans = true;
private ProjectComponent projectComponent;
private ClassLoader scriptLoader = null;
@@ -53,6 +55,12 @@
*/
public ScriptRunnerBase getScriptRunner() {
ScriptRunnerBase runner = getRunner();
+ runner.setCompiled(compiled);
+
+ if (encoding != null) {
+ // set it first, because runner.setSrc() loads immediately the file
+ runner.setEncoding(encoding);
+ }
if (srcFile != null) {
runner.setSrc(srcFile);
}
@@ -108,6 +116,34 @@
}
/**
+ * Get the external script file ; optional.
+ * @return the file containing the script source.
+ * @since Ant 1.10.2
+ */
+ public File getSrc() {
+ return srcFile;
+ }
+
+ /**
+ * Set the encoding of the script from an external file ; optional.
+ *
+ * @param encoding the encoding of the file containing the script source.
+ * @since Ant 1.10.2
+ */
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ /**
+ * Get the external file encoding.
+ * @return the encoding of the file containing the script source.
+ * @since Ant 1.10.2
+ */
+ public String getEncoding() {
+ return encoding;
+ }
+
+ /**
* Add script text.
*
* @param text a component of the script text to be added.
@@ -143,6 +179,28 @@
}
/**
+ * Enable the compilation of the script if possible.
+ * If this is true and the compilation feature is available in
+ * the script engine, the script is compiled before the first
+ * evaluation, and should be cached for future evaluations.
+ * Otherwise, the script is evaluated each time.
+ * The default is false.
+ *
+ * @param compiled the value to set.
+ */
+ public void setCompiled(boolean compiled) {
+ this.compiled = compiled;
+ }
+
+ /**
+ * Get the compilation feature.
+ * @return the compilation feature.
+ */
+ public boolean getCompiled() {
+ return this.compiled;
+ }
+
+ /**
* Set the setbeans attribute.
* If this is true, <script> will create variables in the
* script instance for all
diff --git a/src/main/org/apache/tools/ant/util/StringUtils.java b/src/main/org/apache/tools/ant/util/StringUtils.java
index 4ce9ee3..6ee9c45 100644
--- a/src/main/org/apache/tools/ant/util/StringUtils.java
+++ b/src/main/org/apache/tools/ant/util/StringUtils.java
@@ -19,7 +19,11 @@
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.Vector;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
import org.apache.tools.ant.BuildException;
@@ -270,4 +274,57 @@
return string;
}
}
+
+ /**
+ * Joins the string representation of the elements of a collection to
+ * a joined string with a given separator.
+ * @param collection Collection of the data to be joined (may be null)
+ * @param separator Separator between elements (may be null)
+ * @return the joined string
+ */
+ public static String join(Collection<?> collection, CharSequence separator) {
+ if (collection == null) {
+ return "";
+ }
+ return collection.stream().map( o -> String.valueOf(o) ).collect(joining(separator));
+ }
+
+ /**
+ * Joins the string representation of the elements of an array to
+ * a joined string with a given separator.
+ * @param array Array of the data to be joined (may be null)
+ * @param separator Separator between elements (may be null)
+ * @return the joined string
+ */
+ public static String join(Object[] array, CharSequence separator) {
+ if (array == null) {
+ return "";
+ }
+ return join(Arrays.asList(array), separator);
+ }
+
+ private static Collector<CharSequence,?,String> joining(CharSequence separator) {
+ return separator == null ? Collectors.joining() : Collectors.joining(separator);
+ }
+
+
+ /**
+ * @param inputString String to trim
+ * @return null if the input string is null or empty or contain only empty spaces.
+ * It returns the input string without leading and trailing spaces otherwise.
+ *
+ */
+ public static String trimToNull(String inputString) {
+
+ if (inputString == null) {
+ return null;
+ }
+
+ String tmpString = inputString.trim();
+ if ("".equals(tmpString)) {
+ return null;
+ }
+ return tmpString;
+ }
+
}
diff --git a/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java b/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
index a312ff4..b05ed1f 100644
--- a/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
+++ b/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
@@ -268,16 +268,10 @@
}
} else {
// must be a zip of some sort
- ZipFile zipFile = null;
- try {
- zipFile = new ZipFile(element);
+ try (ZipFile zipFile = new ZipFile(element)) {
if (zipFile.getEntry(resourceLocation) != null) {
return element;
}
- } finally {
- if (zipFile != null) {
- zipFile.close();
- }
}
}
}
diff --git a/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java b/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
index 7a5cfa4..997af7a 100644
--- a/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
+++ b/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
@@ -21,6 +21,8 @@
import java.util.Iterator;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.ReflectWrapper;
import org.apache.tools.ant.util.ScriptRunnerBase;
@@ -30,6 +32,7 @@
*/
public class JavaxScriptRunner extends ScriptRunnerBase {
private ReflectWrapper engine;
+ private ReflectWrapper compiledScript;
/**
* Get the name of the manager prefix.
@@ -79,28 +82,71 @@
checkLanguage();
ClassLoader origLoader = replaceContextLoader();
try {
+
+ if (getCompiled()) {
+
+ final String compiledScriptRefName = MagicNames.SCRIPT_CACHE + "." + getLanguage() +
+ "." + getScript().hashCode() + "." +
+ (null == getClass().getClassLoader() ? 0 : getClass().getClassLoader().hashCode());
+
+ if (null == compiledScript) {
+ compiledScript = getProject().getReference(compiledScriptRefName);
+ }
+
+ if (null == compiledScript) {
+
+ final ReflectWrapper engine = createEngine();
+ if (engine == null) {
+ throw new BuildException(
+ "Unable to create javax script engine for "
+ + getLanguage());
+ }
+
+ final Class engineClass = Class.forName("javax.script.ScriptEngine", true, getClass().getClassLoader());
+ final Class compilableClass = Class.forName("javax.script.Compilable", true, getClass().getClassLoader());
+ final Object wrappedObject = engine.getObject();
+
+ if (engineClass.isAssignableFrom(wrappedObject.getClass()) &&
+ compilableClass.isAssignableFrom(wrappedObject.getClass())) {
+
+ getProject().log("compile script " + execName, Project.MSG_VERBOSE);
+
+ final Object compiled = engine.invoke("compile", String.class, getScript());
+ compiledScript = new ReflectWrapper(compiled);
+
+ } else {
+ getProject().log("script compilation not available for " + execName, Project.MSG_VERBOSE);
+ compiledScript = new ReflectWrapper(null);
+ }
+ getProject().addReference(compiledScriptRefName, compiledScript);
+ }
+
+ if (null != compiledScript.getObject()) {
+
+ final ReflectWrapper simpleBindings = new ReflectWrapper(getClass().getClassLoader(), "javax.script.SimpleBindings");
+
+ applyBindings(simpleBindings);
+
+ getProject().log("run compiled script " + compiledScriptRefName, Project.MSG_DEBUG);
+
+ final Class bindingsClass = Class.forName("javax.script.Bindings", true, getClass().getClassLoader());
+
+ return compiledScript.invoke("eval", bindingsClass, simpleBindings.getObject());
+ }
+ }
+
ReflectWrapper engine = createEngine();
if (engine == null) {
throw new BuildException(
"Unable to create javax script engine for "
+ getLanguage());
}
- for (Iterator i = getBeans().keySet().iterator(); i.hasNext();) {
- String key = (String) i.next();
- Object value = getBeans().get(key);
- if ("FX".equalsIgnoreCase(getLanguage())) {
- engine.invoke(
- "put", String.class, key
- + ":" + value.getClass().getName(),
- Object.class, value);
- } else {
- engine.invoke(
- "put", String.class, key,
- Object.class, value);
- }
- }
+
+ applyBindings(engine);
+
// execute the script
return engine.invoke("eval", String.class, getScript());
+
} catch (BuildException be) {
//catch and rethrow build exceptions
@@ -126,6 +172,17 @@
}
}
+ private void applyBindings(ReflectWrapper engine) {
+ for (Iterator i = getBeans().keySet().iterator(); i.hasNext();) {
+ String key = (String) i.next();
+ Object value = getBeans().get(key);
+ if ("FX".equalsIgnoreCase(getLanguage())) {
+ key += ":" + value.getClass().getName();
+ }
+ engine.invoke("put", String.class, key, Object.class, value);
+ }
+ }
+
private ReflectWrapper createEngine() {
if (engine != null) {
return engine;
diff --git a/src/tests/antunit/antunit-base.xml b/src/tests/antunit/antunit-base.xml
index 9863f3f..e8b3529 100644
--- a/src/tests/antunit/antunit-base.xml
+++ b/src/tests/antunit/antunit-base.xml
@@ -28,10 +28,6 @@
<property name="test4.jar" location="${antunit.tmpdir}/test4.jar"/>
<property name="test5.jar" location="${antunit.tmpdir}/test5.jar"/>
<available property="jdk9+" classname="java.lang.module.ModuleDescriptor"/>
- <available property="jdk1.8+" classname="java.lang.reflect.Executable"/>
- <available property="jdk1.7+" classname="java.nio.file.FileSystem"/>
- <available property="jdk1.6+" classname="java.net.CookieStore"/>
- <available property="jdk1.5+" classname="java.net.Proxy"/>
<condition property="build.sysclasspath.only">
<equals arg1="${build.sysclasspath}" arg2="only"/>
</condition>
diff --git a/src/tests/antunit/taskdefs/apt-test.xml b/src/tests/antunit/taskdefs/apt-test.xml
deleted file mode 100644
index 9b24001..0000000
--- a/src/tests/antunit/taskdefs/apt-test.xml
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0"?>
-<!--
- 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.
--->
-<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
- <import file="../antunit-base.xml" />
- <!-- apt tests -->
-
- <property name="build.dir" location="aptbuild" />
- <property name="classes.dir" location="${build.dir}/classes" />
- <property name="classes2.dir" location="${build.dir}/classes2" />
- <property name="preprocess.dir" location="${build.dir}/source" />
- <property name="src" location="apt" />
-
- <property name="AptExample.class" location="${classes.dir}/AptExample.class" />
-
- <macrodef name="assertCompiled">
- <attribute name="file" />
- <sequential >
- <fail message="not found: @{file}">
- <condition>
- <not>
- <available file="@{file}" />
- </not>
- </condition>
- </fail>
- </sequential>
- </macrodef>
-
- <macrodef name="assertProcessed">
- <sequential>
- <au:assertLogContains text="DistributedAnnotationProcessor-is-go"/>
- <au:assertLogContains text="[-Abuild.dir="/>
- <au:assertLogContains text="visiting DistributedAnnotationFactory"/>
- </sequential>
- </macrodef>
-
- <presetdef name="assertAptExampleCompiled">
- <assertCompiled file="${AptExample.class}"/>
- </presetdef>
-
- <target name="tearDown" depends="antunit-base.tearDown">
- <delete dir="${build.dir}"/>
- </target>
-
- <target name="setUp">
- <mkdir dir="${classes.dir}"/>
- <mkdir dir="${classes2.dir}"/>
- <mkdir dir="${preprocess.dir}"/>
- </target>
-
- <target name="testApt" depends="setUp" unless="jdk1.8+">
- <apt srcdir="${src}"
- destdir="${classes.dir}"
- debug="on"
- compile="true"
- preprocessdir="${preprocess.dir}">
- </apt>
- <assertAptExampleCompiled />
- </target>
-
- <target name="testAptFork" depends="setUp" unless="jdk1.8+">
- <apt srcdir="${src}"
- destdir="${classes.dir}"
- debug="on"
- compile="true"
- fork="true"
- preprocessdir="${preprocess.dir}">
- </apt>
- <assertAptExampleCompiled />
- </target>
-
- <target name="testAptForkFalse" depends="setUp" unless="jdk1.8+">
- <apt srcdir="${src}"
- destdir="${classes.dir}"
- debug="on"
- compile="true"
- fork="false"
- preprocessdir="${preprocess.dir}">
- </apt>
- <assertAptExampleCompiled />
- <au:assertLogContains text="Apt only runs in its own JVM; fork=false option ignored"/>
-
- </target>
-
- <target name="testListAnnotationTypes" depends="setUp" unless="jdk1.8+">
- <apt srcdir="${src}"
- destdir="${classes.dir}"
- debug="on"
- compile="true"
- preprocessdir="${preprocess.dir}">
- <compilerarg value="-XListAnnotationTypes" />
- <compilerarg value="-Xlint:deprecation" />
- </apt>
-
- <assertAptExampleCompiled />
- <au:assertLogContains text="Set of annotations found:"/>
- <au:assertLogContains text="Distributed"/>
- </target>
-
-
- <!-- use the factory we compiled. To avoid trouble
- we deliver into a version in a new classpath, otherwise
- the dependency logic will not run Apt-->
- <target name="testAptNewFactory" depends="testApt" unless="jdk1.8+">
- <apt srcdir="${src}"
- destdir="${classes2.dir}"
- debug="on"
- compile="true"
- factory="DistributedAnnotationFactory"
- preprocessdir="${preprocess.dir}">
- <factorypath path="${classes.dir}" />
- <option name="build.dir" value="${build.dir}" />
- </apt>
- <assertAptExampleCompiled />
- <assertProcessed />
- </target>
-
- <target name="testAptNewFactoryFork" depends="testApt" unless="jdk1.8+">
- <apt srcdir="${src}"
- destdir="${classes2.dir}"
- debug="on"
- compile="true"
- fork="true"
- factory="DistributedAnnotationFactory"
- preprocessdir="${preprocess.dir}">
- <factorypath path="${classes.dir}" />
- <option name="build.dir" value="${build.dir}" />
- </apt>
- <assertAptExampleCompiled />
- <assertProcessed />
- </target>
-
- <target name="testAptUnderJDK18" if="jdk1.8+">
- <au:expectfailure expectedMessage="apt does not exist under Java 1.8 and higher">
- <apt srcdir="${src}"
- destdir="${classes.dir}"
- debug="on"
- compile="true"
- fork="true"
- preprocessdir="${preprocess.dir}">
- </apt>
- </au:expectfailure>
- </target>
-</project>
\ No newline at end of file
diff --git a/src/tests/antunit/taskdefs/apt/AptExample.java b/src/tests/antunit/taskdefs/apt/AptExample.java
deleted file mode 100644
index 9d6fcba..0000000
--- a/src/tests/antunit/taskdefs/apt/AptExample.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.
- *
- */
-/**
- */
-@Distributed(
- protocol="CORBA",
- distribution=Distributed.DistributionTypes.FEDERATED
- )
-public class AptExample {
-}
diff --git a/src/tests/antunit/taskdefs/apt/Distributed.java b/src/tests/antunit/taskdefs/apt/Distributed.java
deleted file mode 100644
index ebc3467..0000000
--- a/src/tests/antunit/taskdefs/apt/Distributed.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.lang.annotation.Annotation;
-import java.lang.annotation.Target;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- */
-@Documented
-@Retention(value = RetentionPolicy.RUNTIME)
-@Target(value = ElementType.TYPE)
-public @interface Distributed {
-
- public DistributionTypes distribution() default DistributionTypes.LOCAL;
-
- public String protocol() default "RMI";
-
- public enum DistributionTypes { SINGLETON, LOCAL, FAULT_TOLERANT, FEDERATED, MOBILE};
-
-
-}
diff --git a/src/tests/antunit/taskdefs/apt/DistributedAnnotationFactory.java b/src/tests/antunit/taskdefs/apt/DistributedAnnotationFactory.java
deleted file mode 100644
index a8fb633..0000000
--- a/src/tests/antunit/taskdefs/apt/DistributedAnnotationFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-import java.util.Collections;
-
-
-/**
- * This was the first piece of Java1.5 code in the source tree.
- * @since 20050-03-09T21:29:25Z
- */
-public class DistributedAnnotationFactory implements AnnotationProcessorFactory {
-
- private static final Collection<String> supportedAnnotations
- = Collections.unmodifiableCollection(Arrays.asList("*"));
-
- public Collection<String> supportedOptions() {
- return Collections.emptySet();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<com.sun.mirror.declaration.AnnotationTypeDeclaration> annotationTypeDeclarations,
- AnnotationProcessorEnvironment env) {
- return new DistributedAnnotationProcessor(env);
- }
-}
diff --git a/src/tests/antunit/taskdefs/apt/DistributedAnnotationProcessor.java b/src/tests/antunit/taskdefs/apt/DistributedAnnotationProcessor.java
deleted file mode 100644
index f94ff7f..0000000
--- a/src/tests/antunit/taskdefs/apt/DistributedAnnotationProcessor.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.
- *
- */
-
-//found in tools.jar, not the JRE runtime.
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.util.SimpleDeclarationVisitor;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-import java.util.Map;
-
-/**
- * Annotation processor outputs stuff
- */
-
-public class DistributedAnnotationProcessor implements AnnotationProcessor {
-
- public AnnotationProcessorEnvironment env;
-
- public DistributedAnnotationProcessor(AnnotationProcessorEnvironment env) {
- this.env = env;
- }
-
- public void echo(String text) {
- env.getMessager().printNotice(text);
- }
-
- public void process() {
- echo("DistributedAnnotationProcessor-is-go");
-
- Map<String, String> options=env.getOptions();
- for(String key:options.keySet()) {
- echo("Option ["+key+"] = "+options.get(key));
- }
-
- //work time
- for (TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) {
- typeDecl.accept(getDeclarationScanner(new ClassVisitor(),
- NO_OP));
- }
- }
-
- private class ClassVisitor extends SimpleDeclarationVisitor {
- public void visitClassDeclaration(ClassDeclaration d) {
- echo("visiting "+ d.getQualifiedName());
- }
- }
-}
diff --git a/src/tests/antunit/taskdefs/copy-test.xml b/src/tests/antunit/taskdefs/copy-test.xml
index 51c6277..9b0148b 100644
--- a/src/tests/antunit/taskdefs/copy-test.xml
+++ b/src/tests/antunit/taskdefs/copy-test.xml
@@ -312,13 +312,10 @@
<mkdir dir="${input}"/>
<touch file="${output}/${file}"/>
</target>
- <target name="makeFileUnwritable"
- depends="createTestdir,makeFileUnwritable-Unix,makeFileUnwritable-Windows"/>
- <target name="makeFileUnwritable-Unix" id="unix">
- <chmod file="${output}/${file}" perm="444"/>
- </target>
- <target name="makeFileUnwritable-Windows" unless="unix">
- <attrib file="${output}/${file}" readonly="true"/>
+ <target name="makeFileUnwritable" depends="createTestdir">
+ <setpermissions mode="444" nonPosixMode="tryDosOrFail">
+ <file file="${output}/${file}"/>
+ </setpermissions>
</target>
<target name="testCopyOverReadOnlyFile" depends="makeFileUnwritable">
@@ -453,14 +450,9 @@
<mkdir dir="${output}"/>
<touch file="${input}/somefile"/>
<touch file="${output}/somefile"/>
- <exec executable="chmod" osfamily="unix">
- <arg value="-w"/>
- <arg file="${output}/somefile"/>
- </exec>
- <exec executable="attrib" osfamily="dos">
- <arg value="+r"/>
- <arg file="${output}/somefile"/>
- </exec>
+ <setpermissions mode="444" nonPosixMode="tryDosOrFail">
+ <file file="${output}/somefile"/>
+ </setpermissions>
<au:expectfailure>
<copy todir="${output}" file="${input}/somefile"
overwrite="true"/>
diff --git a/src/tests/antunit/taskdefs/jar-test.xml b/src/tests/antunit/taskdefs/jar-test.xml
index c2c8834..63646e2 100644
--- a/src/tests/antunit/taskdefs/jar-test.xml
+++ b/src/tests/antunit/taskdefs/jar-test.xml
@@ -249,4 +249,76 @@
resource="${output}/META-INF/MANIFEST.MF"/>
</target>
+ <target name="multiReleaseJarPart1" description="http://openjdk.java.net/jeps/238">
+ <!-- Preparation of the 'MultiRelease-Project' -->
+ <property name="java8.src" value="${input}/src/java"/>
+ <property name="java9.src" value="${input}/src/java9"/>
+ <property name="java10.src" value="${input}/src/java10"/>
+ <property name="java8.classes" value="${input}/build/classes"/>
+ <property name="java9.classes" value="${input}/build/classes9"/>
+ <property name="java10.classes" value="${input}/build/classes10"/>
+ <macrodef name="create">
+ <attribute name="version" />
+ <sequential>
+ <local name="src"/>
+ <local name="classes"/>
+ <property name="src" value="${java@{version}.src}"/>
+ <property name="classes" value="${java@{version}.classes}"/>
+ <mkdir dir="${src}/org/apache/ant/test"/>
+ <echo file="${src}/org/apache/ant/test/MRJarTest.java">
+ package org.apache.ant.test;
+ public class MRJarTest {
+ public static final String VERSION = "Java@{version}";
+ }
+ </echo>
+ <mkdir dir="${classes}"/>
+ <javac srcdir="${src}" destdir="${classes}" debug="on" includeantruntime="false"/>
+ </sequential>
+ </macrodef>
+ <create version="8"/>
+ <create version="9"/>
+ <create version="10"/>
+
+ <!-- Now create the MultiReleaseJar -->
+ <jar destfile="${antunit.tmpdir}/mrjar.jar">
+ <manifest>
+ <!-- special mf-entry according to the spec -->
+ <attribute name="Multi-Release" value="true"/>
+ </manifest>
+ <!-- directory structure according to the spec ... -->
+ <!-- ... default classes loadable by old (<Java9) versions -->
+ <fileset dir="${java8.classes}"/>
+ <!-- ... per release classes, require Java9+ for loadable via standard ClassLoader -->
+ <zipfileset prefix="META-INF/versions/9/" dir="${java9.classes}"/>
+ <zipfileset prefix="META-INF/versions/10/" dir="${java10.classes}"/>
+ </jar>
+
+ <!-- Now some tests -->
+ <au:assertNestedResourceExists>
+ <zipentry zipfile="${antunit.tmpdir}/mrjar.jar" name="META-INF/versions/9/org/apache/ant/test/MRJarTest.class"/>
+ </au:assertNestedResourceExists>
+ <au:assertNestedResourceExists>
+ <zipentry zipfile="${antunit.tmpdir}/mrjar.jar" name="META-INF/versions/10/org/apache/ant/test/MRJarTest.class"/>
+ </au:assertNestedResourceExists>
+ </target>
+
+ <target name="testMultiReleaseJar" depends="multiReleaseJarPart1"
+ unless="build.sysclasspath.only"
+ description="most of the tests happen in , this target contains the part that cannot be tested insid Gump">
+ <loadresource property="valueFrom8">
+ <javaconstant name="org.apache.ant.test.MRJarTest.VERSION">
+ <classpath>
+ <pathelement location="${antunit.tmpdir}/mrjar.jar"/>
+ </classpath>
+ </javaconstant>
+ </loadresource>
+ <au:assertTrue>
+ <or>
+ <equals arg1="Java8" arg2="${valueFrom8}"/>
+ <!-- maybe we are running on an early version of Java9 -->
+ <equals arg1="Java9" arg2="${valueFrom8}"/>
+ </or>
+ </au:assertTrue>
+ </target>
+
</project>
diff --git a/src/tests/antunit/taskdefs/javac-test.xml b/src/tests/antunit/taskdefs/javac-test.xml
index 05c3269..60bc552 100644
--- a/src/tests/antunit/taskdefs/javac-test.xml
+++ b/src/tests/antunit/taskdefs/javac-test.xml
@@ -224,28 +224,7 @@
<mkdir dir="${javac-dir}/classes"/>
</sequential>
- <sequential unless:set="jdk9+">
- <echo>JDK 1.5+</echo>
- <testJavac source="1.5"/>
- <delete dir="${javac-dir}/classes"/>
- <mkdir dir="${javac-dir}/classes"/>
- </sequential>
-
- <sequential if:set="jdk1.6+">
- <echo>JDK 1.6+</echo>
- <testJavac source="1.6"/>
- <delete dir="${javac-dir}/classes"/>
- <mkdir dir="${javac-dir}/classes"/>
- </sequential>
-
- <sequential if:set="jdk1.7+">
- <echo>JDK 1.7+</echo>
- <testJavac source="1.7"/>
- <delete dir="${javac-dir}/classes"/>
- <mkdir dir="${javac-dir}/classes"/>
- </sequential>
-
- <sequential if:set="jdk1.8+">
+ <sequential unless:set="jdk1.9+">
<echo>JDK 1.8+</echo>
<testJavac source="1.8"/>
<delete dir="${javac-dir}/classes"/>
@@ -274,34 +253,6 @@
</au:expectfailure>
<sequential unless:set="jdk9+">
- <echo>JDK 1.4+</echo>
- <testJavac source="1.4" target="1.4"/>
- <delete dir="${javac-dir}/classes"/>
- <mkdir dir="${javac-dir}/classes"/>
- </sequential>
-
- <sequential unless:set="jdk9+">
- <echo>JDK 1.5+</echo>
- <testJavac source="1.5" target="1.5"/>
- <delete dir="${javac-dir}/classes"/>
- <mkdir dir="${javac-dir}/classes"/>
- </sequential>
-
- <sequential if:set="jdk1.6+">
- <echo>JDK 1.6+</echo>
- <testJavac source="1.6" target="1.6"/>
- <delete dir="${javac-dir}/classes"/>
- <mkdir dir="${javac-dir}/classes"/>
- </sequential>
-
- <sequential if:set="jdk1.7+">
- <echo>JDK 1.7+</echo>
- <testJavac source="1.7" target="1.7"/>
- <delete dir="${javac-dir}/classes"/>
- <mkdir dir="${javac-dir}/classes"/>
- </sequential>
-
- <sequential if:set="jdk1.8+">
<echo>JDK 1.8+</echo>
<testJavac source="1.8" target="1.8"/>
<delete dir="${javac-dir}/classes"/>
@@ -316,7 +267,7 @@
</sequential>
</target>
- <target name="testJavacWithNativeHeaderGeneration" if="jdk1.8+" depends="setup">
+ <target name="testJavacWithNativeHeaderGeneration" depends="setup">
<mkdir dir="${javac-dir}/src/org/example" />
<mkdir dir="${javac-dir}/classes"/>
<mkdir dir="${javac-dir}/headers"/>
diff --git a/src/tests/antunit/taskdefs/move-test.xml b/src/tests/antunit/taskdefs/move-test.xml
index 9acac74..3584f9b 100644
--- a/src/tests/antunit/taskdefs/move-test.xml
+++ b/src/tests/antunit/taskdefs/move-test.xml
@@ -134,13 +134,10 @@
<mkdir dir="${input}"/>
<touch file="${output}/${file}"/>
</target>
- <target name="makeFileUnwritable"
- depends="createTestdir,makeFileUnwritable-Unix,makeFileUnwritable-Windows"/>
- <target name="makeFileUnwritable-Unix" id="unix">
- <chmod file="${output}/${file}" perm="444"/>
- </target>
- <target name="makeFileUnwritable-Windows" unless="unix">
- <attrib file="${output}/${file}" readonly="true"/>
+ <target name="makeFileUnwritable" depends="createTestdir">
+ <setpermissions mode="444" nonPosixMode="tryDosOrFail">
+ <file file="${output}/${file}"/>
+ </setpermissions>
</target>
<target name="testMoveOverReadOnlyFile" depends="makeFileUnwritable">
diff --git a/src/tests/antunit/taskdefs/optional/junit/junit-test.xml b/src/tests/antunit/taskdefs/optional/junit/junit-test.xml
index e6aa794..d93b96e 100644
--- a/src/tests/antunit/taskdefs/optional/junit/junit-test.xml
+++ b/src/tests/antunit/taskdefs/optional/junit/junit-test.xml
@@ -317,10 +317,7 @@
</target>
<target name="testTestMethods">
- <condition property="source" value="6">
- <isset property="jdk1.6+"/>
- </condition>
- <property name="source" value="5"/>
+ <property name="source" value="8"/>
<echo file="${input}/T1.java">public class T1 extends
junit.framework.TestCase {
public void testOK() {}
diff --git a/src/tests/antunit/taskdefs/optional/xz/unxz-test.xml b/src/tests/antunit/taskdefs/optional/xz/unxz-test.xml
new file mode 100644
index 0000000..0cfffb4
--- /dev/null
+++ b/src/tests/antunit/taskdefs/optional/xz/unxz-test.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+ <import file="../../../antunit-base.xml" />
+
+ <target name="setup">
+ <mkdir dir="${output}"/>
+ <available property="xz.present" classname="org.tukaani.xz.XZOutputStream"/>
+ </target>
+
+ <target name="testWithFileResourceToFile" depends="setup" if="xz.present">
+ <unxz dest="${output}/asf-logo.gif">
+ <file file="../../../../../etc/testcases/taskdefs/expected/asf-logo.gif.xz"/>
+ </unxz>
+ <au:assertFilesMatch expected="../../../../../etc/testcases/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testWithFileResourceToDirectory" depends="setup" if="xz.present">
+ <unxz dest="${output}">
+ <file file="../../../../../etc/testcases/taskdefs/expected/asf-logo.gif.xz"/>
+ </unxz>
+ <au:assertFilesMatch expected="../../../../../etc/testcases/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testWithNonFileResourceToFile" depends="setup" if="xz.present">
+ <unxz dest="${output}/greeting.txt">
+ <url url="http://ant.apache.org/webtest/xz/greeting.txt.xz"/>
+ </unxz>
+ <get src="http://ant.apache.org/webtest/gunzip/greeting.txt"
+ dest="${output}/orig.greeting.txt"/>
+ <au:assertFilesMatch expected="${output}/orig.greeting.txt"
+ actual="${output}/greeting.txt"/>
+ </target>
+
+ <target name="testWithNonFileResourceToDir" depends="setup" if="xz.present">
+ <unxz dest="${output}">
+ <url url="http://ant.apache.org/webtest/xz/greeting.txt.xz"/>
+ </unxz>
+ <get src="http://ant.apache.org/webtest/gunzip/greeting.txt"
+ dest="${output}/orig.greeting.txt"/>
+ <au:assertFilesMatch expected="${output}/orig.greeting.txt"
+ actual="${output}/greeting.txt"/>
+ </target>
+
+</project>
+
diff --git a/src/tests/antunit/taskdefs/optional/xz/xz-test.xml b/src/tests/antunit/taskdefs/optional/xz/xz-test.xml
new file mode 100644
index 0000000..3e4b6a8
--- /dev/null
+++ b/src/tests/antunit/taskdefs/optional/xz/xz-test.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+
+ <!-- note relies on antunit 1.1 -->
+ <import file="../../../antunit-base.xml" />
+
+ <target name="setUp">
+ <mkdir dir="${output}" />
+ <mkdir dir="${output}/empty" />
+ <touch file="${output}/fileone" />
+ <touch file="${output}/filetwo" />
+ <available property="xz.present" classname="org.tukaani.xz.XZOutputStream"/>
+ </target>
+
+ <target name="testFailNone" if="xz.present">
+ <au:expectfailure expectedmessage="No resource selected, xz needs exactly one resource." message="Should have thrown an exception">
+ <xz destfile="${output}/file.gz">
+ <fileset dir="${output}/empty" />
+ </xz>
+ </au:expectfailure>
+ </target>
+
+ <target name="testFailTwo" if="xz.present">
+ <au:expectfailure expectedmessage="xz cannot handle multiple resources at once. (2 resources were selected.)" message="Should have thrown an exception">
+ <xz destfile="${output}/file.xz">
+ <fileset dir="${output}" />
+ </xz>
+ </au:expectfailure>
+ </target>
+
+</project>
diff --git a/src/tests/antunit/taskdefs/secure-input.xml b/src/tests/antunit/taskdefs/secure-input.xml
index 8311ce9..ae0675e 100644
--- a/src/tests/antunit/taskdefs/secure-input.xml
+++ b/src/tests/antunit/taskdefs/secure-input.xml
@@ -22,7 +22,7 @@
<target name="setUp">
</target>
- <target name="test-secure-input" if="jdk1.6+">
+ <target name="test-secure-input">
<input message="secure-input:>" addproperty="the.password">
<handler classname="org.apache.tools.ant.input.SecureInputHandler" />
</input>
diff --git a/src/tests/antunit/taskdefs/setpermissions-test.xml b/src/tests/antunit/taskdefs/setpermissions-test.xml
new file mode 100644
index 0000000..99b90e0
--- /dev/null
+++ b/src/tests/antunit/taskdefs/setpermissions-test.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">
+
+ <import file="../antunit-base.xml" />
+
+ <target name="setUp">
+ <mkdir dir="${input}"/>
+ <property name="file" location="${input}/file"/>
+ <touch file="${file}"/>
+ </target>
+
+ <target name="testRequiresNestedResources" depends="setUp">
+ <au:expectfailure expectedMessage="At least one resource-collection is required">
+ <setpermissions mode="644" />
+ </au:expectfailure>
+ </target>
+
+ <target name="testPermissionsSetViaPermissionsAttribute"
+ depends="setUp">
+ <setpermissions permissions="OWNER_READ,GROUP_READ,OTHERS_READ"
+ nonPosixMode="tryDosOrFail">
+ <file file="${file}"/>
+ </setpermissions>
+ <au:assertFalse>
+ <isfileselected file="${file}">
+ <writable/>
+ </isfileselected>
+ </au:assertFalse>
+ <au:assertTrue>
+ <isfileselected file="${file}">
+ <readable/>
+ </isfileselected>
+ </au:assertTrue>
+ </target>
+
+ <target name="testPermissionsSetViaModeAttribute"
+ depends="setUp">
+ <setpermissions mode="444" nonPosixMode="tryDosOrFail">
+ <file file="${file}"/>
+ </setpermissions>
+ <au:assertFalse>
+ <isfileselected file="${file}">
+ <writable/>
+ </isfileselected>
+ </au:assertFalse>
+ <au:assertTrue>
+ <isfileselected file="${file}">
+ <readable/>
+ </isfileselected>
+ </au:assertTrue>
+ </target>
+</project>
diff --git a/src/tests/antunit/taskdefs/tar-test.xml b/src/tests/antunit/taskdefs/tar-test.xml
index 1aac9a8..d83b5f9 100644
--- a/src/tests/antunit/taskdefs/tar-test.xml
+++ b/src/tests/antunit/taskdefs/tar-test.xml
@@ -24,6 +24,7 @@
<target name="setUp">
<mkdir dir="${input}" />
<mkdir dir="${output}" />
+ <available property="xz.present" classname="org.tukaani.xz.XZOutputStream"/>
</target>
<target name="testTarFilesetHandlesFilesetReferences" depends="setUp">
@@ -115,4 +116,47 @@
<untar dest="${output}" src="${output}/x.tar"/>
<au:assertFileExists file="${output}/${longfile.file.name}"/>
</target>
+
+ <target name="testGzipCompression" depends="setUp">
+ <au:assertFileExists file="../../../etc/testcases/asf-logo.gif"/>
+ <tar destfile="${input}/asf-logo.gif.tar.gz" compression="gzip">
+ <file file="../../../etc/testcases/asf-logo.gif"/>
+ </tar>
+ <gunzip dest="${input}/asf-logo.gif.tar">
+ <file file="${input}/asf-logo.gif.tar.gz"/>
+ </gunzip>
+ <untar src="${input}/asf-logo.gif.tar" dest="${output}"/>
+ <au:assertFilesMatch
+ expected="../../../etc/testcases/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testBzip2Compression" depends="setUp">
+ <au:assertFileExists file="../../../etc/testcases/asf-logo.gif"/>
+ <tar destfile="${input}/asf-logo.gif.tar.bz2" compression="bzip2">
+ <file file="../../../etc/testcases/asf-logo.gif"/>
+ </tar>
+ <bunzip2 dest="${input}/asf-logo.gif.tar">
+ <file file="${input}/asf-logo.gif.tar.bz2"/>
+ </bunzip2>
+ <untar src="${input}/asf-logo.gif.tar" dest="${output}"/>
+ <au:assertFilesMatch
+ expected="../../../etc/testcases/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testXzCompression" depends="setUp" if="xz.present">
+ <au:assertFileExists file="../../../etc/testcases/asf-logo.gif"/>
+ <tar destfile="${input}/asf-logo.gif.tar.xz" compression="xz">
+ <file file="../../../etc/testcases/asf-logo.gif"/>
+ </tar>
+ <unxz dest="${input}/asf-logo.gif.tar">
+ <file file="${input}/asf-logo.gif.tar.xz"/>
+ </unxz>
+ <untar src="${input}/asf-logo.gif.tar" dest="${output}"/>
+ <au:assertFilesMatch
+ expected="../../../etc/testcases/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
</project>
diff --git a/src/tests/antunit/taskdefs/taskdef-antlib-test.xml b/src/tests/antunit/taskdefs/taskdef-antlib-test.xml
index 58d01f0..72f21ae 100644
--- a/src/tests/antunit/taskdefs/taskdef-antlib-test.xml
+++ b/src/tests/antunit/taskdefs/taskdef-antlib-test.xml
@@ -18,9 +18,7 @@
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />
- <!-- Java5 has some trouble with the recursive Antlib lookup -->
-
- <target name="setUp" if="jdk1.6+">
+ <target name="setUp">
<mkdir dir="${input}/org/example" />
<property name="tmpdir" location="../../../../build/ant-unit/taskdef" />
<mkdir dir="${tmpdir}" />
@@ -46,14 +44,14 @@
<sleep seconds="1"/>
</target>
- <target name="testAntlib" depends="setUp" if="jdk1.6+">
+ <target name="testAntlib" depends="setUp">
<taskdef classpath="${test.jar}" uri="antlib:org.example"
loaderref="loader1"/>
<echoooo xmlns="antlib:org.example" message="exemple" />
<au:assertLogContains text="exempleexempleexempleexemple" />
</target>
- <target name="testURI" depends="setUp" if="jdk1.6+">
+ <target name="testURI" depends="setUp">
<taskdef classpath="${test.jar}" uri="urn:my:exemple"
loaderref="loader2"
resource="org/example/antlib.xml" />
diff --git a/src/tests/antunit/taskdefs/taskdef-test.xml b/src/tests/antunit/taskdefs/taskdef-test.xml
index 9574508..1da8e9f 100644
--- a/src/tests/antunit/taskdefs/taskdef-test.xml
+++ b/src/tests/antunit/taskdefs/taskdef-test.xml
@@ -41,7 +41,7 @@
<au:assertLogContains text="Hello"/>
</target>
- <target name="testDirWithPling" depends="setUp" if="jdk1.6+"
+ <target name="testDirWithPling" depends="setUp"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=50007">
<property name="dir" location="${tmpdir}/pl!ng"/>
<mkdir dir="${dir}"/>
diff --git a/src/tests/antunit/taskdefs/untar-test.xml b/src/tests/antunit/taskdefs/untar-test.xml
new file mode 100644
index 0000000..4c04bfe
--- /dev/null
+++ b/src/tests/antunit/taskdefs/untar-test.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+
+<project name="untar-test" default="antunit"
+ xmlns:au="antlib:org.apache.ant.antunit">
+ <import file="../antunit-base.xml" />
+
+ <target name="setUp">
+ <mkdir dir="${input}"/>
+ <mkdir dir="${output}/expected" />
+ <mkdir dir="${output}/actual" />
+ <available property="xz.present" classname="org.tukaani.xz.XZOutputStream"/>
+ </target>
+
+ <target name="testGzipCompression" depends="setUp">
+ <untar src="../../../etc/testcases/taskdefs/expected/asf-logo.gif.tar"
+ dest="${output}/expected"/>
+ <untar src="../../../etc/testcases/taskdefs/expected/asf-logo.gif.tar.gz"
+ compression="gzip"
+ dest="${output}/actual"/>
+ <au:assertFilesMatch expected="${output}/expected/asf-logo.gif"
+ actual="${output}/actual/asf-logo.gif"/>
+ </target>
+
+ <target name="testBzip2Compression" depends="setUp">
+ <untar src="../../../etc/testcases/taskdefs/expected/asf-logo.gif.tar"
+ dest="${output}/expected"/>
+ <untar src="../../../etc/testcases/taskdefs/expected/asf-logo.gif.tar.bz2"
+ compression="bzip2"
+ dest="${output}/actual"/>
+ <au:assertFilesMatch expected="${output}/expected/asf-logo.gif"
+ actual="${output}/actual/asf-logo.gif"/>
+ </target>
+
+ <target name="testXZCompression" depends="setUp" if="xz.present">
+ <untar src="../../../etc/testcases/taskdefs/expected/asf-logo.gif.tar"
+ dest="${output}/expected"/>
+ <xz destfile="${input}/asf-logo.gif.tar.xz"
+ src="../../../etc/testcases/taskdefs/expected/asf-logo.gif.tar"/>
+ <untar src="${input}/asf-logo.gif.tar.xz"
+ compression="xz"
+ dest="${output}/actual"/>
+ <au:assertFilesMatch expected="${output}/expected/asf-logo.gif"
+ actual="${output}/actual/asf-logo.gif"/>
+ </target>
+</project>
diff --git a/src/tests/antunit/taskdefs/xslt-test.xml b/src/tests/antunit/taskdefs/xslt-test.xml
index d6f6d66..b327c7b 100644
--- a/src/tests/antunit/taskdefs/xslt-test.xml
+++ b/src/tests/antunit/taskdefs/xslt-test.xml
@@ -187,18 +187,7 @@
</xslt>
</target>
-
- <target name="testTraceJdk14" unless="jdk1.5+" depends="setUp">
- <xslt in="${legacy.dir}/data.xml"
- out="${output}/out.xml"
- style="${legacy.dir}/printParams.xsl">
- <param name="set" expression="myvalue"/>
- <trace templates="true"/>
- </xslt>
- <au:assertLogContains text="Failed to enable tracing" level="warning"/>
- </target>
-
- <target name="testTraceJdk15+" if="jdk1.5+" depends="setUp">
+ <target name="testTrace" depends="setUp">
<xslt in="${legacy.dir}/data.xml"
out="${output}/out.xml"
style="${legacy.dir}/printParams.xsl">
diff --git a/src/tests/antunit/types/optional/xz/xzresource-test.xml b/src/tests/antunit/types/optional/xz/xzresource-test.xml
new file mode 100644
index 0000000..56fe66d
--- /dev/null
+++ b/src/tests/antunit/types/optional/xz/xzresource-test.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">
+
+ <import file="../../../antunit-base.xml" />
+
+ <target name="setup">
+ <mkdir dir="${output}"/>
+ <available property="xz.present" classname="org.tukaani.xz.XZOutputStream"/>
+ </target>
+
+ <target name="testDocumentationClaimsOnCopy" if="xz.present">
+ <copy todir="${output}">
+ <xzresource>
+ <file file="../../../../../etc/testcases/taskdefs/expected/asf-logo.gif.xz"/>
+ </xzresource>
+ <mapper type="glob" from="*.xz" to="*"/>
+ </copy>
+ <au:assertFilesMatch expected="../../../../../etc/testcases/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+</project>
diff --git a/src/tests/antunit/types/resources/selectors/readwrite-test.xml b/src/tests/antunit/types/resources/selectors/readwrite-test.xml
index 6a0301b..4247875 100644
--- a/src/tests/antunit/types/resources/selectors/readwrite-test.xml
+++ b/src/tests/antunit/types/resources/selectors/readwrite-test.xml
@@ -70,13 +70,10 @@
</au:assertTrue>
</target>
- <target name="makeFileUnwritable"
- depends="createTestdir,makeFileUnwritable-Unix,makeFileUnwritable-Windows"/>
- <target name="makeFileUnwritable-Unix" id="unix">
- <chmod file="${output}/${file}" perm="444"/>
- </target>
- <target name="makeFileUnwritable-Windows" unless="unix">
- <attrib file="${output}/${file}" readonly="true"/>
+ <target name="makeFileUnwritable" depends="createTestdir">
+ <setpermissions mode="444" nonPosixMode="tryDosOrFail">
+ <file file="${output}/${file}"/>
+ </setpermissions>
</target>
<target name="testUnwritable" depends="makeFileUnwritable">
diff --git a/src/tests/antunit/types/selectors/executable-test.xml b/src/tests/antunit/types/selectors/executable-test.xml
new file mode 100644
index 0000000..45cbeeb
--- /dev/null
+++ b/src/tests/antunit/types/selectors/executable-test.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">
+
+ <import file="../../antunit-base.xml" />
+
+ <property name="file" value="testfile"/>
+
+ <condition property="unix">
+ <os family="unix"/>
+ </condition>
+
+ <target name="createTestdir">
+ <mkdir dir="${output}"/>
+ <touch file="${output}/${file}"/>
+ </target>
+
+ <target name="testExecutable" depends="makeFileExecutable" if="unix">
+ <au:assertTrue>
+ <resourcecount when="equal" count="1">
+ <fileset dir="${output}">
+ <executable/>
+ </fileset>
+ </resourcecount>
+ </au:assertTrue>
+ <au:assertTrue>
+ <resourcecount when="equal" count="0">
+ <fileset dir="${output}" excludes="${file}">
+ <executable/>
+ </fileset>
+ </resourcecount>
+ </au:assertTrue>
+ </target>
+
+ <target name="makeFileExecutable" depends="createTestdir">
+ <setpermissions mode="755" nonPosixMode="pass">
+ <file file="${output}/${file}"/>
+ </setpermissions>
+ </target>
+
+ <target name="testNotexecutable" depends="createTestdir" if="unix">
+ <au:assertTrue>
+ <resourcecount when="equal" count="0">
+ <fileset dir="${output}">
+ <executable/>
+ </fileset>
+ </resourcecount>
+ </au:assertTrue>
+ </target>
+
+ <target name="testAsFalseConditions" depends="createTestdir" if="unix">
+ <au:assertFalse>
+ <isfileselected file="${output}/${file}">
+ <executable/>
+ </isfileselected>
+ </au:assertFalse>
+ </target>
+
+ <target name="testAsTrueConditions" depends="makeFileExecutable" if="unix">
+ <au:assertTrue>
+ <isfileselected file="${output}/${file}">
+ <executable/>
+ </isfileselected>
+ </au:assertTrue>
+ </target>
+
+</project>
diff --git a/src/tests/antunit/types/selectors/ownedby-test.xml b/src/tests/antunit/types/selectors/ownedby-test.xml
new file mode 100644
index 0000000..5ec4381
--- /dev/null
+++ b/src/tests/antunit/types/selectors/ownedby-test.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">
+
+ <import file="../../antunit-base.xml" />
+
+ <property name="file" value="testfile"/>
+
+ <condition property="unix">
+ <os family="unix"/>
+ </condition>
+
+ <target name="createTestdir">
+ <mkdir dir="${output}"/>
+ <touch file="${output}/${file}"/>
+ </target>
+
+ <target name="testRequiresOwner" depends="createTestdir">
+ <au:expectfailure expectedMessage="the owner attribute is required">
+ <au:assertTrue>
+ <isfileselected file="${output}/${file}">
+ <ownedBy/>
+ </isfileselected>
+ </au:assertTrue>
+ </au:expectfailure>
+ </target>
+
+ <!-- at least on Jenkins the file is owned by BUILTIN\Administrators -->
+ <target name="testOwnedBy" depends="createTestdir" if="unix">
+ <au:assertTrue>
+ <resourcecount when="equal" count="1">
+ <fileset dir="${output}">
+ <ownedBy owner="${user.name}"/>
+ </fileset>
+ </resourcecount>
+ </au:assertTrue>
+ <au:assertTrue>
+ <resourcecount when="equal" count="0">
+ <fileset dir="${output}" excludes="${file}">
+ <ownedBy owner="${user.name}"/>
+ </fileset>
+ </resourcecount>
+ </au:assertTrue>
+ </target>
+
+ <target name="testAsTrueConditions" depends="createTestdir" if="unix">
+ <au:assertTrue>
+ <isfileselected file="${output}/${file}">
+ <ownedBy owner="${user.name}"/>
+ </isfileselected>
+ </au:assertTrue>
+ </target>
+
+</project>
diff --git a/src/tests/antunit/types/selectors/readwrite-test.xml b/src/tests/antunit/types/selectors/readwrite-test.xml
index bd4ac8d..62dc052 100644
--- a/src/tests/antunit/types/selectors/readwrite-test.xml
+++ b/src/tests/antunit/types/selectors/readwrite-test.xml
@@ -64,13 +64,10 @@
</au:assertTrue>
</target>
- <target name="makeFileUnwritable"
- depends="createTestdir,makeFileUnwritable-Unix,makeFileUnwritable-Windows"/>
- <target name="makeFileUnwritable-Unix" id="unix">
- <chmod file="${output}/${file}" perm="444"/>
- </target>
- <target name="makeFileUnwritable-Windows" unless="unix">
- <attrib file="${output}/${file}" readonly="true"/>
+ <target name="makeFileUnwritable" depends="createTestdir">
+ <setpermissions mode="444" nonPosixMode="tryDosOrFail">
+ <file file="${output}/${file}"/>
+ </setpermissions>
</target>
<target name="testUnwritable" depends="makeFileUnwritable">
diff --git a/src/tests/antunit/types/selectors/symlink-test.xml b/src/tests/antunit/types/selectors/symlink-test.xml
new file mode 100644
index 0000000..0c47326
--- /dev/null
+++ b/src/tests/antunit/types/selectors/symlink-test.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">
+
+ <import file="../../antunit-base.xml" />
+
+ <property name="file" value="testfile"/>
+ <property name="link" value="testlink"/>
+
+ <condition property="unix">
+ <os family="unix"/>
+ </condition>
+
+ <target name="createTestdir">
+ <mkdir dir="${output}"/>
+ <touch file="${output}/${file}"/>
+ </target>
+
+ <target name="testSymlink" depends="makeSymlink" if="unix">
+ <au:assertTrue>
+ <resourcecount when="equal" count="1">
+ <fileset dir="${output}">
+ <symlink/>
+ </fileset>
+ </resourcecount>
+ </au:assertTrue>
+ <au:assertTrue>
+ <resourcecount when="equal" count="0">
+ <fileset dir="${output}" excludes="${link}">
+ <symlink/>
+ </fileset>
+ </resourcecount>
+ </au:assertTrue>
+ </target>
+
+ <target name="makeSymlink"
+ depends="createTestdir,makeSymlink-Unix,makeSymlink-Windows"/>
+ <target name="makeSymlink-Unix" if="unix">
+ <symlink link="${output}/${link}" resource="${output}/${file}"/>
+ </target>
+ <target name="makeSymlink-Windows" unless="unix">
+ <!-- no idea how to do this -->
+ </target>
+
+ <target name="testNoSymlink" depends="createTestdir">
+ <au:assertTrue>
+ <resourcecount when="equal" count="0">
+ <fileset dir="${output}">
+ <symlink/>
+ </fileset>
+ </resourcecount>
+ </au:assertTrue>
+ </target>
+
+ <target name="testAsFalseConditions" depends="createTestdir">
+ <au:assertFalse>
+ <isfileselected file="${output}/${link}">
+ <symlink/>
+ </isfileselected>
+ </au:assertFalse>
+ </target>
+
+ <target name="testAsTrueConditions" depends="makeSymlink" if="unix">
+ <au:assertTrue>
+ <isfileselected file="${output}/${link}">
+ <symlink/>
+ </isfileselected>
+ </au:assertTrue>
+ </target>
+
+</project>
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java
index 3e1157d..fb78937 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java
@@ -18,6 +18,7 @@
package org.apache.tools.ant.taskdefs;
+import org.apache.tools.ant.AntAssert;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileRule;
import org.junit.After;
@@ -25,6 +26,7 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
@@ -103,6 +105,8 @@
public void test7() {
try {
buildRule.executeTarget("test7");
+ AntAssert.assertNotContains("Adding header", buildRule.getLog());
+
fail("userAgent may not be null or empty");
} catch (BuildException ex) {
//TODO assert value
@@ -119,4 +123,35 @@
buildRule.executeTarget("testUseTomorrow");
}
+ @Test
+ public void testTwoHeadersAreAddedOK() {
+ buildRule.executeTarget("testTwoHeadersAreAddedOK");
+ String log = buildRule.getLog();
+ AntAssert.assertContains("Adding header 'header1'", log);
+ AntAssert.assertContains("Adding header 'header2'", log);
+ }
+
+ @Test
+ public void testEmptyHeadersAreNeverAdded() {
+ buildRule.executeTarget("testEmptyHeadersAreNeverAdded");
+ AntAssert.assertNotContains("Adding header", buildRule.getLog());
+ }
+
+ @Test
+ public void testThatWhenMoreThanOneHeaderHaveSameNameOnlyLastOneIsAdded() {
+ buildRule.executeTarget("testThatWhenMoreThanOneHeaderHaveSameNameOnlyLastOneIsAdded");
+ String log = buildRule.getLog();
+ AntAssert.assertContains("Adding header 'header1'", log);
+
+ int actualHeaderCount = log.split("Adding header ").length - 1;
+
+ assertEquals("Only one header has been added", 1, actualHeaderCount);
+ }
+
+ @Test
+ public void testHeaderSpaceTrimmed() {
+ buildRule.executeTarget("testHeaderSpaceTrimmed");
+ AntAssert.assertContains("Adding header 'header1'", buildRule.getLog());
+ }
+
}
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java
index 67e31e9..364a50e 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java
@@ -35,7 +35,6 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
/**
* Testcase for <javac>.
@@ -249,46 +248,31 @@
assertEquals("1.5", javac.getTarget());
}
- @Test
+ @Test(expected = BuildException.class)
public void testModulesourcepathOrSrcDirRequired() {
- try {
- javac.checkParameters();
- fail("Build exception should have been thrown - neither srcDir nor modulesourcepath");
- } catch (BuildException e) {
- //pass
- }
+ javac.checkParameters();
}
- @Test
+ @Test(expected = BuildException.class)
public void testModulesourcepathAndSrcDirForbidden() {
- try {
- javac.checkParameters();
- final Path p = new Path(project);
- p.setPath("src");
- javac.setSrcdir(p);
- final Path mp = new Path(project);
- p.setPath("modsrc");
- javac.setModulesourcepath(mp);
- fail("Build exception should have been thrown - neither srcDir nor modulesourcepath");
- } catch (BuildException e) {
- //pass
- }
+ javac.checkParameters();
+ final Path p = new Path(project);
+ p.setPath("src");
+ javac.setSrcdir(p);
+ final Path mp = new Path(project);
+ p.setPath("modsrc");
+ javac.setModulesourcepath(mp);
}
- @Test
+ @Test(expected = BuildException.class)
public void testModulesourcepathAndSourcepathForbidden() {
- try {
- javac.checkParameters();
- final Path p = new Path(project);
- p.setPath("src");
- javac.setSourcepath(p);
- final Path mp = new Path(project);
- p.setPath("modsrc");
- javac.setModulesourcepath(mp);
- fail("Build exception should have been thrown - neither srcDir nor modulesourcepath");
- } catch (BuildException e) {
- //pass
- }
+ javac.checkParameters();
+ final Path p = new Path(project);
+ p.setPath("src");
+ javac.setSourcepath(p);
+ final Path mp = new Path(project);
+ p.setPath("modsrc");
+ javac.setModulesourcepath(mp);
}
@Test
@@ -317,16 +301,11 @@
}
}
- @Test
+ @Test(expected = BuildException.class)
public void testModulesourcepathRequiresDestdir() {
- try {
- final Path p = new Path(project);
- p.setPath("src");
- javac.setModulesourcepath(p);
- javac.checkParameters();
- fail("Build exception should have been thrown - modulesourcepath requires destdir");
- } catch (BuildException e) {
- //pass
- }
+ final Path p = new Path(project);
+ p.setPath("src");
+ javac.setModulesourcepath(p);
+ javac.checkParameters();
}
}
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
index 3753b68..f2f1861 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
@@ -348,28 +348,6 @@
}
/**
- * test that passes -Xnew to sun's rmic.
- *
- * @throws Exception
- */
- @Test
- public void testXnew() throws Exception {
- // skipped via unless attribute for JDK > 6
- buildRule.executeTarget("testXnew");
- }
-
- /**
- * test that passes -Xnew to sun's rmic.
- *
- * @throws Exception
- */
- @Test
- public void testXnewDest() throws Exception {
- // skipped via unless attribute for JDK > 6
- buildRule.executeTarget("testXnewDest");
- }
-
- /**
* test that passes -Xnew to sun's rmic running in a different VM.
*
* @throws Exception
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
index 95585fd..93d5e78 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
@@ -106,7 +106,6 @@
@Test
public void testTsaLocalhost() {
- Assume.assumeTrue("Only runs on Java 1.5+", JavaEnvUtils.getJavaVersionNumber()>=15);
try {
buildRule.executeTarget("testTsaLocalhost");
fail("Should have thrown exception - no TSA at localhost:0");
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java
index cb274a8..63203bf 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java
@@ -244,6 +244,7 @@
javac.setProject(prj);
final Commandline[] cmd = new Commandline[1];
final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() {
+ @Override
public boolean execute() throws BuildException {
cmd[0] = setupModernJavacCommand();
return true;
@@ -300,6 +301,7 @@
javac.setProject(prj);
final Commandline[] cmd = new Commandline[1];
final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() {
+ @Override
public boolean execute() throws BuildException {
cmd[0] = setupModernJavacCommand();
return true;
@@ -363,6 +365,7 @@
final LogCapturingJavac javac = new LogCapturingJavac();
javac.setProject(prj);
final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() {
+ @Override
public boolean execute() throws BuildException {
setupModernJavacCommand();
return true;
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java
index d05cf0c..b383ca9 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java
@@ -1,67 +1,89 @@
-/*
- * 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;
-
-import org.apache.tools.ant.BuildFileRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests the examples of the <script> task docs.
- *
- * @since Ant 1.5.2
- */
-public class RhinoScriptTest {
-
- @Rule
- public BuildFileRule buildRule = new BuildFileRule();
-
- @Before
- public void setUp() {
- buildRule.configureProject("src/etc/testcases/taskdefs/optional/script.xml");
- }
-
- @Test
- public void testExample1() {
- buildRule.executeTarget("example1");
- int index = buildRule.getLog().indexOf("1");
- assertTrue(index > -1);
- index = buildRule.getLog().indexOf("4", index);
- assertTrue(index > -1);
- index = buildRule.getLog().indexOf("9", index);
- assertTrue(index > -1);
- index = buildRule.getLog().indexOf("16", index);
- assertTrue(index > -1);
- index = buildRule.getLog().indexOf("25", index);
- assertTrue(index > -1);
- index = buildRule.getLog().indexOf("36", index);
- assertTrue(index > -1);
- index = buildRule.getLog().indexOf("49", index);
- assertTrue(index > -1);
- index = buildRule.getLog().indexOf("64", index);
- assertTrue(index > -1);
- index = buildRule.getLog().indexOf("81", index);
- assertTrue(index > -1);
- index = buildRule.getLog().indexOf("100", index);
- assertTrue(index > -1);
- }
-
-}
+/*
+ * 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;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests the examples of the <script> task docs.
+ *
+ * @since Ant 1.5.2
+ */
+public class RhinoScriptTest {
+
+ @Rule
+ public BuildFileRule buildRule = new BuildFileRule();
+
+ @Before
+ public void setUp() {
+ buildRule.configureProject("src/etc/testcases/taskdefs/optional/script.xml");
+ }
+
+ @Test
+ public void testExample1() {
+ buildRule.executeTarget("example1");
+ int index = buildRule.getLog().indexOf("1");
+ assertTrue(index > -1);
+ index = buildRule.getLog().indexOf("4", index);
+ assertTrue(index > -1);
+ index = buildRule.getLog().indexOf("9", index);
+ assertTrue(index > -1);
+ index = buildRule.getLog().indexOf("16", index);
+ assertTrue(index > -1);
+ index = buildRule.getLog().indexOf("25", index);
+ assertTrue(index > -1);
+ index = buildRule.getLog().indexOf("36", index);
+ assertTrue(index > -1);
+ index = buildRule.getLog().indexOf("49", index);
+ assertTrue(index > -1);
+ index = buildRule.getLog().indexOf("64", index);
+ assertTrue(index > -1);
+ index = buildRule.getLog().indexOf("81", index);
+ assertTrue(index > -1);
+ index = buildRule.getLog().indexOf("100", index);
+ assertTrue(index > -1);
+ }
+
+ @Test
+ public void testUseSrcAndEncoding() {
+ final String readerEncoding = "UTF-8";
+ buildRule.getProject().setProperty("useSrcAndEncoding.reader.encoding", readerEncoding);
+ buildRule.executeTarget("useSrcAndEncoding");
+ }
+
+ @Test
+ public void testUseSrcAndEncodingFailure() {
+ final String readerEncoding = "ISO-8859-1";
+ buildRule.getProject().setProperty("useSrcAndEncoding.reader.encoding", readerEncoding);
+ try {
+ buildRule.executeTarget("useSrcAndEncoding");
+ fail("should have failed with reader's encoding [" + readerEncoding +
+ "] different from the writer's encoding [" + buildRule.getProject().getProperty("useSrcAndEncoding.encoding") + "]");
+ }
+ catch(BuildException e) {
+ assertTrue(e.getMessage().matches("expected <eacute \\[\u00e9]> but was <eacute \\[\u00c3\u00a9]>"));
+ }
+ }
+}
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java
index 8a36452..db2172e 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java
@@ -472,7 +472,7 @@
assertNotNull(mockProcLauncher.cmd);
String resCp = null;
String resMp = null;
- Set<String> resExports = new TreeSet<String>();
+ Set<String> resExports = new TreeSet<>();
for (int i = 1; i< mockProcLauncher.cmd.length; i++) {
if ("-classpath".equals(mockProcLauncher.cmd[i])) { //NOI18N
resCp = mockProcLauncher.cmd[++i];
@@ -529,7 +529,7 @@
assertNotNull(mockProcLauncher.cmd);
String resCp = null;
String resMp = null;
- Set<String> resExports = new TreeSet<String>();
+ Set<String> resExports = new TreeSet<>();
for (int i = 1; i< mockProcLauncher.cmd.length; i++) {
if ("-classpath".equals(mockProcLauncher.cmd[i])) { //NOI18N
resCp = mockProcLauncher.cmd[++i];
@@ -569,8 +569,7 @@
@Override
public Process exec(Project project, String[] cmd, String[] env, File workingDir) throws IOException {
- this.cmd = new String[cmd.length];
- System.arraycopy(cmd, 0, this.cmd, 0, cmd.length);
+ this.cmd = Arrays.copyOf(cmd, cmd.length);
return new MockProcess();
}
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java
index 77c7036..0b2ebce 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java
@@ -1,146 +1,187 @@
-/*
- * 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.script;
-
-import org.apache.tools.ant.AntAssert;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildFileRule;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.FileSet;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import java.io.File;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Tests the examples of the <scriptdef> task.
- *
- * @since Ant 1.6
- */
-public class ScriptDefTest {
-
- @Rule
- public BuildFileRule buildRule = new BuildFileRule();
-
- @Before
- public void setUp() {
- buildRule.configureProject("src/etc/testcases/taskdefs/optional/script/scriptdef.xml");
- }
-
- @Test
- public void testSimple() {
- buildRule.executeTarget("simple");
- // get the fileset and its basedir
- Project p = buildRule.getProject();
- FileSet fileset = (FileSet) p.getReference("testfileset");
- File baseDir = fileset.getDir(p);
- String log = buildRule.getLog();
- assertTrue("Expecting attribute value printed",
- log.indexOf("Attribute attr1 = test") != -1);
-
- assertTrue("Expecting nested element value printed",
- log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1);
- }
-
- @Test
- public void testNoLang() {
- try {
- buildRule.executeTarget("nolang");
- fail("Absence of language attribute not detected");
- } catch(BuildException ex) {
- AntAssert.assertContains("requires a language attribute", ex.getMessage());
- }
- }
-
- @Test
- public void testNoName() {
- try {
- buildRule.executeTarget("noname");
- fail("Absence of name attribute not detected");
- } catch(BuildException ex) {
- AntAssert.assertContains("scriptdef requires a name attribute", ex.getMessage());
- }
- }
-
- @Test
- public void testNestedByClassName() {
- buildRule.executeTarget("nestedbyclassname");
- // get the fileset and its basedir
- Project p = buildRule.getProject();
- FileSet fileset = (FileSet) p.getReference("testfileset");
- File baseDir = fileset.getDir(p);
- String log = buildRule.getLog();
- assertTrue("Expecting attribute value to be printed",
- log.indexOf("Attribute attr1 = test") != -1);
-
- assertTrue("Expecting nested element value to be printed",
- log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1);
- }
-
- @Test
- public void testNoElement() {
- buildRule.executeTarget("noelement");
- assertEquals("Attribute attr1 = test", buildRule.getOutput().trim());
- }
-
- @Test
- public void testException() {
- try {
- buildRule.executeTarget("exception");
- fail("Should have thrown an exception in the script");
- } catch(BuildException ex) {
- AntAssert.assertContains("TypeError", ex.getMessage());
- }
- }
-
- @Test
- public void testDoubleDef() {
- buildRule.executeTarget("doubledef");
- String log = buildRule.getLog();
- assertTrue("Task1 did not execute",
- log.indexOf("Task1") != -1);
- assertTrue("Task2 did not execute",
- log.indexOf("Task2") != -1);
- }
-
- @Test
- public void testDoubleAttribute() {
- try {
- buildRule.executeTarget("doubleAttributeDef");
- fail("Should have detected duplicate attirbute definition");
- } catch(BuildException ex) {
- AntAssert.assertContains("attr1 attribute more than once", ex.getMessage());
- }
- }
-
- @Test
- public void testProperty() {
- buildRule.executeTarget("property");
- // get the fileset and its basedir
- String log = buildRule.getLog();
- assertTrue("Expecting property in attribute value replaced",
- log.indexOf("Attribute value = test") != -1);
- }
-
-
-}
+/*
+ * 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.script;
+
+import org.apache.tools.ant.AntAssert;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.FileSet;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests the examples of the <scriptdef> task.
+ *
+ * @since Ant 1.6
+ */
+public class ScriptDefTest {
+
+ @Rule
+ public BuildFileRule buildRule = new BuildFileRule();
+
+ @Before
+ public void setUp() {
+ buildRule.configureProject("src/etc/testcases/taskdefs/optional/script/scriptdef.xml");
+ }
+
+ @Test
+ public void testSimple() {
+ buildRule.executeTarget("simple");
+ // get the fileset and its basedir
+ Project p = buildRule.getProject();
+ FileSet fileset = (FileSet) p.getReference("testfileset");
+ File baseDir = fileset.getDir(p);
+ String log = buildRule.getLog();
+ assertTrue("Expecting attribute value printed",
+ log.indexOf("Attribute attr1 = test") != -1);
+
+ assertTrue("Expecting nested element value printed",
+ log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1);
+ }
+
+ @Test
+ public void testNoLang() {
+ try {
+ buildRule.executeTarget("nolang");
+ fail("Absence of language attribute not detected");
+ } catch(BuildException ex) {
+ AntAssert.assertContains("requires a language attribute", ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testNoName() {
+ try {
+ buildRule.executeTarget("noname");
+ fail("Absence of name attribute not detected");
+ } catch(BuildException ex) {
+ AntAssert.assertContains("scriptdef requires a name attribute", ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testNestedByClassName() {
+ buildRule.executeTarget("nestedbyclassname");
+ // get the fileset and its basedir
+ Project p = buildRule.getProject();
+ FileSet fileset = (FileSet) p.getReference("testfileset");
+ File baseDir = fileset.getDir(p);
+ String log = buildRule.getLog();
+ assertTrue("Expecting attribute value to be printed",
+ log.indexOf("Attribute attr1 = test") != -1);
+
+ assertTrue("Expecting nested element value to be printed",
+ log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1);
+ }
+
+ @Test
+ public void testNoElement() {
+ buildRule.executeTarget("noelement");
+ assertEquals("Attribute attr1 = test", buildRule.getOutput().trim());
+ }
+
+ @Test
+ public void testException() {
+ try {
+ buildRule.executeTarget("exception");
+ fail("Should have thrown an exception in the script");
+ } catch(BuildException ex) {
+ AntAssert.assertContains("TypeError", ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testDoubleDef() {
+ buildRule.executeTarget("doubledef");
+ String log = buildRule.getLog();
+ assertTrue("Task1 did not execute",
+ log.indexOf("Task1") != -1);
+ assertTrue("Task2 did not execute",
+ log.indexOf("Task2") != -1);
+ }
+
+ @Test
+ public void testDoubleAttribute() {
+ try {
+ buildRule.executeTarget("doubleAttributeDef");
+ fail("Should have detected duplicate attirbute definition");
+ } catch(BuildException ex) {
+ AntAssert.assertContains("attr1 attribute more than once", ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testProperty() {
+ buildRule.executeTarget("property");
+ // get the fileset and its basedir
+ String log = buildRule.getLog();
+ assertTrue("Expecting property in attribute value replaced",
+ log.indexOf("Attribute value = test") != -1);
+ }
+
+ @Test
+ public void testUseSrcAndEncoding() {
+ final String readerEncoding = "UTF-8";
+ buildRule.getProject().setProperty("useSrcAndEncoding.reader.encoding", readerEncoding);
+ buildRule.executeTarget("useSrcAndEncoding");
+ }
+
+ @Test
+ public void testUseSrcAndEncodingFailure() {
+ final String readerEncoding = "ISO-8859-1";
+ buildRule.getProject().setProperty("useSrcAndEncoding.reader.encoding", readerEncoding);
+ try {
+ buildRule.executeTarget("useSrcAndEncoding");
+ fail("should have failed with reader's encoding [" + readerEncoding +
+ "] different from the writer's encoding [" +
+ buildRule.getProject().getProperty("useSrcAndEncoding.encoding") + "]");
+ }
+ catch(BuildException e) {
+ assertTrue(e.getMessage().matches(
+ "expected <eacute \\[\u00e9]> but was <eacute \\[\u00c3\u00a9]>"));
+ }
+ }
+
+ @Test
+ public void testUseCompiled() {
+
+ final long duration;
+ {
+ long start = System.nanoTime();
+ buildRule.executeTarget("useCompiled");
+ duration = System.nanoTime() - start;
+ }
+
+ final long notCompiledDuration;
+ {
+ long start = System.nanoTime();
+ buildRule.executeTarget("useNotCompiled");
+ notCompiledDuration = System.nanoTime() - start;
+ }
+
+ assertTrue(duration < notCompiledDuration);
+ }
+}
diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java
new file mode 100644
index 0000000..389923f
--- /dev/null
+++ b/src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.types.selectors;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.attribute.UserPrincipal;
+
+import org.apache.tools.ant.taskdefs.condition.Os;
+import org.junit.Assume;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+public class OwnedBySelectorTest {
+
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder();
+
+ @Test
+ public void ownedByIsTrueForSelf() throws Exception {
+ // at least on Jenkins the file is owned by "BUILTIN\Administrators"
+ Assume.assumeFalse(Os.isFamily("windows"));
+ String self = System.getProperty("user.name");
+ File file = folder.newFile("f.txt");
+ UserPrincipal user = Files.getOwner(file.toPath());
+ assertEquals(self, user.getName());
+
+ OwnedBySelector s = new OwnedBySelector();
+ s.setOwner(self);
+ assertTrue(s.isSelected(null, null, file));
+ }
+
+}
diff --git a/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java
index 80a92a9..e27cc4d 100644
--- a/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java
@@ -116,12 +116,11 @@
assertTrue(j+" is normalized and in the JDK dir",
j.startsWith(javaHomeParent));
- if ((Os.isFamily("mac") && JavaEnvUtils.getJavaVersionNumber() <= JavaEnvUtils.VERSION_1_6)
- || JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
- assertTrue(j+" is normalized and in the JRE dir",
+ if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
+ assertTrue(j + " is normalized and in the JRE dir",
j.startsWith(javaHome));
} else {
- assertTrue(j+" is normalized and not in the JRE dir",
+ assertTrue(j + " is normalized and not in the JRE dir",
!j.startsWith(javaHome));
}
@@ -145,5 +144,4 @@
assertTrue("JAVA_1_9 is not considered equal to JAVA_9",
JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_9));
}
-
}
diff --git a/src/tests/junit/org/apache/tools/ant/util/PermissionUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/PermissionUtilsTest.java
new file mode 100644
index 0000000..c4dd8fc
--- /dev/null
+++ b/src/tests/junit/org/apache/tools/ant/util/PermissionUtilsTest.java
@@ -0,0 +1,160 @@
+/*
+ * 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.util;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.attribute.PosixFileAttributeView;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.EnumSet;
+import java.util.Set;
+
+import org.apache.tools.ant.types.resources.FileResource;
+import org.apache.tools.ant.types.resources.TarResource;
+import org.apache.tools.ant.types.resources.ZipResource;
+import org.apache.tools.tar.TarEntry;
+import org.apache.tools.tar.TarOutputStream;
+import org.apache.tools.zip.ZipEntry;
+import org.apache.tools.zip.ZipOutputStream;
+import org.junit.Assume;
+import org.junit.Test;
+
+public class PermissionUtilsTest {
+
+ @Test
+ public void modeFromPermissionsReturnsExpectedResult() {
+ int mode = PermissionUtils.modeFromPermissions(EnumSet.of(PosixFilePermission.OWNER_READ,
+ PosixFilePermission.OWNER_WRITE,
+ PosixFilePermission.OWNER_EXECUTE),
+ PermissionUtils.FileType.REGULAR_FILE);
+ assertEquals("100700", Integer.toString(mode, 8));
+ }
+
+ @Test
+ public void permissionsFromModeReturnsExpectedResult() {
+ Set<PosixFilePermission> s = PermissionUtils.permissionsFromMode(0100753);
+ assertEquals(EnumSet.of(PosixFilePermission.OWNER_READ,
+ PosixFilePermission.OWNER_WRITE,
+ PosixFilePermission.OWNER_EXECUTE,
+ PosixFilePermission.GROUP_READ,
+ PosixFilePermission.GROUP_EXECUTE,
+ PosixFilePermission.OTHERS_WRITE,
+ PosixFilePermission.OTHERS_EXECUTE),
+ s);
+ }
+
+ @Test
+ public void detectsFileTypeOfRegularFileFromPath() throws IOException {
+ File f = File.createTempFile("ant", ".tst");
+ f.deleteOnExit();
+ assertEquals(PermissionUtils.FileType.REGULAR_FILE,
+ PermissionUtils.FileType.of(f.toPath()));
+ }
+
+ @Test
+ public void detectsFileTypeOfRegularFileFromResource() throws IOException {
+ File f = File.createTempFile("ant", ".tst");
+ f.deleteOnExit();
+ assertEquals(PermissionUtils.FileType.REGULAR_FILE,
+ PermissionUtils.FileType.of(new FileResource(f)));
+ }
+
+ @Test
+ public void detectsFileTypeOfDirectoryFromPath() throws IOException {
+ File f = File.createTempFile("ant", ".dir");
+ f.delete();
+ f.mkdirs();
+ f.deleteOnExit();
+ assertEquals(PermissionUtils.FileType.DIR,
+ PermissionUtils.FileType.of(f.toPath()));
+ }
+
+ @Test
+ public void detectsFileTypeOfDirectoryFromResource() throws IOException {
+ File f = File.createTempFile("ant", ".tst");
+ f.delete();
+ f.mkdirs();
+ f.deleteOnExit();
+ assertEquals(PermissionUtils.FileType.DIR,
+ PermissionUtils.FileType.of(new FileResource(f)));
+ }
+
+ @Test
+ public void getSetPermissionsWorksForFiles() throws IOException {
+ File f = File.createTempFile("ant", ".tst");
+ f.deleteOnExit();
+ Assume.assumeNotNull(Files.getFileAttributeView(f.toPath(),
+ PosixFileAttributeView.class));
+ Set<PosixFilePermission> s =
+ EnumSet.of(PosixFilePermission.OWNER_READ,
+ PosixFilePermission.OWNER_WRITE,
+ PosixFilePermission.OWNER_EXECUTE,
+ PosixFilePermission.GROUP_READ);
+ PermissionUtils.setPermissions(new FileResource(f), s, null);
+ assertEquals(s, PermissionUtils.getPermissions(new FileResource(f), null));
+ }
+
+ @Test
+ public void getSetPermissionsWorksForZipResources() throws IOException {
+ File f = File.createTempFile("ant", ".zip");
+ f.deleteOnExit();
+ try (ZipOutputStream os = new ZipOutputStream(f)) {
+ ZipEntry e = new ZipEntry("foo");
+ os.putNextEntry(e);
+ os.closeEntry();
+ }
+
+ ZipResource r = new ZipResource();
+ r.setName("foo");
+ r.setArchive(f);
+ Set<PosixFilePermission> s =
+ EnumSet.of(PosixFilePermission.OWNER_READ,
+ PosixFilePermission.OWNER_WRITE,
+ PosixFilePermission.OWNER_EXECUTE,
+ PosixFilePermission.GROUP_READ);
+ PermissionUtils.setPermissions(r, s, null);
+ assertEquals(s, PermissionUtils.getPermissions(r, null));
+ }
+
+ @Test
+ public void getSetPermissionsWorksForTarResources() throws IOException {
+ File f = File.createTempFile("ant", ".zip");
+ f.deleteOnExit();
+ try (TarOutputStream os = new TarOutputStream(new FileOutputStream(f))) {
+ TarEntry e = new TarEntry("foo");
+ os.putNextEntry(e);
+ os.closeEntry();
+ }
+
+ TarResource r = new TarResource();
+ r.setName("foo");
+ r.setArchive(f);
+ Set<PosixFilePermission> s =
+ EnumSet.of(PosixFilePermission.OWNER_READ,
+ PosixFilePermission.OWNER_WRITE,
+ PosixFilePermission.OWNER_EXECUTE,
+ PosixFilePermission.GROUP_READ);
+ PermissionUtils.setPermissions(r, s, null);
+ assertEquals(s, PermissionUtils.getPermissions(r, null));
+ }
+}
diff --git a/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java
index 4dc43ee..612c6ec 100644
--- a/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java
@@ -1,170 +1,216 @@
-/*
- * 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.util;
-
-import java.util.Vector;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Test for StringUtils
- */
-public class StringUtilsTest {
-
- @Test
- public void testSplit(){
- final String data = "a,b,,";
- Vector res = StringUtils.split(data, ',');
- assertEquals(4, res.size());
- assertEquals("a", res.elementAt(0));
- assertEquals("b", res.elementAt(1));
- assertEquals("", res.elementAt(2));
- assertEquals("", res.elementAt(3));
- }
-
- @Test
- public void testSplitLines(){
- final String data = "a\r\nb\nc\nd\ne";
- Vector res = StringUtils.lineSplit(data);
- assertEquals(5, res.size());
- assertEquals("a\r", res.elementAt(0));
- assertEquals("b", res.elementAt(1));
- assertEquals("c", res.elementAt(2));
- assertEquals("d", res.elementAt(3));
- assertEquals("e", res.elementAt(4));
- }
-
- @Test
- public void testReplace() {
- final String data = "abcabcabca";
- String res = StringUtils.replace(data, "a", "");
- assertEquals("bcbcbc", res);
- }
-
- @Test
- public void testEndsWithBothEmpty() {
- assertTrue( StringUtils.endsWith( new StringBuffer(), "") );
- }
-
- @Test
- public void testEndsWithEmptyString() {
- assertTrue( StringUtils.endsWith( new StringBuffer("12234545"), "") );
- }
-
- @Test
- public void testEndsWithShorterString() {
- assertTrue( StringUtils.endsWith( new StringBuffer("12345678"), "78"));
- }
-
- @Test
- public void testEndsWithSameString() {
- assertTrue( StringUtils.endsWith( new StringBuffer("123"), "123"));
- }
-
- @Test
- public void testEndsWithLongerString() {
- assertFalse( StringUtils.endsWith( new StringBuffer("12"), "1245"));
- }
-
- @Test
- public void testEndsWithNoMatch() {
- assertFalse( StringUtils.endsWith( new StringBuffer("12345678"), "789"));
- }
-
- @Test
- public void testEndsWithEmptyBuffer() {
- assertFalse( StringUtils.endsWith( new StringBuffer(""), "12345667") );
- }
-
- @Test
- public void testEndsWithJDKPerf() {
- StringBuffer buf = getFilledBuffer(1024*300, 'a');
- for (int i = 0; i < 1000; i++) {
- assertTrue(buf.toString().endsWith("aa"));
- }
- }
-
- @Test
- public void testEndsWithPerf() {
- StringBuffer buf = getFilledBuffer(1024*300, 'a');
- for (int i = 0; i < 1000; i++) {
- assertTrue(StringUtils.endsWith(buf, "aa"));
- }
- }
-
- private StringBuffer getFilledBuffer(int size, char ch) {
- StringBuffer buf = new StringBuffer(size);
- for (int i = 0; i < size; i++) { buf.append(ch); };
- return buf;
- }
-
- @Test
- public void testParseHumanSizes() throws Exception {
- final long KILOBYTE = 1024;
- final long MEGABYTE = KILOBYTE * 1024;
- final long GIGABYTE = MEGABYTE * 1024;
- final long TERABYTE = GIGABYTE * 1024;
- final long PETABYTE = TERABYTE * 1024;
- assertEquals(StringUtils.parseHumanSizes("1K"), KILOBYTE);
- assertEquals(StringUtils.parseHumanSizes("1M"), MEGABYTE);
- assertEquals(StringUtils.parseHumanSizes("1G"), GIGABYTE);
- assertEquals(StringUtils.parseHumanSizes("1T"), TERABYTE);
- assertEquals(StringUtils.parseHumanSizes("1P"), PETABYTE);
- assertEquals(StringUtils.parseHumanSizes("1"), 1L);
- }
-
- @Test
- public void testRemoveSuffix() {
- String prefix = "Prefix";
- String name = "Name";
- String suffix = "Suffix";
- String input = prefix + name + suffix;
- assertEquals(
- "Does not remove the suffix right.",
- prefix + name,
- StringUtils.removeSuffix(input, suffix)
- );
- assertEquals(
- "Should leave the string unattended.",
- prefix + name + suffix,
- StringUtils.removeSuffix(input, "bla")
- );
- }
-
- @Test
- public void testRemovePrefix() {
- String prefix = "Prefix";
- String name = "Name";
- String suffix = "Suffix";
- String input = prefix + name + suffix;
- assertEquals(
- "Does not remove the prefix right.",
- name + suffix,
- StringUtils.removePrefix(input, prefix)
- );
- assertEquals(
- "Should leave the string unattended.",
- prefix + name + suffix,
- StringUtils.removePrefix(input, "bla")
- );
- }
-}
+/*
+ * 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.util;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Vector;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test for StringUtils
+ */
+public class StringUtilsTest {
+
+ @Test
+ public void testSplit(){
+ final String data = "a,b,,";
+ Vector<String> res = StringUtils.split(data, ',');
+ assertEquals(4, res.size());
+ assertEquals("a", res.elementAt(0));
+ assertEquals("b", res.elementAt(1));
+ assertEquals("", res.elementAt(2));
+ assertEquals("", res.elementAt(3));
+ }
+
+ @Test
+ public void testSplitLines(){
+ final String data = "a\r\nb\nc\nd\ne";
+ Vector<String> res = StringUtils.lineSplit(data);
+ assertEquals(5, res.size());
+ assertEquals("a\r", res.elementAt(0));
+ assertEquals("b", res.elementAt(1));
+ assertEquals("c", res.elementAt(2));
+ assertEquals("d", res.elementAt(3));
+ assertEquals("e", res.elementAt(4));
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testReplace() {
+ final String data = "abcabcabca";
+ String res = StringUtils.replace(data, "a", "");
+ assertEquals("bcbcbc", res);
+ }
+
+ @Test
+ public void testEndsWithBothEmpty() {
+ assertTrue( StringUtils.endsWith( new StringBuffer(), "") );
+ }
+
+ @Test
+ public void testEndsWithEmptyString() {
+ assertTrue( StringUtils.endsWith( new StringBuffer("12234545"), "") );
+ }
+
+ @Test
+ public void testEndsWithShorterString() {
+ assertTrue( StringUtils.endsWith( new StringBuffer("12345678"), "78"));
+ }
+
+ @Test
+ public void testEndsWithSameString() {
+ assertTrue( StringUtils.endsWith( new StringBuffer("123"), "123"));
+ }
+
+ @Test
+ public void testEndsWithLongerString() {
+ assertFalse( StringUtils.endsWith( new StringBuffer("12"), "1245"));
+ }
+
+ @Test
+ public void testEndsWithNoMatch() {
+ assertFalse( StringUtils.endsWith( new StringBuffer("12345678"), "789"));
+ }
+
+ @Test
+ public void testEndsWithEmptyBuffer() {
+ assertFalse( StringUtils.endsWith( new StringBuffer(""), "12345667") );
+ }
+
+ @Test
+ public void testEndsWithJDKPerf() {
+ StringBuffer buf = getFilledBuffer(1024*300, 'a');
+ for (int i = 0; i < 1000; i++) {
+ assertTrue(buf.toString().endsWith("aa"));
+ }
+ }
+
+ @Test
+ public void testEndsWithPerf() {
+ StringBuffer buf = getFilledBuffer(1024*300, 'a');
+ for (int i = 0; i < 1000; i++) {
+ assertTrue(StringUtils.endsWith(buf, "aa"));
+ }
+ }
+
+ private StringBuffer getFilledBuffer(int size, char ch) {
+ StringBuffer buf = new StringBuffer(size);
+ for (int i = 0; i < size; i++) { buf.append(ch); };
+ return buf;
+ }
+
+ @Test
+ public void testParseHumanSizes() throws Exception {
+ final long KILOBYTE = 1024;
+ final long MEGABYTE = KILOBYTE * 1024;
+ final long GIGABYTE = MEGABYTE * 1024;
+ final long TERABYTE = GIGABYTE * 1024;
+ final long PETABYTE = TERABYTE * 1024;
+ assertEquals(StringUtils.parseHumanSizes("1K"), KILOBYTE);
+ assertEquals(StringUtils.parseHumanSizes("1M"), MEGABYTE);
+ assertEquals(StringUtils.parseHumanSizes("1G"), GIGABYTE);
+ assertEquals(StringUtils.parseHumanSizes("1T"), TERABYTE);
+ assertEquals(StringUtils.parseHumanSizes("1P"), PETABYTE);
+ assertEquals(StringUtils.parseHumanSizes("1"), 1L);
+ }
+
+ @Test
+ public void testRemoveSuffix() {
+ String prefix = "Prefix";
+ String name = "Name";
+ String suffix = "Suffix";
+ String input = prefix + name + suffix;
+ assertEquals(
+ "Does not remove the suffix right.",
+ prefix + name,
+ StringUtils.removeSuffix(input, suffix)
+ );
+ assertEquals(
+ "Should leave the string unattended.",
+ prefix + name + suffix,
+ StringUtils.removeSuffix(input, "bla")
+ );
+ }
+
+ @Test
+ public void testRemovePrefix() {
+ String prefix = "Prefix";
+ String name = "Name";
+ String suffix = "Suffix";
+ String input = prefix + name + suffix;
+ assertEquals(
+ "Does not remove the prefix right.",
+ name + suffix,
+ StringUtils.removePrefix(input, prefix)
+ );
+ assertEquals(
+ "Should leave the string unattended.",
+ prefix + name + suffix,
+ StringUtils.removePrefix(input, "bla")
+ );
+ }
+
+ @Test
+ public void testJoin() {
+ assertEquals("a, b, c", StringUtils.join(Arrays.asList("a", "b", "c"), ", "));
+ }
+
+ @Test
+ public void testJoinEmptyArray() {
+ assertEquals("", StringUtils.join(new String[]{}, ", "));
+ }
+
+ @Test
+ public void testJoinNullCollection() {
+ assertEquals("", StringUtils.join((Collection<String>)null, ", "));
+ }
+
+ @Test
+ public void testJoinNullArray() {
+ assertEquals("", StringUtils.join((String[])null, ", "));
+ }
+
+ @Test
+ public void testJoinNullSeparator() {
+ assertEquals("abc", StringUtils.join(Arrays.asList("a", "b", "c"), null));
+ }
+
+ @Test
+ public void testTrimToNullWithNullInput(){
+ assertNull(StringUtils.trimToNull(null));
+ }
+
+ @Test
+ public void testTrimToNullWithEmptyInput(){
+ assertNull(StringUtils.trimToNull(""));
+ }
+
+ @Test
+ public void testTrimToNullWithBlankSpaceInput(){
+ assertNull(StringUtils.trimToNull(" "));
+ }
+
+ @Test
+ public void testTrimToNullWithInputPaddedWithSpace(){
+ assertEquals("aaBcDeF",StringUtils.trimToNull(" aaBcDeF "));
+ }
+}