New upstream version 1.9.8
Emmanuel Bourg
7 years ago
50 | 50 | Cedomir Igaly |
51 | 51 | Charles Hudak |
52 | 52 | Charlie Hubbard |
53 | Chris Hegarty | |
53 | 54 | Chris Povirk |
54 | 55 | Christian Knorr |
55 | 56 | Christian Schmidt |
76 | 77 | Dale Anson |
77 | 78 | Dale Sherwood |
78 | 79 | Dan Armbrust |
80 | Dana Dahlstrom | |
79 | 81 | Daniel Henrique |
80 | 82 | Daniel Ribagnac |
81 | 83 | Daniel Spilker |
135 | 137 | Gero Vermaas |
136 | 138 | Gerrit Riessen |
137 | 139 | Gilbert Rebhan |
140 | Gilles Querret | |
138 | 141 | Gilles Scokart |
139 | 142 | Glenn McAllister |
140 | 143 | Glenn Twiggs |
250 | 253 | Matthew Inger |
251 | 254 | Matthew Kuperus Heun |
252 | 255 | Matthew Watson |
256 | Matthew Yanos | |
253 | 257 | Matthias Bhend |
254 | 258 | Michael Bayne |
255 | 259 | Michael Clarke |
399 | 403 | Victor Toni |
400 | 404 | Vimil Saju |
401 | 405 | Vincent Legoll |
406 | Vincent Privat | |
402 | 407 | Vitold Sedyshev |
403 | 408 | Volker Leidl |
404 | 409 | Waldek Herka |
0 | Changes from Ant 1.9.7 TO Ant 1.9.8 | |
1 | =================================== | |
2 | ||
3 | Changes that could break older environments: | |
4 | ------------------------------------------- | |
5 | ||
6 | * <fileset>/<zipfileset>/<tarfileset> exhibited undefined | |
7 | behavior when both the dir and file attribute have been used on the | |
8 | same instance. This will now cause the build to fail. | |
9 | Bugzilla Report 59402 | |
10 | ||
11 | * The ant.java.version property will now hold the value "9" rather | |
12 | than "1.9" if running on Java 9. | |
13 | ||
14 | * <rmic> will no longer allow the -Xnew option (or xmic compiler) to | |
15 | be used when running on Java 9 since this option has been removed. | |
16 | Bugzilla Report 59906 | |
17 | ||
18 | Fixed bugs: | |
19 | ----------- | |
20 | ||
21 | * setDynamicAttribute on MacroInstance now lower-cases the attribute | |
22 | name in order to allow users of the API to use the attributes names | |
23 | they have specified. | |
24 | Bugzilla Report 59339 | |
25 | ||
26 | * <get>'s quiet attribute was broken, it didn't suppress any messages. | |
27 | Bugzilla Report 59379 | |
28 | ||
29 | * <zip>'s check whether an archive is already up-to-date failed on | |
30 | NTFS filesystems and re-created archives more often than necessary. | |
31 | Bugzilla Report 59562 | |
32 | ||
33 | * AntClassLoader didn't delegate to the parent loader for classes in | |
34 | the "jdk" package or one of its subpackages. This hierarchy has | |
35 | been introduced with Java 7. | |
36 | Bugzilla Report 59556 | |
37 | ||
38 | * The ant wrapper script used on Unix-like operating systems only | |
39 | worked on OSes where sed is GNU sed. | |
40 | Bugzilla Report 59898 | |
41 | ||
42 | * <touch>'s default pattern as well as the default patterns used by | |
43 | the <date> (resource) selectors depended on the JDK being used - or | |
44 | rather the locale provider being used and the default locale | |
45 | provider changed with Java 9. | |
46 | They are now fixed and the documentation has been updated to | |
47 | reflect the real patterns used rather than a non-formal description | |
48 | of the expected format. | |
49 | Bugzilla Report 59909 | |
50 | ||
51 | * Clarified the documentation of <get>'s retries attribute. | |
52 | Bugzilla Report 59930 | |
53 | ||
54 | * The ant wrapper script failed if backticks were passed on the | |
55 | command line. | |
56 | Bugzilla Report 60150, 59445 | |
57 | ||
58 | * The report generated by <junitreport> could contain duplicate | |
59 | characters in stack traces. | |
60 | Bugzilla Report 58661 | |
61 | ||
62 | Other changes: | |
63 | -------------- | |
64 | ||
65 | * <junit> now initializes the cause of the AssertionFailedError when | |
66 | converting from AssertionError. | |
67 | Bugzilla Report 58982 | |
68 | ||
69 | * <scp> now supports compression via the optional compressed attribute. | |
70 | Bugzilla Report 47552 | |
71 | ||
72 | * <junit> now supports JDK9 modules | |
73 | Github Pull Request #18 | |
74 | ||
75 | * a new implementation "builtin" has been added to <native2ascii> and | |
76 | is the default when running on JDK9+ since the tool itself has been | |
77 | removed from the JDK. | |
78 | Bugzilla Report 59855 | |
79 | ||
80 | * added a new <native2asciifilter> filter that can perform non-ASCII | |
81 | to Unicode-escape conversions. | |
82 | ||
83 | * <rmic> defaults to the "forking" compiler on JDK 9+ as the | |
84 | implementation class of rmic is not exported by its containing | |
85 | module and thus not accessible to Ant without applying -XaddExports | |
86 | magic. | |
87 | Bugzilla Report 59860 | |
88 | ||
89 | * a new implementation "forking" has been added to <javah> and is | |
90 | used as default when running on JDK9. | |
91 | ||
92 | * support for javac's -h switch has been added with the | |
93 | nativeheaderdir attribute. | |
94 | Bugzilla Report 59905 | |
95 | ||
96 | * it is now possible to set features of the TraX factory used by <xslt> | |
97 | and <junitreport>. | |
98 | ||
99 | * it is now possible to use references to Ant types and classloaders | |
100 | built around Ant <path>s as values for TraX factory attributes. | |
101 | ||
102 | * <junitreport> now enables the feature | |
103 | http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions | |
104 | when run on Java 9 so the redirect extension function can be used | |
105 | if when a SecurityManager is active. | |
106 | Bugzilla Report 60060 | |
107 | ||
108 | * support for javac's --release switch introduced with Java9 has been | |
109 | added. | |
110 | Bugzilla Report 60172 | |
111 | ||
0 | 112 | Changes from Ant 1.9.6 TO Ant 1.9.7 |
1 | 113 | =================================== |
2 | 114 |
52 | 52 | echo JAVA=%JAVA% |
53 | 53 | echo JAVAC=%JAVAC% |
54 | 54 | echo CLASSPATH=%CLASSPATH% |
55 | echo ANT_HOME=%ANT_HOME% | |
55 | 56 | |
56 | 57 | if "%OS%" == "Windows_NT" if exist %CLASSDIR%\nul rmdir/s/q %CLASSDIR% |
57 | 58 | if not "%OS%" == "Windows_NT" if exist %CLASSDIR%\nul deltree/y %CLASSDIR% |
33 | 33 | <property name="name" value="ant"/> |
34 | 34 | <!-- this is the groupId of ant in the Maven repository --> |
35 | 35 | <property name="groupid" value="org/apache/ant"/> |
36 | <property name="project.version" value="1.9.7"/> | |
36 | <property name="project.version" value="1.9.8"/> | |
37 | 37 | <!-- pom.version is used when doing a distribution and must match with what is checked in under src/etc/poms --> |
38 | <property name="pom.version" value="1.9.7"/> | |
39 | <property name="manifest-version" value="1.9.7"/> | |
38 | <property name="pom.version" value="1.9.8"/> | |
39 | <property name="manifest-version" value="1.9.8"/> | |
40 | 40 | <property name="bootstrap.jar" value="ant-bootstrap.jar"/> |
41 | 41 | |
42 | 42 | <property name="ant.package" value="org/apache/tools/ant"/> |
377 | 377 | <available property="jdk1.6+" classname="java.net.CookieStore"/> |
378 | 378 | <available property="jdk1.7+" classname="java.nio.file.FileSystem"/> |
379 | 379 | <available property="jdk1.8+" classname="java.lang.reflect.Executable"/> |
380 | <condition property="jdk1.9+"> | |
381 | <contains string="${java.version}" substring="1.9."/> | |
382 | </condition> | |
380 | <available property="jdk9+" classname="java.lang.module.ModuleDescriptor"/> | |
383 | 381 | <available property="kaffe" classname="kaffe.util.NotImplemented"/> |
384 | 382 | <available property="harmony" |
385 | 383 | classname="org.apache.harmony.luni.util.Base64"/> |
226 | 226 | </name> |
227 | 227 | <name> |
228 | 228 | <first>Chris</first> |
229 | <last>Hegarty</last> | |
230 | </name> | |
231 | <name> | |
232 | <first>Chris</first> | |
229 | 233 | <last>Povirk</last> |
230 | 234 | </name> |
231 | 235 | <name> |
331 | 335 | <last>Armbrust</last> |
332 | 336 | </name> |
333 | 337 | <name> |
338 | <first>Dana</first> | |
339 | <last>Dahlstrom</last> | |
340 | </name> | |
341 | <name> | |
334 | 342 | <first>Daniel</first> |
335 | 343 | <last>Henrique</last> |
336 | 344 | </name> |
569 | 577 | </name> |
570 | 578 | <name> |
571 | 579 | <first>Gilles</first> |
580 | <last>Querret</last> | |
581 | </name> | |
582 | <name> | |
583 | <first>Gilles</first> | |
572 | 584 | <last>Scokart</last> |
573 | 585 | </name> |
574 | 586 | <name> |
1033 | 1045 | <last>Watson</last> |
1034 | 1046 | </name> |
1035 | 1047 | <name> |
1048 | <first>Matthew</first> | |
1049 | <last>Yanos</last> | |
1050 | </name> | |
1051 | <name> | |
1036 | 1052 | <first>Michael</first> |
1037 | 1053 | <last>Bayne</last> |
1038 | 1054 | </name> |
1604 | 1620 | <last>Legoll</last> |
1605 | 1621 | </name> |
1606 | 1622 | <name> |
1623 | <first>Vincent</first> | |
1624 | <last>Privat</last> | |
1625 | </name> | |
1626 | <name> | |
1607 | 1627 | <first>Vimil</first> |
1608 | 1628 | <last>Saju</last> |
1609 | 1629 | </name> |
56 | 56 | regexp.version=1.3 |
57 | 57 | servlet-api.version=2.3 |
58 | 58 | which.version=1.0 |
59 | xalan.version=2.7.1 | |
59 | xalan.version=2.7.2 | |
60 | 60 | xml-resolver.version=1.2 |
61 | 61 | mail.version=1.4 |
62 | 62 | #paired |
106 | 106 | </tr> |
107 | 107 | <tr> |
108 | 108 | <td valign="top">retries</td> |
109 | <td valign="top">the per download number of retries on error<br/> | |
109 | <td valign="top">The number of attempts to make for opening the URI.<br/> | |
110 | The name of the attribute is misleading as a value of 1 means | |
111 | "don't retry on error" and a value of 0 meant don't even try to | |
112 | reach the URI at all.<br/> | |
110 | 113 | <em>since Ant 1.8.0</em></td> |
111 | 114 | <td align="center" valign="top">No; default "3"</td> |
112 | 115 | </tr> |
78 | 78 | <code>javac1.6</code> and |
79 | 79 | <code>javac1.7</code> (<em>since Ant 1.8.2</em>) and |
80 | 80 | <code>javac1.8</code> (<em>since Ant 1.8.3</em>) and</li> |
81 | <code>javac1.9</code> (<em>since Ant 1.9.5</em>) can be used as aliases.</li> | |
81 | <code>javac1.9</code> (<em>since Ant 1.9.5</em>) and</li> | |
82 | <code>javac9</code> (<em>since Ant 1.9.8</em>) can be used as aliases.</li> | |
82 | 83 | <li><code>jikes</code> (the <a |
83 | 84 | href="http://jikes.sourceforge.net/" target="_top">Jikes</a> |
84 | 85 | compiler).</li> |
123 | 124 | The side effect of this is that you will not be able to delete or move |
124 | 125 | those files later on in the build. The workaround is to fork when |
125 | 126 | invoking the compiler.</p> |
127 | <p>If you are using Java 8 or above and your source contains native | |
128 | methods or fields annotated with the <code>@Native</code> annotation | |
129 | you can set the <code>nativeheaderdir</code> attribute in order to | |
130 | use the <code>-h</code> switch of <code>javac</code> to generate the | |
131 | native header files. Note that the logic Ant uses to determine which | |
132 | files to compile does not take native headers into account, i.e. if | |
133 | the <code>.class</code> is more recent than the | |
134 | corresponding <code>.java</code> file the file will not get compiled | |
135 | even if a native header file generated for it would be outdated.</p> | |
126 | 136 | <h3>Parameters</h3> |
127 | 137 | <table border="1" cellpadding="2" cellspacing="0"> |
128 | 138 | <tr> |
501 | 511 | <td valign="top"> |
502 | 512 | The upgrademodulepath to use, given as <a href="../using.html#references">reference</a> to a PATH defined elsewhere. |
503 | 513 | <em>since Ant 1.9.7</em></td> |
514 | <td align="center" valign="top">No</td> | |
515 | </tr> | |
516 | <tr> | |
517 | <td valign="top">nativeheaderdir</td> | |
518 | <td valign="top"> | |
519 | Specify where to place generated native header files. Ignored | |
520 | when running on JDK < 8. | |
521 | <em>Since Ant 1.9.8</em>. | |
522 | <td align="center" valign="top">No</td> | |
523 | </tr> | |
524 | <tr> | |
525 | <td valign="top">release</td> | |
526 | <td valign="top"> | |
527 | Specify the value for the <code>--release</code> switch.Ignored | |
528 | when running on JDK < 9.<br> | |
529 | When set and running on JDK >= 9 the source and target | |
530 | attributes as well as the bootclasspath will be ignored. | |
531 | <em>Since Ant 1.9.8</em>. | |
504 | 532 | <td align="center" valign="top">No</td> |
505 | 533 | </tr> |
506 | 534 | </table> |
32 | 32 | or <a href="http://java.sun.com/products/jdk/1.1/docs/tooldocs/win32/javah.html">pre-JDK1.2</a> |
33 | 33 | systems are used.</p> |
34 | 34 | |
35 | <p>If you are building with Java 8 or above consider | |
36 | using <a href="javac.html"><code>javac</code></a>'s <code>nativeheaderdir</code> | |
37 | attribute instead which allows you to compile the classes and | |
38 | generate the native header files with a single step.</p> | |
39 | ||
40 | <p><b>Note</b> the <code>javah</code> has been deprecated as of Java 9 | |
41 | and is scheduled to be removed with Java 10.</p> | |
42 | ||
35 | 43 | <p>It is possible to use different compilers. This can be selected |
36 | 44 | with the <code>implementation</code> attribute or a nested element. <a |
37 | 45 | name="implementationvalues">Here are the choices of the attribute</a>:</p> |
38 | 46 | <ul> |
39 | <li>default - the default compiler (kaffeh or sun) for the platform.</li> | |
40 | <li>sun (the standard compiler of the JDK)</li> | |
47 | <li>default - the default compiler for the platform.</li> | |
48 | <li>sun (the standard compiler of the JDK) - default when not | |
49 | running on Kaffee or gcj/gij or Java9.</li> | |
41 | 50 | <li>kaffeh (the native standard compiler of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> |
42 | 51 | <li>gcjh (the native standard compiler |
43 | 52 | of <a href="http://gcc.gnu.org/java/" |
44 | target="_top">gcj and gij</a>) <em>since Apache Ant 1.8.2</em></li> | |
53 | target="_top">gcj and gij</a>) <em>since Apache Ant 1.8.2</em></li> | |
54 | <li>forking - runs the javah executable via its command line | |
55 | interface in a separate process. Default when running on | |
56 | Java9. <em>since Ant 1.9.8</em></li> | |
45 | 57 | </ul> |
46 | 58 | |
47 | 59 | <p><b>Note:</b> if you are using this task to work on multiple files |
369 | 369 | <p>Assertion statements are currently ignored in non-forked mode.</p> |
370 | 370 | |
371 | 371 | <p><em>since Ant 1.6.</em></p> |
372 | ||
373 | <h4>modulepath</h4> | |
374 | ||
375 | <p>The location of modules can be specified using this <a href="../using.html#path">PATH like structure</a>.<br/> | |
376 | The modulepath requires <i>fork</i> to be set to <code>true</code>. | |
377 | ||
378 | <p><em>since Ant 1.9.8</em></p> | |
379 | ||
380 | <h4>upgrademodulepath</h4> | |
381 | ||
382 | <p>The location of modules that replace upgradeable modules in the runtime image | |
383 | can be specified using this <a href="../using.html#path">PATH like structure</a>.<br/> | |
384 | The upgrademodulepath requires <i>fork</i> to be set to <code>true</code>. | |
385 | ||
386 | <p><em>since Ant 1.9.8</em></p> | |
372 | 387 | |
373 | 388 | <h4>formatter</h4> |
374 | 389 | |
795 | 810 | The two nested formatters are for displaying (for the user) and for updating the collector |
796 | 811 | class. |
797 | 812 | </p> |
798 | ||
799 | ||
813 | <pre> | |
814 | <junit fork="true" | |
815 | jvm="${platform.java}"> | |
816 | <jvmarg line="--patch-module ${module.name}=${build.test.classes}"/> | |
817 | <jvmarg line="--add-modules ${module.name}"/> | |
818 | <jvmarg line="--add-reads ${module.name}=ALL-UNNAMED"/> | |
819 | <jvmarg line="--add-exports ${module.name}/my.test=ALL-UNNAMED"/> | |
820 | <classpath> | |
821 | <pathelement path="${libs.junit}"/> | |
822 | </classpath> | |
823 | <modulepath> | |
824 | <pathelement path="${modules}:${build.classes}"/> | |
825 | </modulepath> | |
826 | <formatter type="plain"/> | |
827 | <test name="my.test.TestCase"/> | |
828 | </junit> | |
829 | </pre> | |
830 | <p>Runs my.test.TestCase as a white-box test in the forked VM given by the <code>platform.java</code> property. | |
831 | The junit library is a part of an unnamed module while the tested project and required modules are on the module path. The tests | |
832 | do not have module-info file and are executed in the project module given by <code>module.name</code> property.<br/> | |
833 | The <code>--patch-module</code> java option executes the tests built into <code>${build.test.classes}</code> in a module given | |
834 | by <code>module.name</code> property.<br/> | |
835 | The <code>--add-modules</code> java option enables the tested module.<br/> | |
836 | The <code>--add-reads</code> java option makes the unnamed module containing the junit readable by tested module.<br/> | |
837 | The <code>--add-exports</code> java option makes the non-exported test package <code>my.test</code> accessible from the unnamed module containing the junit.<br/> | |
838 | <pre> | |
839 | <junit fork="true" | |
840 | jvm="${platform.java}"> | |
841 | <jvmarg line="--add-modules ${test.module.name}"/> | |
842 | <jvmarg line="--add-exports ${test.module.name}/my.test=junit,ALL-UNNAMED"/> | |
843 | <modulepath> | |
844 | <pathelement path="${modules}:${build.classes}:${libs.junit}"/> | |
845 | </modulepath> | |
846 | <formatter type="plain"/> | |
847 | <test name="my.test.TestCase"/> | |
848 | </junit> | |
849 | </pre> | |
850 | <p>Runs my.test.TestCase as a black-box test in the forked VM given by the <code>platform.java</code> property. | |
851 | The junit library is used as an automatic module. The tests module-info requires the tested module and junit.<br/> | |
852 | The <code>--add-modules</code> java option enables the test module.<br/> | |
853 | The <code>--add-exports</code> java option makes the non-exported test package <code>my.test</code> accessible from the junit module and Ant's test runner. | |
854 | Another possibility is to export the test package in the tests module-info by <code>exports my.test</code> directive.<br/> | |
800 | 855 | </body> |
801 | 856 | </html> |
60 | 60 | with the <code>implementation</code> attribute or a nested element. |
61 | 61 | <a name="implementationvalues">Here are the choices of the attribute</a>:</p> |
62 | 62 | <ul> |
63 | <li>default - the default converter (kaffe or sun) for the platform.</li> | |
64 | <li>sun (the standard converter of the JDK)</li> | |
65 | <li>kaffe (the standard converter of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> | |
63 | <li>default - the default converter for the platform - kaffee | |
64 | when run on Kaffee, builtin if JDK9 or newer is detected, sun | |
65 | otherwise.</li> | |
66 | <li>sun (the standard converter of the JDK < 9)</li> | |
67 | <li>kaffe (the standard converter | |
68 | of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> | |
69 | <li>builtin - Ant's internal implementation used for | |
70 | JDK9+. <em>since ant 1.9.8</em></li> | |
66 | 71 | </ul> |
67 | 72 | |
68 | 73 | <table border="1" cellpadding="2" cellspacing="0"> |
75 | 80 | <td>reverse</td> |
76 | 81 | <td>Reverse the sense of the conversion, |
77 | 82 | i.e. convert from ASCII to native <b>only supported by the |
78 | sun converter</b></td> | |
83 | sun and builtin converters</b></td> | |
79 | 84 | <td align="center">No</td> |
80 | 85 | </tr> |
81 | 86 | <tr> |
51 | 51 | attribute. or a nested element. |
52 | 52 | <a name="compilervalues">Here are the choices</a>:</p> |
53 | 53 | <ul> |
54 | <li>default -the default compiler (kaffe or sun) for the platform. | |
55 | <li>sun (the standard compiler of the JDK)</li> | |
54 | <li>default -the default compiler (kaffe, sun or forking) for the platform. | |
55 | <li>sun (the standard compiler of the JDK < JDK 9)</li> | |
56 | 56 | <li>kaffe (the standard compiler of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> |
57 | 57 | <li>weblogic</li> |
58 | <li>forking - the sun compiler forked into a separate process (since Apache Ant 1.7)</li> | |
58 | <li>forking - the sun compiler forked into a separate process (since | |
59 | Apache Ant 1.7). Starting with Ant 1.9.8 this is the default when | |
60 | running on JDK 9+.</li> | |
59 | 61 | <li>xnew - the sun compiler forked into a separate process, |
60 | 62 | with the -Xnew option (since Ant 1.7). |
61 | This is the most reliable way to use -Xnew</li> | |
63 | This is the most reliable way to use -Xnew. | |
64 | <br></br>JDK9 has removed support for -Xnew and starting with Ant | |
65 | 1.9.8 this option will be rejected by ant when running on JDK9.</li> | |
62 | 66 | <li> "" (empty string). This has the same behaviour as not setting the compiler attribute. |
63 | 67 | First the value of <tt>build.rmic</tt> is used if defined, and if not, the default |
64 | 68 | for the platform is chosen. If build.rmic is set to this, you get the default. |
215 | 215 | used if serverAliveIntervalSeconds is not 0. |
216 | 216 | <em>since Ant 1.9.7</em></td> |
217 | 217 | <td align="center" valign="top">No, defaults to 3</td> |
218 | </tr> | |
219 | <tr> | |
220 | <td valign="top">compressed</td> | |
221 | <td valign="top">Whether to enable compression during transfer. | |
222 | <em>since Ant 1.9.8</em></td> | |
223 | <td align="center" valign="top">No, defaults to false</td> | |
218 | 224 | </tr> |
219 | 225 | </table> |
220 | 226 | <h3>Parameters specified as nested elements</h3> |
68 | 68 | to an <code><xsl:param></code> declaration.</p> |
69 | 69 | <p>This task supports the use of a nested <a href="../Types/xmlcatalog.html">xmlcatalog</a> |
70 | 70 | element which is used to perform Entity and URI resolution.</p> |
71 | ||
72 | <p><b>Note on XSLT extension functions</b>: when using the default | |
73 | TraX implementation of the Java class library and | |
74 | a <code>SecurityManager</code> is active - e.g. when running from | |
75 | within an IDE - XSLT extension functions cannot be used as "secure | |
76 | processing" is active in Java 7 and above. Ant contains a special | |
77 | "hack" that allows XSLT extensions to be used in Java 7 and 8, but | |
78 | this hack fails for Java 9. If you want to use extensions like the | |
79 | redirect extension that are provided by the Java class library | |
80 | itself, you can allow them by enabling the | |
81 | feature <code>http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions</code> | |
82 | in Java 9 and above. If you need to use an extension function not | |
83 | provided by Java itself you can set the | |
84 | attribute <code>jdk.xml.transform.extensionClassLoader</code> to a | |
85 | classloader (reference to an Ant PATH-like structure).</p> | |
86 | ||
71 | 87 | <h3>Parameters</h3> |
72 | 88 | <table border="1" cellpadding="2" cellspacing="0"> |
73 | 89 | <tr> |
394 | 410 | </tr> |
395 | 411 | </table> |
396 | 412 | <h3>Parameters specified as nested elements</h3> |
397 | <h4>attribute </h4> | |
413 | <h4>attribute</h4> | |
398 | 414 | <p>Used to specify settings of the processor factory. |
399 | 415 | The attribute names and values are entirely processor specific |
400 | 416 | so you must be aware of the implementation to figure them out. |
430 | 446 | <tr> |
431 | 447 | <td valign="top">value</td> |
432 | 448 | <td valign="top">value of the attribute.</td> |
449 | <td align="center" valign="middle" rowspan="3">Exactly one of these</td> | |
450 | </tr> | |
451 | <tr> | |
452 | <td valign="top">valueref</td> | |
453 | <td valign="top">value of the attribute is the value of the | |
454 | project reference with the given id. <em>since Ant 1.9.8</em></td> | |
455 | </tr> | |
456 | <tr> | |
457 | <td valign="top">classloaderforpath</td> | |
458 | <td valign="top">value of the attribute is a classloader that uses | |
459 | the classpath specified by a path that is the project reference | |
460 | with the given id. <em>since Ant 1.9.8</em></td> | |
461 | </tr> | |
462 | </table> | |
463 | ||
464 | <h4>Examples</h4> | |
465 | ||
466 | <pre> | |
467 | <path id="extension-path"> | |
468 | ... | |
469 | </path> | |
470 | ||
471 | ||
472 | <xslt ...> | |
473 | <factory> | |
474 | <attribute name="jdk.xml.transform.extensionClassLoader" | |
475 | classloaderforpath="extension-path"/> | |
476 | </factory> | |
477 | </xslt ...> | |
478 | </pre> | |
479 | <p>Sets the classloader to use when loading extension functions to a | |
480 | classloader using the <code>path</code> with the | |
481 | id <code>extension-path</code>. | |
482 | </blockquote> | |
483 | <h4>feature</h4> | |
484 | <p><em>since Ant 1.9.8</em></p> | |
485 | <p>Used to specify settings of the processor factory. The feature | |
486 | names are mostly processor specific so you must be aware of the | |
487 | implementation to figure them out. Read the documentation of your | |
488 | processor. The only feature all implementations are required to | |
489 | support | |
490 | is <code>http://javax.xml.XMLConstants/feature/secure-processing</code>. | |
491 | <blockquote> | |
492 | <h4>Parameters</h4> | |
493 | <table width="60%" border="1" cellpadding="2" cellspacing="0"> | |
494 | <tr> | |
495 | <td valign="top"><b>Attribute</b></td> | |
496 | <td valign="top"><b>Description</b></td> | |
497 | <td align="center" valign="top"><b>Required</b></td> | |
498 | </tr> | |
499 | <tr> | |
500 | <td valign="top">name</td> | |
501 | <td valign="top">Name of the feature</td> | |
433 | 502 | <td align="center" valign="top">Yes</td> |
503 | </tr> | |
504 | <tr> | |
505 | <td valign="top">value</td> | |
506 | <td valign="top">value of the feature. A boolean value | |
507 | (i.e. permitted values are true,false,yes,no,on,off).</td> | |
508 | <td align="center" valign="top">No, defaults to false</td> | |
434 | 509 | </tr> |
435 | 510 | </table> |
436 | 511 | </blockquote> |
73 | 73 | </tr> |
74 | 74 | <tr> |
75 | 75 | <td valign="top">pattern</td> |
76 | <td valign="top">SimpleDateFormat-compatible pattern string. | |
77 | Defaults to MM/DD/YYYY HH:MM AM_or_PM or MM/DD/YYYY HH:MM:SS AM_or_PM. | |
76 | <td valign="top">SimpleDateFormat-compatible pattern string using | |
77 | the current locale. | |
78 | Defaults to "MM/dd/YYYY hh:mm a" or "MM/dd/yyyy hh:mm:ss a" | |
79 | using the US locale. | |
78 | 80 | <b>Since Ant 1.6.3</b></td> |
79 | 81 | <td valign="top" align="center">No</td> |
80 | 82 | </tr> |
49 | 49 | <tr> |
50 | 50 | <td valign="top">dir</td> |
51 | 51 | <td valign="top">the root of the directory tree of this FileSet.</td> |
52 | <td valign="middle" align="center" rowspan="2">Either dir or file must be specified</td> | |
52 | <td valign="middle" align="center" rowspan="2">Exactly one of dir or file must be specified</td> | |
53 | 53 | </tr> |
54 | 54 | <tr> |
55 | 55 | <td valign="top">file</td> |
1142 | 1142 | <a href="#ignoreblank">IgnoreBlank</a><br> |
1143 | 1143 | <a href="#filterdeletecharacters">DeleteCharacters</a><br> |
1144 | 1144 | <a href="#uniqfilter">UniqFilter</a><br> |
1145 | <a href="#native2asciifilter">Native2AsciiFilter</a><br> | |
1145 | 1146 | </p> |
1146 | 1147 | |
1147 | 1148 | The following string filters are provided by the optional distribution. |
1483 | 1484 | <blockquote><pre> |
1484 | 1485 | <tokenfilter> |
1485 | 1486 | <uniqfilter/> |
1487 | </tokenfilter> | |
1488 | </pre></blockquote> | |
1489 | ||
1490 | <p><b><em><a name="native2asciifilter">Native2AsciiFilter</a></em></b></p> | |
1491 | ||
1492 | <p>Uses the "builtin" implementation of | |
1493 | the <a href="../Tasks/native2ascii.html">native2ascii</a> task.</p> | |
1494 | ||
1495 | <p>Replaces non-ascii characters by their Unicode-escapes or | |
1496 | vice-versa. <em>Since Ant 1.9.8</em>.</p> | |
1497 | ||
1498 | <p>This filter may be used directly within a filterchain.</p> | |
1499 | ||
1500 | <table cellSpacing=0 cellPadding=2 border=1> | |
1501 | <tr> | |
1502 | <td vAlign=top><b>Attribute</b></td> | |
1503 | <td vAlign=top><b>Description</b></td> | |
1504 | <td vAlign=top align="center"><b>Required</b></td> | |
1505 | </tr> | |
1506 | <tr> | |
1507 | <td vAlign=top>reverse</td> | |
1508 | <td vAlign=top>Reverse the sense of the conversion, | |
1509 | i.e. convert from ASCII to native.</td> | |
1510 | <td vAlign=top align="center">No</td> | |
1511 | </tr> | |
1512 | </table> | |
1513 | ||
1514 | <h4>Example:</h4> | |
1515 | ||
1516 | <p>This replaces all non-ASCII characters by their Unicode-escapes.</p> | |
1517 | <blockquote><pre> | |
1518 | <tokenfilter> | |
1519 | <native2asciifilter/> | |
1486 | 1520 | </tokenfilter> |
1487 | 1521 | </pre></blockquote> |
1488 | 1522 |
640 | 640 | <tr> |
641 | 641 | <td valign="top">pattern</td> |
642 | 642 | <td valign="top">SimpleDateFormat-compatible pattern |
643 | for use with the <code>datetime</code> attribute</td> | |
643 | for use with the <code>datetime</code> attribute using the | |
644 | current locale</td> | |
644 | 645 | <td align="center" valign="top"> |
645 | No, default is "MM/DD/YYYY HH:MM AM_or_PM"</td> | |
646 | No, default is "MM/dd/yyyy hh:mm a" using the US locale</td> | |
646 | 647 | </tr> |
647 | 648 | <tr> |
648 | 649 | <td valign="top">granularity</td> |
172 | 172 | <tr> |
173 | 173 | <td valign="top">datetime</td> |
174 | 174 | <td valign="top">Specifies the date and time to test for. |
175 | Should be in the format MM/DD/YYYY HH:MM AM_or_PM, or | |
176 | an alternative pattern specified via the <i>pattern</i> | |
177 | attribute. | |
175 | Should be in the format "MM/dd/yyyy hh:mm a" using the US | |
176 | locale, or an alternative pattern specified via | |
177 | the <i>pattern</i> attribute. | |
178 | 178 | </td> |
179 | 179 | <td valign="top" align="center" rowspan="2">At least one of the two.</td> |
180 | 180 | </tr> |
211 | 211 | <tr> |
212 | 212 | <td valign="top">pattern</td> |
213 | 213 | <td valign="top">The <CODE>SimpleDateFormat</CODE>-compatible pattern |
214 | to use when interpreting the <i>datetime</i> attribute. | |
214 | to use when interpreting the <i>datetime</i> attribute using | |
215 | the current locale. | |
215 | 216 | <i>Since Ant 1.6.2</i> |
216 | 217 | </td> |
217 | 218 | <td valign="top" align="center">No</td> |
18 | 18 | <head> |
19 | 19 | <meta http-equiv="Content-Language" content="en-us"> |
20 | 20 | <link rel="stylesheet" type="text/css" href="stylesheets/style.css"> |
21 | <title>Apache Ant 1.9.7 User Manual</title> | |
21 | <title>Apache Ant 1.9.8 User Manual</title> | |
22 | 22 | </head> |
23 | 23 | |
24 | 24 | <body bgcolor="#FFFFFF"> |
25 | 25 | <div align="center"> |
26 | 26 | <h1><img src="images/ant_logo_large.gif" width="190" height="120"></h1> |
27 | <h1>Apache Ant™ 1.9.7 Manual</h1> | |
28 | <p align="left">This is the manual for version 1.9.7 of | |
27 | <h1>Apache Ant™ 1.9.8 Manual</h1> | |
28 | <p align="left">This is the manual for version 1.9.8 of | |
29 | 29 | <a target="_top" href="http://ant.apache.org/index.html">Apache Ant</a>. |
30 | 30 | If your version |
31 | 31 | of Ant (as verified with <tt>ant -version</tt>) is older or newer than this |
61 | 61 | </ul> |
62 | 62 | |
63 | 63 | <center> |
64 | <p>Version: 1.9.7</p> | |
64 | <p>Version: 1.9.8</p> | |
65 | 65 | </center> |
66 | 66 | |
67 | 67 |
83 | 83 | will contain the project's default target in this |
84 | 84 | case for tasks nested into targets.. |
85 | 85 | ant.java.version the JVM version Ant detected; currently it can hold |
86 | the values "1.9", "1.8", | |
86 | the values "9", "1.8", | |
87 | 87 | "1.7", "1.6", "1.5", |
88 | 88 | "1.4", "1.3" and |
89 | "1.2". ant.core.lib the absolute path | |
90 | of the <code>ant.jar</code> file. | |
89 | "1.2". | |
90 | ant.core.lib the absolute path of the <code>ant.jar</code> file. | |
91 | 91 | </pre> |
92 | 92 | |
93 | 93 | <p>There is also another property, but this is set by the launcher |
929 | 929 | <xsl:template name="br-replace"> |
930 | 930 | <xsl:param name="word"/> |
931 | 931 | <xsl:param name="splitlimit">32</xsl:param> |
932 | <xsl:variable name="secondhalflen" select="(string-length($word)+(string-length($word) mod 2)) div 2"/> | |
933 | <xsl:variable name="secondhalfword" select="substring($word, $secondhalflen)"/> | |
932 | <xsl:variable name="secondhalfstartindex" select="(string-length($word)+(string-length($word) mod 2)) div 2"/> | |
933 | <xsl:variable name="secondhalfword" select="substring($word, $secondhalfstartindex)"/> | |
934 | 934 | <!-- When word is very big, a recursive replace is very heap/stack expensive, so subdivide on line break after middle of string --> |
935 | 935 | <xsl:choose> |
936 | 936 | <xsl:when test="(string-length($word) > $splitlimit) and (contains($secondhalfword, '
'))"> |
937 | 937 | <xsl:variable name="secondhalfend" select="substring-after($secondhalfword, '
')"/> |
938 | <xsl:variable name="firsthalflen" select="string-length($word) - $secondhalflen"/> | |
938 | <xsl:variable name="firsthalflen" select="string-length($word) - string-length($secondhalfword)"/> | |
939 | 939 | <xsl:variable name="firsthalfword" select="substring($word, 1, $firsthalflen)"/> |
940 | 940 | <xsl:variable name="firsthalfend" select="substring-before($secondhalfword, '
')"/> |
941 | 941 | <xsl:call-template name="br-replace"> |
469 | 469 | <xsl:template name="br-replace"> |
470 | 470 | <xsl:param name="word"/> |
471 | 471 | <xsl:param name="splitlimit">32</xsl:param> |
472 | <xsl:variable name="secondhalflen" select="(string-length($word)+(string-length($word) mod 2)) div 2"/> | |
473 | <xsl:variable name="secondhalfword" select="substring($word, $secondhalflen)"/> | |
472 | <xsl:variable name="secondhalfstartindex" select="(string-length($word)+(string-length($word) mod 2)) div 2"/> | |
473 | <xsl:variable name="secondhalfword" select="substring($word, $secondhalfstartindex)"/> | |
474 | 474 | <!-- When word is very big, a recursive replace is very heap/stack expensive, so subdivide on line break after middle of string --> |
475 | 475 | <xsl:choose> |
476 | 476 | <xsl:when test="(string-length($word) > $splitlimit) and (contains($secondhalfword, '
'))"> |
477 | 477 | <xsl:variable name="secondhalfend" select="substring-after($secondhalfword, '
')"/> |
478 | <xsl:variable name="firsthalflen" select="string-length($word) - $secondhalflen"/> | |
478 | <xsl:variable name="firsthalflen" select="string-length($word) - string-length($secondhalfword)"/> | |
479 | 479 | <xsl:variable name="firsthalfword" select="substring($word, 1, $firsthalflen)"/> |
480 | 480 | <xsl:variable name="firsthalfend" select="substring-before($secondhalfword, '
')"/> |
481 | 481 | <xsl:call-template name="br-replace"> |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant Core</name> |
37 | 37 | <dependencies> |
38 | 38 | <dependency> |
39 | 39 | <groupId>org.apache.ant</groupId> |
40 | 40 | <artifactId>ant-launcher</artifactId> |
41 | <version>1.9.7</version> | |
41 | <version>1.9.8</version> | |
42 | 42 | <scope>compile</scope> |
43 | 43 | </dependency> |
44 | 44 | <dependency> |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant-antlr</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant + ANTLR</name> |
37 | 37 | <description>antlr specific task. |
38 | 38 | The implementation forks a java process, therefore the antlr jar file is only needed at runtime</description> |
40 | 40 | <dependency> |
41 | 41 | <groupId>org.apache.ant</groupId> |
42 | 42 | <artifactId>ant</artifactId> |
43 | <version>1.9.7</version> | |
43 | <version>1.9.8</version> | |
44 | 44 | <optional>true</optional> |
45 | 45 | <scope>compile</scope> |
46 | 46 | </dependency> |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant-apache-bcel</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant + BCEL</name> |
37 | 37 | <dependencies> |
38 | 38 | <dependency> |
39 | 39 | <groupId>org.apache.ant</groupId> |
40 | 40 | <artifactId>ant</artifactId> |
41 | <version>1.9.7</version> | |
41 | <version>1.9.8</version> | |
42 | 42 | <scope>compile</scope> |
43 | 43 | </dependency> |
44 | 44 | <dependency> |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant-apache-bsf</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant + BSF</name> |
37 | 37 | <dependencies> |
38 | 38 | <dependency> |
39 | 39 | <groupId>org.apache.ant</groupId> |
40 | 40 | <artifactId>ant</artifactId> |
41 | <version>1.9.7</version> | |
41 | <version>1.9.8</version> | |
42 | 42 | <scope>compile</scope> |
43 | 43 | </dependency> |
44 | 44 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-apache-log4j</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + Log4J</name> |
36 | 36 | <dependencies> |
37 | 37 | <dependency> |
38 | 38 | <groupId>org.apache.ant</groupId> |
39 | 39 | <artifactId>ant</artifactId> |
40 | <version>1.9.7</version> | |
40 | <version>1.9.8</version> | |
41 | 41 | <scope>compile</scope> |
42 | 42 | </dependency> |
43 | 43 | <dependency> |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant-apache-oro</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant + Apache Oro</name> |
37 | 37 | <dependencies> |
38 | 38 | <dependency> |
39 | 39 | <groupId>org.apache.ant</groupId> |
40 | 40 | <artifactId>ant</artifactId> |
41 | <version>1.9.7</version> | |
41 | <version>1.9.8</version> | |
42 | 42 | <scope>compile</scope> |
43 | 43 | </dependency> |
44 | 44 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-apache-regexp</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + Apache Regexp</name> |
36 | 36 | <dependencies> |
37 | 37 | <dependency> |
38 | 38 | <groupId>org.apache.ant</groupId> |
39 | 39 | <artifactId>ant</artifactId> |
40 | <version>1.9.7</version> | |
40 | <version>1.9.8</version> | |
41 | 41 | <scope>compile</scope> |
42 | 42 | </dependency> |
43 | 43 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-apache-resolver</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + Apache Resolver</name> |
36 | 36 | <dependencies> |
37 | 37 | <dependency> |
38 | 38 | <groupId>org.apache.ant</groupId> |
39 | 39 | <artifactId>ant</artifactId> |
40 | <version>1.9.7</version> | |
40 | <version>1.9.8</version> | |
41 | 41 | <scope>compile</scope> |
42 | 42 | </dependency> |
43 | 43 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-apache-xalan2</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + Xalan 2</name> |
36 | 36 | <description>contains Xalan2-specific features</description> |
37 | 37 | <dependencies> |
38 | 38 | <dependency> |
39 | 39 | <groupId>org.apache.ant</groupId> |
40 | 40 | <artifactId>ant</artifactId> |
41 | <version>1.9.7</version> | |
41 | <version>1.9.8</version> | |
42 | 42 | <scope>compile</scope> |
43 | 43 | </dependency> |
44 | 44 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-commons-logging</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + Commons Logging</name> |
36 | 36 | <description>Ant Listener based on commons-logging</description> |
37 | 37 | <dependencies> |
38 | 38 | <dependency> |
39 | 39 | <groupId>org.apache.ant</groupId> |
40 | 40 | <artifactId>ant</artifactId> |
41 | <version>1.9.7</version> | |
41 | <version>1.9.8</version> | |
42 | 42 | <scope>compile</scope> |
43 | 43 | </dependency> |
44 | 44 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-commons-net</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + Commons Net</name> |
36 | 36 | <description>ftp, rexec and telnet tasks</description> |
37 | 37 | <dependencies> |
38 | 38 | <dependency> |
39 | 39 | <groupId>org.apache.ant</groupId> |
40 | 40 | <artifactId>ant</artifactId> |
41 | <version>1.9.7</version> | |
41 | <version>1.9.8</version> | |
42 | 42 | <scope>compile</scope> |
43 | 43 | </dependency> |
44 | 44 | <dependency> |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant-jai</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant + JAI</name> |
37 | 37 | <description>image task and corresponding types. |
38 | 38 | </description> |
40 | 40 | <dependency> |
41 | 41 | <groupId>org.apache.ant</groupId> |
42 | 42 | <artifactId>ant</artifactId> |
43 | <version>1.9.7</version> | |
43 | <version>1.9.8</version> | |
44 | 44 | <scope>compile</scope> |
45 | 45 | </dependency> |
46 | 46 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-javamail</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + JavaMail</name> |
36 | 36 | <description>implementation of the mail task based on javamail. |
37 | 37 | Required to send emails to SMTP servers using user/password combinations |
40 | 40 | <dependency> |
41 | 41 | <groupId>org.apache.ant</groupId> |
42 | 42 | <artifactId>ant</artifactId> |
43 | <version>1.9.7</version> | |
43 | <version>1.9.8</version> | |
44 | 44 | <scope>compile</scope> |
45 | 45 | </dependency> |
46 | 46 | <dependency> |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant-jdepend</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant + JDepend</name> |
37 | 37 | <description>task jdepend invoking the jdepend parser. There is also a version 2.9.1 of the |
38 | 38 | jdepend parser available on the maven repository</description> |
40 | 40 | <dependency> |
41 | 41 | <groupId>org.apache.ant</groupId> |
42 | 42 | <artifactId>ant</artifactId> |
43 | <version>1.9.7</version> | |
43 | <version>1.9.8</version> | |
44 | 44 | <scope>compile</scope> |
45 | 45 | </dependency> |
46 | 46 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-jmf</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + JMF</name> |
36 | 36 | <description>contains the sound task and a soundplayer listener |
37 | 37 | download the dependency from http://java.sun.com/products/java-media/jmf/</description> |
39 | 39 | <dependency> |
40 | 40 | <groupId>org.apache.ant</groupId> |
41 | 41 | <artifactId>ant</artifactId> |
42 | <version>1.9.7</version> | |
42 | <version>1.9.8</version> | |
43 | 43 | <scope>compile</scope> |
44 | 44 | </dependency> |
45 | 45 | </dependencies> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-jsch</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + JSch</name> |
36 | 36 | <description>contains the sshexec and scp tasks |
37 | 37 | </description> |
39 | 39 | <dependency> |
40 | 40 | <groupId>org.apache.ant</groupId> |
41 | 41 | <artifactId>ant</artifactId> |
42 | <version>1.9.7</version> | |
42 | <version>1.9.8</version> | |
43 | 43 | <scope>compile</scope> |
44 | 44 | </dependency> |
45 | 45 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-junit</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + JUnit</name> |
36 | 36 | <description>contains the junit and junirreport tasks</description> |
37 | 37 | <dependencies> |
38 | 38 | <dependency> |
39 | 39 | <groupId>org.apache.ant</groupId> |
40 | 40 | <artifactId>ant</artifactId> |
41 | <version>1.9.7</version> | |
41 | <version>1.9.8</version> | |
42 | 42 | <scope>compile</scope> |
43 | 43 | </dependency> |
44 | 44 | <dependency> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-junit4</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + JUnit 4</name> |
36 | 36 | <description>contains JUnit 4.x support</description> |
37 | 37 | <dependencies> |
38 | 38 | <dependency> |
39 | 39 | <groupId>org.apache.ant</groupId> |
40 | 40 | <artifactId>ant</artifactId> |
41 | <version>1.9.7</version> | |
41 | <version>1.9.8</version> | |
42 | 42 | <scope>compile</scope> |
43 | 43 | </dependency> |
44 | 44 | <dependency> |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant-launcher</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant Launcher</name> |
37 | 37 | <build> |
38 | 38 | <plugins> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | 27 | <relativePath>../pom.xml</relativePath> |
28 | <version>1.9.7</version> | |
28 | <version>1.9.8</version> | |
29 | 29 | </parent> |
30 | 30 | <modelVersion>4.0.0</modelVersion> |
31 | 31 | <url>http://ant.apache.org/</url> |
32 | 32 | <groupId>org.apache.ant</groupId> |
33 | 33 | <artifactId>ant-netrexx</artifactId> |
34 | <version>1.9.7</version> | |
34 | <version>1.9.8</version> | |
35 | 35 | <name>Apache Ant + NetRexx</name> |
36 | 36 | <description>NetRexxC task |
37 | 37 | dependency can be downloaded from http://www.ibm.com/software/awdtools/netrexx/download.html</description> |
39 | 39 | <dependency> |
40 | 40 | <groupId>org.apache.ant</groupId> |
41 | 41 | <artifactId>ant</artifactId> |
42 | <version>1.9.7</version> | |
42 | <version>1.9.8</version> | |
43 | 43 | <scope>compile</scope> |
44 | 44 | </dependency> |
45 | 45 | <!-- Processed too early, before maven-antrun-plugin gets a chance to work: |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant-swing</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant + Swing</name> |
37 | 37 | <description>a listener and a splash task based on Swing</description> |
38 | 38 | <dependencies> |
39 | 39 | <dependency> |
40 | 40 | <groupId>org.apache.ant</groupId> |
41 | 41 | <artifactId>ant</artifactId> |
42 | <version>1.9.7</version> | |
42 | <version>1.9.8</version> | |
43 | 43 | <scope>compile</scope> |
44 | 44 | </dependency> |
45 | 45 | </dependencies> |
26 | 26 | <groupId>org.apache.ant</groupId> |
27 | 27 | <artifactId>ant-parent</artifactId> |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | <version>1.9.7</version> | |
29 | <version>1.9.8</version> | |
30 | 30 | </parent> |
31 | 31 | <modelVersion>4.0.0</modelVersion> |
32 | 32 | <url>http://ant.apache.org/</url> |
33 | 33 | <groupId>org.apache.ant</groupId> |
34 | 34 | <artifactId>ant-testutil</artifactId> |
35 | <version>1.9.7</version> | |
35 | <version>1.9.8</version> | |
36 | 36 | <name>Apache Ant Test Utilities</name> |
37 | 37 | <description>test utility classes</description> |
38 | 38 | <dependencies> |
39 | 39 | <dependency> |
40 | 40 | <groupId>org.apache.ant</groupId> |
41 | 41 | <artifactId>ant</artifactId> |
42 | <version>1.9.7</version> | |
42 | <version>1.9.8</version> | |
43 | 43 | <scope>compile</scope> |
44 | 44 | </dependency> |
45 | 45 | <dependency> |
24 | 24 | <modelVersion>4.0.0</modelVersion> |
25 | 25 | <groupId>org.apache.ant</groupId> |
26 | 26 | <artifactId>ant-parent</artifactId> |
27 | <version>1.9.7</version> | |
27 | <version>1.9.8</version> | |
28 | 28 | <packaging>pom</packaging> |
29 | 29 | <description>master POM</description> |
30 | 30 | <licenses> |
31 | 31 | <fail> |
32 | 32 | <condition> |
33 | 33 | <not> |
34 | <antversion exactly="1.9.7" /> | |
34 | <antversion exactly="1.9.8" /> | |
35 | 35 | </not> |
36 | 36 | </condition> |
37 | Should be exactly 1.9.7 | |
37 | Should be exactly 1.9.8 | |
38 | 38 | |
39 | 39 | </fail> |
40 | 40 | </target> |
44 | 44 | <fail> |
45 | 45 | <condition> |
46 | 46 | <not> |
47 | <antversion atleast="1.9.7" /> | |
47 | <antversion atleast="1.9.8" /> | |
48 | 48 | </not> |
49 | 49 | </condition> |
50 | Should be at least 1.9.7 | |
50 | Should be at least 1.9.8 | |
51 | 51 | </fail> |
52 | 52 | </target> |
53 | 53 | |
56 | 56 | <fail> |
57 | 57 | <condition> |
58 | 58 | <not> |
59 | <antversion exactly="1.9.7" /> | |
59 | <antversion exactly="1.9.8" /> | |
60 | 60 | </not> |
61 | 61 | </condition> |
62 | Should be exactly 1.9.7 | |
62 | Should be exactly 1.9.8 | |
63 | 63 | </fail> |
64 | 64 | </target> |
65 | 65 | </project> |
199 | 199 | |
200 | 200 | <target name="probe-rmic"> |
201 | 201 | <available property="kaffe.present" classname="jkaffe.rmi.rmic.RMIC"/> |
202 | <available property="rmic.present" classname="sun.rmi.rmic.Main"/> | |
202 | <condition property="rmic.present"> | |
203 | <or> | |
204 | <available classname="sun.rmi.rmic.Main"/> | |
205 | <!-- we'll use forking as default for Java9 --> | |
206 | <available classname="java.lang.module.ModuleDescriptor"/> | |
207 | </or> | |
208 | </condition> | |
209 | <condition property="rmic.compiler" value="forking"> | |
210 | <available classname="java.lang.module.ModuleDescriptor"/> | |
211 | </condition> | |
212 | <property name="rmic.compiler" value="sun"/> | |
203 | 213 | <available property="wlrmic.present" classname="weblogic.rmic"/> |
204 | <condition property="rmic5.present"> | |
205 | <and> | |
206 | <isset property="rmic.present"/> | |
207 | <available classname="java.net.Proxy"/> | |
208 | </and> | |
209 | </condition> | |
210 | 214 | <condition property="rmic6.present"> |
211 | 215 | <and> |
212 | 216 | <isset property="rmic.present"/> |
268 | 272 | </target> |
269 | 273 | |
270 | 274 | <target name="testRmic" if="rmic.present" depends="init"> |
271 | <base-rmic compiler="sun"/> | |
275 | <base-rmic compiler="${rmic.compiler}"/> | |
272 | 276 | <assertBaseCompiled/> |
273 | 277 | </target> |
274 | 278 | |
275 | 279 | <target name="testRmicDest" if="rmic.present" depends="init"> |
276 | <dest-rmic compiler="sun"/> | |
280 | <dest-rmic compiler="${rmic.compiler}"/> | |
277 | 281 | <assertBaseCompiledInDest/> |
278 | 282 | </target> |
279 | 283 | |
280 | 284 | <target name="testRmicJArg" if="rmic.present" depends="init"> |
281 | <base-rmic compiler="sun"> | |
285 | <base-rmic compiler="${rmic.compiler}"> | |
282 | 286 | <compilerarg value="-J-mx256m" /> |
283 | 287 | </base-rmic> |
284 | 288 | <assertBaseCompiled/> |
285 | 289 | </target> |
286 | 290 | |
287 | 291 | <target name="testRmicJArgDest" if="rmic.present" depends="init"> |
288 | <dest-rmic compiler="sun"> | |
292 | <dest-rmic compiler="${rmic.compiler}"> | |
289 | 293 | <compilerarg value="-J-mx256m" /> |
290 | 294 | </dest-rmic> |
291 | 295 | <assertBaseCompiledInDest/> |
327 | 331 | <assertBaseCompiled/> |
328 | 332 | </target> |
329 | 333 | |
330 | <target name="testBadName" if="rmic.present" depends="init"> | |
334 | <target name="testBadName" depends="init"> | |
331 | 335 | <base-rmic |
332 | 336 | compiler="no-such-compiler" |
333 | 337 | /> |
335 | 339 | |
336 | 340 | <target name="testExplicitClass" if="rmic.present" depends="init"> |
337 | 341 | <base-rmic |
338 | compiler="org.apache.tools.ant.taskdefs.rmic.SunRmic" | |
342 | compiler="org.apache.tools.ant.taskdefs.rmic.ForkingSunRmic" | |
339 | 343 | /> |
340 | 344 | <assertBaseCompiled/> |
341 | 345 | </target> |
342 | 346 | |
343 | <target name="testWrongClass" if="rmic.present" depends="init"> | |
347 | <target name="testWrongClass" depends="init"> | |
344 | 348 | <base-rmic |
345 | 349 | compiler="org.apache.tools.ant.BuildException" |
346 | 350 | /> |
394 | 398 | <assertAntCompiledInDest/> |
395 | 399 | </target> |
396 | 400 | |
397 | <target name="testForkingAntClasspath" if="rmic.present" depends="compileAntTimestamp"> | |
401 | <target name="testForkingAntClasspath" depends="compileAntTimestamp"> | |
398 | 402 | <base-rmic |
399 | 403 | compiler="forking" |
400 | 404 | /> |
401 | 405 | <assertAntCompiled /> |
402 | 406 | </target> |
403 | 407 | |
404 | <target name="testForkingAntClasspathDest" if="rmic.present" depends="compileAntTimestamp"> | |
408 | <target name="testForkingAntClasspathDest" depends="compileAntTimestamp"> | |
405 | 409 | <dest-rmic |
406 | 410 | compiler="forking" |
407 | 411 | /> |
433 | 437 | <!-- |
434 | 438 | This test stamps on the XML parser settings on java6, so it is disabled. |
435 | 439 | --> |
436 | <target name="testXnew" if="rmic5.present" unless="rmic6.present" depends="init"> | |
437 | <base-rmic compiler="sun"> | |
440 | <target name="testXnew" if="rmic.present" unless="rmic6.present" depends="init"> | |
441 | <base-rmic compiler="${rmic.compiler}"> | |
438 | 442 | <compilerarg value="-Xnew"/> |
439 | 443 | </base-rmic> |
440 | 444 | <assertBaseCompiled/> |
441 | 445 | </target> |
442 | 446 | |
443 | <target name="testXnewDest" if="rmic5.present" unless="rmic6.present" depends="init"> | |
444 | <dest-rmic compiler="sun"> | |
447 | <target name="testXnewDest" if="rmic.present" unless="rmic6.present" depends="init"> | |
448 | <dest-rmic compiler="${rmic.compiler}"> | |
445 | 449 | <compilerarg value="-Xnew"/> |
446 | 450 | </dest-rmic> |
447 | 451 | <assertBaseCompiledInDest/> |
448 | 452 | </target> |
449 | 453 | |
450 | <target name="testXnewForked" if="rmic5.present" depends="init"> | |
454 | <target name="testXnewForked" if="rmic.present" depends="init"> | |
451 | 455 | <base-rmic compiler="forking"> |
452 | 456 | <compilerarg value="-Xnew"/> |
453 | 457 | </base-rmic> |
454 | 458 | <assertBaseCompiled/> |
455 | 459 | </target> |
456 | 460 | |
457 | <target name="testXnewForkedDest" if="rmic5.present" depends="init"> | |
461 | <target name="testXnewForkedDest" if="rmic.present" depends="init"> | |
458 | 462 | <dest-rmic compiler="forking"> |
459 | 463 | <compilerarg value="-Xnew"/> |
460 | 464 | </dest-rmic> |
461 | 465 | <assertBaseCompiledInDest/> |
462 | 466 | </target> |
463 | 467 | |
464 | <target name="testXnewCompiler" if="rmic5.present" depends="init"> | |
468 | <target name="testXnewCompiler" if="rmic.present" depends="init"> | |
465 | 469 | <base-rmic compiler="xnew"> |
466 | 470 | </base-rmic> |
467 | 471 | <assertBaseCompiled/> |
468 | 472 | </target> |
469 | 473 | |
470 | <target name="testXnewCompilerDest" if="rmic5.present" depends="init"> | |
474 | <target name="testXnewCompilerDest" if="rmic.present" depends="init"> | |
471 | 475 | <dest-rmic compiler="xnew"> |
472 | 476 | </dest-rmic> |
473 | 477 | <assertBaseCompiledInDest/> |
282 | 282 | <zip destFile="${output}/test3.zip" basedir="${output}/ziptest" update="true"/> |
283 | 283 | </target> |
284 | 284 | |
285 | <target name="testRegexpMapper1"> | |
286 | <mkdir dir="${output}/regexp.src"/> | |
287 | <touch file="${output}/regexp.src/file1"/> | |
288 | <zip destFile="${output}/regexp.zip"> | |
289 | <mappedresources> | |
290 | <fileset dir="${output}/regexp.src" includes="file1" /> | |
291 | <regexpmapper from="^(([a-z][a-z]).*)" to="\2/\1.r" /> | |
292 | </mappedresources> | |
293 | </zip> | |
294 | </target> | |
295 | <target name="testRegexpMapper2"> | |
296 | <sleep seconds="3" /> | |
297 | <zip destFile="${output}/regexp.zip"> | |
298 | <mappedresources> | |
299 | <fileset dir="${output}/regexp.src" includes="file1" /> | |
300 | <regexpmapper from="^(([a-z][a-z]).*)" to="\2/\1.r" /> | |
301 | </mappedresources> | |
302 | </zip> | |
303 | </target> | |
285 | 304 | |
286 | 305 | </project> |
48 | 48 | import org.apache.tools.ant.util.FileUtils; |
49 | 49 | import org.apache.tools.ant.util.JavaEnvUtils; |
50 | 50 | import org.apache.tools.ant.util.LoaderUtils; |
51 | import org.apache.tools.ant.util.StringUtils; | |
51 | 52 | import org.apache.tools.ant.util.VectorSet; |
52 | 53 | import org.apache.tools.zip.ZipLong; |
53 | 54 | |
400 | 401 | protected void log(final String message, final int priority) { |
401 | 402 | if (project != null) { |
402 | 403 | project.log(message, priority); |
404 | } else if (priority < Project.MSG_INFO) { | |
405 | System.err.println(message); | |
403 | 406 | } |
404 | 407 | } |
405 | 408 | |
1019 | 1022 | final String msg = "CLASSPATH element " + file |
1020 | 1023 | + " is not a JAR."; |
1021 | 1024 | log(msg, Project.MSG_WARN); |
1022 | System.err.println(msg); | |
1023 | 1025 | return null; |
1024 | 1026 | } |
1025 | 1027 | jarFile = new JarFile(file); |
1042 | 1044 | } catch (final Exception e) { |
1043 | 1045 | final String msg = "Unable to obtain resource from " + file + ": "; |
1044 | 1046 | log(msg + e, Project.MSG_WARN); |
1045 | System.err.println(msg); | |
1046 | e.printStackTrace(); | |
1047 | log(StringUtils.getStackTrace(e), Project.MSG_WARN); | |
1047 | 1048 | } |
1048 | 1049 | return null; |
1049 | 1050 | } |
1209 | 1210 | * |
1210 | 1211 | * @return the entry's certificates or null is the container is |
1211 | 1212 | * not a jar or it has no certificates. |
1212 | * | |
1213 | * @exception IOException if the manifest cannot be read. | |
1214 | */ | |
1215 | private Certificate[] getCertificates(final File container, final String entry) | |
1216 | throws IOException { | |
1213 | */ | |
1214 | private Certificate[] getCertificates(final File container, final String entry) { | |
1217 | 1215 | if (container.isDirectory()) { |
1218 | 1216 | return null; |
1219 | 1217 | } |
83 | 83 | } |
84 | 84 | |
85 | 85 | InputStream systemResource = ClassLoader.getSystemResourceAsStream(SERVICE_ID); |
86 | if (systemResource != null) { | |
86 | if (systemResource != null) { //NOSONAR | |
87 | 87 | ArgumentProcessor processor = getProcessorByService(systemResource); |
88 | 88 | registerArgumentProcessor(processor); |
89 | 89 | } |
92 | 92 | + SERVICE_ID + " (" + e.getClass().getName() + ": " |
93 | 93 | + e.getMessage() + ")"); |
94 | 94 | if (DEBUG) { |
95 | e.printStackTrace(System.err); | |
95 | e.printStackTrace(System.err); //NOSONAR | |
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
970 | 970 | Throwable t = ex.getTargetException(); |
971 | 971 | out.println("Cause: The constructor threw the exception"); |
972 | 972 | out.println(t.toString()); |
973 | t.printStackTrace(out); | |
973 | t.printStackTrace(out); //NOSONAR | |
974 | 974 | } catch (NoClassDefFoundError ncdfe) { |
975 | 975 | jars = true; |
976 | 976 | out.println("Cause: A class needed by class " + classname |
470 | 470 | // report error if something weird happens...this is diagnostic. |
471 | 471 | if (error != null) { |
472 | 472 | out.println("Error while running org.apache.env.Which"); |
473 | error.printStackTrace(); | |
473 | error.printStackTrace(out); //NOSONAR | |
474 | 474 | } |
475 | 475 | } |
476 | 476 |
145 | 145 | * method instead. |
146 | 146 | */ |
147 | 147 | @Deprecated |
148 | protected static final String[] DEFAULTEXCLUDES = { | |
148 | protected static final String[] DEFAULTEXCLUDES = { //NOSONAR | |
149 | 149 | // Miscellaneous typical temporary files |
150 | 150 | SelectorUtils.DEEP_TREE_MATCH + "/*~", |
151 | 151 | SelectorUtils.DEEP_TREE_MATCH + "/#*#", |
406 | 406 | + " doesn't support the \"" + attributeName + "\" attribute."; |
407 | 407 | throw new UnsupportedAttributeException(msg, attributeName); |
408 | 408 | } |
409 | try { | |
410 | as.setObject(p, element, value); | |
411 | } catch (final IllegalAccessException ie) { | |
412 | // impossible as getMethods should only return public methods | |
413 | throw new BuildException(ie); | |
414 | } catch (final InvocationTargetException ite) { | |
415 | throw extractBuildException(ite); | |
409 | if (as != null) { // possible if value == null | |
410 | try { | |
411 | as.setObject(p, element, value); | |
412 | } catch (final IllegalAccessException ie) { | |
413 | // impossible as getMethods should only return public methods | |
414 | throw new BuildException(ie); | |
415 | } catch (final InvocationTargetException ite) { | |
416 | throw extractBuildException(ite); | |
417 | } | |
416 | 418 | } |
417 | 419 | } |
418 | 420 |
80 | 80 | private File buildFile; /* null */ |
81 | 81 | |
82 | 82 | /** Stream to use for logging. */ |
83 | private static PrintStream out = System.out; | |
83 | private PrintStream out = System.out; | |
84 | 84 | |
85 | 85 | /** Stream that we are using for logging error messages. */ |
86 | private static PrintStream err = System.err; | |
86 | private PrintStream err = System.err; | |
87 | 87 | |
88 | 88 | /** The build targets. */ |
89 | 89 | private final Vector<String> targets = new Vector<String>(); |
142 | 142 | * Whether or not a logfile is being used. This is used to |
143 | 143 | * check if the output streams must be closed. |
144 | 144 | */ |
145 | private static boolean isLogFileUsed = false; | |
145 | private boolean isLogFileUsed = false; | |
146 | 146 | |
147 | 147 | /** |
148 | 148 | * optional thread priority |
245 | 245 | printMessage(be); |
246 | 246 | } |
247 | 247 | } catch (final Throwable exc) { |
248 | exc.printStackTrace(); | |
248 | exc.printStackTrace(); //NOSONAR | |
249 | 249 | printMessage(exc); |
250 | 250 | } finally { |
251 | 251 | handleLogfile(); |
268 | 268 | * |
269 | 269 | * @since Ant 1.6 |
270 | 270 | */ |
271 | private static void handleLogfile() { | |
271 | private void handleLogfile() { | |
272 | 272 | if (isLogFileUsed) { |
273 | 273 | FileUtils.close(out); |
274 | 274 | FileUtils.close(err); |
354 | 354 | try { |
355 | 355 | final File logFile = new File(args[i + 1]); |
356 | 356 | i++; |
357 | logTo = new PrintStream(new FileOutputStream(logFile)); | |
357 | // life-cycle of FileOutputStream is controlled by | |
358 | // logTo which becomes "out" and is closed in | |
359 | // handleLogfile | |
360 | logTo = new PrintStream(new FileOutputStream(logFile)); //NOSONAR | |
358 | 361 | isLogFileUsed = true; |
359 | 362 | } catch (final IOException ioe) { |
360 | 363 | final String msg = "Cannot write on the specified log file. " |
877 | 880 | // but if we don't, we lose valuable information |
878 | 881 | System.err.println("Caught an exception while logging the" |
879 | 882 | + " end of the build. Exception was:"); |
880 | t.printStackTrace(); | |
883 | t.printStackTrace(); //NOSONAR | |
881 | 884 | if (error != null) { |
882 | 885 | System.err.println("There has been an error prior to" |
883 | 886 | + " that:"); |
884 | error.printStackTrace(); | |
887 | error.printStackTrace(); //NOSONAR | |
885 | 888 | } |
886 | throw new BuildException(t); | |
889 | throw new BuildException(t); //NOSONAR | |
887 | 890 | } |
888 | 891 | } else if (error != null) { |
889 | 892 | project.log(error.toString(), Project.MSG_ERR); |
974 | 977 | project.setInputHandler(handler); |
975 | 978 | } |
976 | 979 | |
977 | // TODO: (Jon Skeet) Any reason for writing a message and then using a bare | |
978 | // RuntimeException rather than just using a BuildException here? Is it | |
979 | // in case the message could end up being written to no loggers (as the | |
980 | // loggers could have failed to be created due to this failure)? | |
981 | 980 | /** |
982 | 981 | * Creates the default build logger for sending build events to the ant |
983 | 982 | * log. |
999 | 998 | System.err.println("The specified logger class " |
1000 | 999 | + loggerClassname |
1001 | 1000 | + " could not be used because " + e.getMessage()); |
1002 | throw new RuntimeException(); | |
1001 | throw e; | |
1003 | 1002 | } |
1004 | 1003 | } else { |
1005 | 1004 | logger = new DefaultLogger(); |
872 | 872 | try { |
873 | 873 | setBasedir("."); |
874 | 874 | } catch (final BuildException ex) { |
875 | ex.printStackTrace(); | |
875 | ex.printStackTrace(); //NOSONAR | |
876 | 876 | } |
877 | 877 | } |
878 | 878 | return baseDir; |
1429 | 1429 | "Target '" + curtarget.getName() |
1430 | 1430 | + "' failed with message '" |
1431 | 1431 | + thrownException.getMessage() + "'.", MSG_ERR); |
1432 | thrownException.printStackTrace(System.err); | |
1432 | thrownException.printStackTrace(System.err); //NOSONAR | |
1433 | 1433 | if (buildException == null) { |
1434 | 1434 | buildException = |
1435 | 1435 | new BuildException(thrownException); |
1835 | 1835 | if (st == null) { |
1836 | 1836 | tsort(root[i], targetTable, state, visiting, ret); |
1837 | 1837 | } else if (st == VISITING) { |
1838 | throw new RuntimeException("Unexpected node in visiting state: " | |
1838 | throw new BuildException("Unexpected node in visiting state: " | |
1839 | 1839 | + root[i]); |
1840 | 1840 | } |
1841 | 1841 | } |
1854 | 1854 | if (st == null) { |
1855 | 1855 | tsort(curTarget, targetTable, state, visiting, complete); |
1856 | 1856 | } else if (st == VISITING) { |
1857 | throw new RuntimeException("Unexpected node in visiting state: " | |
1857 | throw new BuildException("Unexpected node in visiting state: " | |
1858 | 1858 | + curTarget); |
1859 | 1859 | } |
1860 | 1860 | } |
1940 | 1940 | } |
1941 | 1941 | final String p = visiting.pop(); |
1942 | 1942 | if (root != p) { |
1943 | throw new RuntimeException("Unexpected internal error: expected to " | |
1943 | throw new BuildException("Unexpected internal error: expected to " | |
1944 | 1944 | + "pop " + root + " but got " + p); |
1945 | 1945 | } |
1946 | 1946 | state.put(root, VISITED); |
61 | 61 | PROJECTHELPER2_CONSTRUCTOR = ProjectHelper2.class.getConstructor(); |
62 | 62 | } catch (Exception e) { |
63 | 63 | // ProjectHelper2 must be available |
64 | throw new RuntimeException(e); | |
64 | throw new BuildException(e); | |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
107 | 107 | + e.getClass().getName() |
108 | 108 | + ": " + e.getMessage() + ")"); |
109 | 109 | if (DEBUG) { |
110 | e.printStackTrace(System.err); | |
110 | e.printStackTrace(System.err); //NOSONAR | |
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
174 | 174 | + ProjectHelper.HELPER_PROPERTY + " (" |
175 | 175 | + e.getMessage() + ")"); |
176 | 176 | if (DEBUG) { |
177 | e.printStackTrace(System.err); | |
177 | e.printStackTrace(System.err); //NOSONAR | |
178 | 178 | } |
179 | 179 | } |
180 | 180 | return null; |
202 | 202 | System.out.println("Unable to load ProjectHelper from service " |
203 | 203 | + ProjectHelper.SERVICE_ID + " (" + e.getMessage() + ")"); |
204 | 204 | if (DEBUG) { |
205 | e.printStackTrace(System.err); | |
205 | e.printStackTrace(System.err); //NOSONAR | |
206 | 206 | } |
207 | 207 | } |
208 | 208 | return null; |
262 | 262 | return helper; |
263 | 263 | } |
264 | 264 | } |
265 | throw new RuntimeException("BUG: at least the ProjectHelper2 should " | |
265 | throw new BuildException("BUG: at least the ProjectHelper2 should " | |
266 | 266 | + "have supported the file " + buildFile); |
267 | 267 | } |
268 | 268 | |
285 | 285 | return helper; |
286 | 286 | } |
287 | 287 | } |
288 | throw new RuntimeException("BUG: at least the ProjectHelper2 should " | |
288 | throw new BuildException("BUG: at least the ProjectHelper2 should " | |
289 | 289 | + "have supported the file " + antlib); |
290 | 290 | } |
291 | 291 |
51 | 51 | private String elementTag = null; |
52 | 52 | |
53 | 53 | /** List of child element wrappers. */ |
54 | private List<RuntimeConfigurable> children = null; | |
54 | // picking ArrayList rather than List as arrayList is Serializable | |
55 | private ArrayList<RuntimeConfigurable> children = null; | |
55 | 56 | |
56 | 57 | /** The element to configure. It is only used during |
57 | 58 | * maybeConfigure. |
588 | 589 | |
589 | 590 | // Children (this is a shadow of UnknownElement#children) |
590 | 591 | if (r.children != null) { |
591 | List<RuntimeConfigurable> newChildren = new ArrayList<RuntimeConfigurable>(); | |
592 | ArrayList<RuntimeConfigurable> newChildren = new ArrayList<RuntimeConfigurable>(); | |
592 | 593 | newChildren.addAll(r.children); |
593 | 594 | if (children != null) { |
594 | 595 | newChildren.addAll(children); |
645 | 645 | return false; |
646 | 646 | } |
647 | 647 | for (int i = 0; i < childrenSize; ++i) { |
648 | UnknownElement child = (UnknownElement) children.get(i); | |
648 | // children cannot be null childrenSize would have been 0 | |
649 | UnknownElement child = (UnknownElement) children.get(i); //NOSONAR | |
649 | 650 | if (!child.similar(other.children.get(i))) { |
650 | 651 | return false; |
651 | 652 | } |
263 | 263 | if (!threadStack.empty()) { |
264 | 264 | TimedElement poppedStack = threadStack.pop(); |
265 | 265 | if (poppedStack != targetElement) { |
266 | throw new RuntimeException("Mismatch - popped element = " + poppedStack | |
266 | throw new RuntimeException("Mismatch - popped element = " + poppedStack //NOSONAR | |
267 | 267 | + " finished target element = " + targetElement); |
268 | 268 | } |
269 | 269 | if (!threadStack.empty()) { |
315 | 315 | Task task = event.getTask(); |
316 | 316 | TimedElement taskElement = tasks.get(task); |
317 | 317 | if (taskElement == null) { |
318 | throw new RuntimeException("Unknown task " + task + " not in " + tasks); | |
318 | throw new RuntimeException("Unknown task " + task + " not in " + tasks); //NOSONAR | |
319 | 319 | } |
320 | 320 | long totalTime = System.currentTimeMillis() - taskElement.startTime; |
321 | 321 | taskElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime)); |
333 | 333 | if (!threadStack.empty()) { |
334 | 334 | TimedElement poppedStack = threadStack.pop(); |
335 | 335 | if (poppedStack != taskElement) { |
336 | throw new RuntimeException("Mismatch - popped element = " + poppedStack | |
336 | throw new RuntimeException("Mismatch - popped element = " + poppedStack //NOSONAR | |
337 | 337 | + " finished task element = " + taskElement); |
338 | 338 | } |
339 | 339 | } |
139 | 139 | classname="org.apache.tools.ant.filters.SortFilter"/> |
140 | 140 | <componentdef name="uniqfilter" onerror="ignore" |
141 | 141 | classname="org.apache.tools.ant.filters.UniqFilter"/> |
142 | <componentdef name="native2asciifilter" onerror="ignore" | |
143 | classname="org.apache.tools.ant.filters.Native2AsciiFilter"/> | |
142 | 144 | </antlib> |
143 | 145 |
0 | /* | |
1 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
2 | * contributor license agreements. See the NOTICE file distributed with | |
3 | * this work for additional information regarding copyright ownership. | |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | * (the "License"); you may not use this file except in compliance with | |
6 | * the License. You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | */ | |
17 | package org.apache.tools.ant.filters; | |
18 | ||
19 | import org.apache.tools.ant.util.Native2AsciiUtils; | |
20 | ||
21 | /** | |
22 | * A filter that performs translations from characters to their | |
23 | * Unicode-escape sequences and vice-versa. | |
24 | * | |
25 | * @since Ant 1.9.8 | |
26 | */ | |
27 | public class Native2AsciiFilter extends TokenFilter.ChainableReaderFilter { | |
28 | private boolean reverse; | |
29 | ||
30 | /** | |
31 | * Flag the conversion to run in the reverse sense, | |
32 | * that is Ascii to Native encoding. | |
33 | * | |
34 | * @param reverse True if the conversion is to be reversed, | |
35 | * otherwise false; | |
36 | */ | |
37 | public void setReverse(boolean reverse) { | |
38 | this.reverse = reverse; | |
39 | } | |
40 | ||
41 | public String filter(String line) { | |
42 | return reverse | |
43 | ? Native2AsciiUtils.ascii2native(line) | |
44 | : Native2AsciiUtils.native2ascii(line); | |
45 | } | |
46 | } |
26 | 26 | import java.util.SortedMap; |
27 | 27 | import java.util.TreeMap; |
28 | 28 | |
29 | import org.apache.tools.ant.Project; | |
29 | 30 | import org.apache.tools.ant.types.Parameter; |
30 | 31 | import org.apache.tools.ant.types.Resource; |
31 | 32 | import org.apache.tools.ant.types.resources.FileResource; |
243 | 244 | in = resource.getInputStream(); |
244 | 245 | props.load(in); |
245 | 246 | } catch (IOException ioe) { |
246 | ioe.printStackTrace(); | |
247 | if (getProject() != null) { | |
248 | getProject().log("getProperties failed, " + ioe.getMessage(), Project.MSG_ERR); | |
249 | } else { | |
250 | ioe.printStackTrace(); //NOSONAR | |
251 | } | |
247 | 252 | } finally { |
248 | 253 | FileUtils.close(in); |
249 | 254 | } |
361 | 361 | if (reverse) { |
362 | 362 | Collections.sort(lines, new Comparator<String>() { |
363 | 363 | public int compare(String s1, String s2) { |
364 | return (-s1.compareTo(s2)); | |
364 | return (-s1.compareTo(s2)); //NOSONAR | |
365 | 365 | } |
366 | 366 | }); |
367 | 367 | } else { |
30 | 30 | private String lastLine = null; |
31 | 31 | |
32 | 32 | public String filter(String string) { |
33 | return lastLine == null || !lastLine.equals(string) | |
34 | ? (lastLine = string) : null; | |
33 | if (lastLine == null || !lastLine.equals(string)) { | |
34 | lastLine = string; | |
35 | return lastLine; | |
36 | } | |
37 | return null; | |
35 | 38 | } |
36 | 39 | } |
599 | 599 | private static void handleElement(ProjectHelperImpl helperImpl, DocumentHandler parent, |
600 | 600 | Target target, String elementName, AttributeList attrs) throws SAXParseException { |
601 | 601 | if (elementName.equals("description")) { |
602 | new DescriptionHandler(helperImpl, parent); | |
602 | // created for side effect | |
603 | new DescriptionHandler(helperImpl, parent); //NOSONAR | |
603 | 604 | } else if (helperImpl.project.getDataTypeDefinitions().get(elementName) != null) { |
604 | 605 | new DataTypeHandler(helperImpl, parent, target).init(elementName, attrs); |
605 | 606 | } else { |
47 | 47 | public void handleInput(InputRequest request) throws BuildException { |
48 | 48 | String prompt = getPrompt(request); |
49 | 49 | BufferedReader r = null; |
50 | boolean success = false; | |
50 | 51 | try { |
51 | 52 | r = new BufferedReader(new InputStreamReader(getInputStream())); |
52 | 53 | do { |
60 | 61 | + " Console.", e); |
61 | 62 | } |
62 | 63 | } while (!request.isInputValid()); |
64 | success = true; | |
63 | 65 | } finally { |
64 | 66 | if (r != null) { |
65 | 67 | try { |
66 | 68 | r.close(); |
67 | 69 | } catch (IOException e) { |
68 | throw new BuildException("Failed to close input.", e); | |
70 | if (success) { // don't hide inner exception | |
71 | throw new BuildException("Failed to close input.", e); //NOSONAR | |
72 | } | |
69 | 73 | } |
70 | 74 | } |
71 | 75 | } |
64 | 64 | /** |
65 | 65 | * launch diagnostics flag; for debugging trouble at launch time. |
66 | 66 | */ |
67 | public static boolean launchDiag = false; | |
67 | public boolean launchDiag = false; | |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * The location of a per-user library directory. |
106 | 106 | */ |
107 | 107 | public static void main(final String[] args) { |
108 | 108 | int exitCode; |
109 | boolean launchDiag = false; | |
109 | 110 | try { |
110 | 111 | final Launcher launcher = new Launcher(); |
111 | 112 | exitCode = launcher.run(args); |
113 | launchDiag = launcher.launchDiag; | |
112 | 114 | } catch (final LaunchException e) { |
113 | 115 | exitCode = EXIT_CODE_ERROR; |
114 | 116 | System.err.println(e.getMessage()); |
115 | 117 | } catch (final Throwable t) { |
116 | 118 | exitCode = EXIT_CODE_ERROR; |
117 | t.printStackTrace(System.err); | |
119 | t.printStackTrace(System.err); //NOSONAR | |
118 | 120 | } |
119 | 121 | if (exitCode != 0) { |
120 | 122 | if (launchDiag) { |
294 | 296 | "Failed to locate" + mainClassname); |
295 | 297 | thrown = cnfe; |
296 | 298 | } catch (final Throwable t) { |
297 | t.printStackTrace(System.err); | |
299 | t.printStackTrace(System.err); //NOSONAR | |
298 | 300 | thrown=t; |
299 | 301 | } |
300 | 302 | if(thrown!=null) { |
176 | 176 | } |
177 | 177 | } catch (Exception e) { |
178 | 178 | System.out.println("MailLogger failed to send e-mail!"); |
179 | e.printStackTrace(System.err); | |
179 | e.printStackTrace(System.err); //NOSONAR | |
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
326 | 326 | * property is not present in properties. |
327 | 327 | */ |
328 | 328 | private String getValue(Hashtable<String, Object> properties, String name, |
329 | String defaultValue) throws Exception { | |
329 | String defaultValue) { | |
330 | 330 | String propertyName = "MailLogger." + name; |
331 | 331 | String value = (String) properties.get(propertyName); |
332 | 332 | |
335 | 335 | } |
336 | 336 | |
337 | 337 | if (value == null) { |
338 | throw new Exception("Missing required parameter: " + propertyName); | |
338 | throw new RuntimeException("Missing required parameter: " + propertyName); //NOSONAR | |
339 | 339 | } |
340 | 340 | |
341 | 341 | return value; |
381 | 381 | FileSet sourceJar = new FileSet(); |
382 | 382 | sourceJar.setProject(getProject()); |
383 | 383 | sourceJar.setFile(jar); |
384 | sourceJar.setDir(jar.getParentFile()); | |
385 | 384 | sources.add(sourceJar); |
386 | 385 | } |
387 | 386 | return sources; |
35 | 35 | import org.apache.tools.ant.TaskContainer; |
36 | 36 | import org.apache.tools.ant.types.EnumeratedAttribute; |
37 | 37 | import org.apache.tools.ant.types.Reference; |
38 | import org.apache.tools.ant.util.FileUtils; | |
38 | 39 | |
39 | 40 | /** |
40 | 41 | * Creates a partial DTD for Ant from the currently known tasks. |
83 | 84 | |
84 | 85 | PrintWriter out = null; |
85 | 86 | try { |
87 | FileOutputStream fos = null; | |
86 | 88 | try { |
87 | out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output), "UTF8")); | |
89 | fos = new FileOutputStream(output); | |
90 | out = new PrintWriter(new OutputStreamWriter(fos, "UTF8")); | |
88 | 91 | } catch (final UnsupportedEncodingException ue) { |
92 | FileUtils.close(fos); | |
89 | 93 | /* |
90 | 94 | * Plain impossible with UTF8, see |
91 | 95 | * http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html |
385 | 389 | } catch (final IllegalAccessException ie) { |
386 | 390 | sb.append("CDATA "); |
387 | 391 | } |
388 | } else if (type.getSuperclass() != null | |
389 | && type.getSuperclass().getName().equals("java.lang.Enum")) { | |
392 | } else if (Enum.class.isAssignableFrom(type)) { | |
390 | 393 | try { |
391 | 394 | final Object[] values = (Object[]) type.getMethod("values", (Class[]) null) |
392 | 395 | .invoke(null, (Object[]) null); |
18 | 18 | package org.apache.tools.ant.taskdefs; |
19 | 19 | |
20 | 20 | import java.io.File; |
21 | import java.io.InputStream; | |
21 | 22 | |
22 | 23 | import org.apache.tools.ant.AntClassLoader; |
23 | 24 | import org.apache.tools.ant.BuildException; |
420 | 421 | * Check if a given resource can be loaded. |
421 | 422 | */ |
422 | 423 | private boolean checkResource(String resource) { |
423 | if (loader != null) { | |
424 | return (loader.getResourceAsStream(resource) != null); | |
425 | } else { | |
426 | ClassLoader cL = this.getClass().getClassLoader(); | |
427 | if (cL != null) { | |
428 | return (cL.getResourceAsStream(resource) != null); | |
424 | InputStream is = null; | |
425 | try { | |
426 | if (loader != null) { | |
427 | is = loader.getResourceAsStream(resource); | |
429 | 428 | } else { |
430 | return | |
431 | (ClassLoader.getSystemResourceAsStream(resource) != null); | |
432 | } | |
429 | ClassLoader cL = this.getClass().getClassLoader(); | |
430 | if (cL != null) { | |
431 | is = cL.getResourceAsStream(resource); | |
432 | } else { | |
433 | is = ClassLoader.getSystemResourceAsStream(resource); | |
434 | } | |
435 | } | |
436 | return is != null; | |
437 | } finally { | |
438 | FileUtils.close(is); | |
433 | 439 | } |
434 | 440 | } |
435 | 441 |
26 | 26 | import org.apache.tools.ant.Task; |
27 | 27 | import org.apache.tools.ant.types.Path; |
28 | 28 | import org.apache.tools.ant.types.Reference; |
29 | import org.apache.tools.ant.util.StringUtils; | |
29 | 30 | |
30 | 31 | /** |
31 | 32 | * EXPERIMENTAL |
237 | 238 | // TODO add exceptions |
238 | 239 | |
239 | 240 | } catch (Exception ex) { |
240 | ex.printStackTrace(); | |
241 | log(StringUtils.getStackTrace(ex), Project.MSG_ERR); | |
241 | 242 | } |
242 | 243 | } |
243 | 244 | } |
382 | 382 | private ConcatResource(ResourceCollection c) { |
383 | 383 | this.c = c; |
384 | 384 | } |
385 | public InputStream getInputStream() throws IOException { | |
385 | public InputStream getInputStream() { | |
386 | 386 | if (binary) { |
387 | 387 | ConcatResourceInputStream result = new ConcatResourceInputStream(c); |
388 | 388 | result.setManagingComponent(this); |
112 | 112 | procEnvironment = System.getenv(); |
113 | 113 | return procEnvironment; |
114 | 114 | } catch (Exception x) { |
115 | x.printStackTrace(); | |
115 | x.printStackTrace(); //NOSONAR | |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
161 | 161 | procEnvironment.put(var.substring(0, eq), var.substring(eq + 1)); |
162 | 162 | } |
163 | 163 | } catch (java.io.IOException exc) { |
164 | exc.printStackTrace(); | |
164 | exc.printStackTrace(); //NOSONAR | |
165 | 165 | // Just try to see how much we got |
166 | 166 | } |
167 | 167 | return procEnvironment; |
52 | 52 | private Long timeout = null; |
53 | 53 | private volatile Throwable caught = null; |
54 | 54 | private volatile boolean timedOut = false; |
55 | private boolean done = false; | |
55 | 56 | private Thread thread = null; |
56 | 57 | |
57 | 58 | /** |
149 | 150 | + " is not declared static"); |
150 | 151 | } |
151 | 152 | if (timeout == null) { |
152 | run(); | |
153 | run(); //NOSONAR | |
153 | 154 | } else { |
154 | 155 | thread = new Thread(this, "ExecuteJava"); |
155 | 156 | Task currentThreadTask |
167 | 168 | thread.start(); |
168 | 169 | w.start(); |
169 | 170 | try { |
170 | wait(); | |
171 | while (!done) { | |
172 | wait(); | |
173 | } | |
171 | 174 | } catch (InterruptedException e) { |
172 | 175 | // ignore |
173 | 176 | } |
227 | 230 | perm.restoreSecurityManager(); |
228 | 231 | } |
229 | 232 | synchronized (this) { |
233 | done = true; | |
230 | 234 | notifyAll(); |
231 | 235 | } |
232 | 236 | } |
242 | 246 | timedOut = true; |
243 | 247 | thread.interrupt(); |
244 | 248 | } |
249 | done = true; | |
245 | 250 | notifyAll(); |
246 | 251 | } |
247 | 252 |
190 | 190 | log("extracting " + ze.getName(), Project.MSG_DEBUG); |
191 | 191 | try { |
192 | 192 | extractFile(fileUtils, srcF, dir, |
193 | is = zf.getInputStream(ze), | |
193 | is = zf.getInputStream(ze), //NOSONAR | |
194 | 194 | ze.getName(), new Date(ze.getTime()), |
195 | 195 | ze.isDirectory(), mapper); |
196 | 196 | } finally { |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | //set up logging | |
138 | final int logLevel = Project.MSG_INFO; | |
139 | DownloadProgress progress = null; | |
140 | if (verbose) { | |
141 | progress = new VerboseProgress(System.out); | |
142 | } | |
143 | ||
144 | //execute the get | |
145 | try { | |
146 | doGet(source, dest, logLevel, progress); | |
147 | } catch (final IOException ioe) { | |
148 | log("Error getting " + source + " to " + dest); | |
149 | if (!ignoreErrors) { | |
150 | throw new BuildException(ioe, getLocation()); | |
151 | } | |
152 | } | |
137 | //set up logging | |
138 | final int logLevel = Project.MSG_INFO; | |
139 | DownloadProgress progress = null; | |
140 | if (verbose) { | |
141 | progress = new VerboseProgress(System.out); | |
142 | } | |
143 | ||
144 | //execute the get | |
145 | try { | |
146 | doGet(source, dest, logLevel, progress); | |
147 | } catch (final IOException ioe) { | |
148 | log("Error getting " + source + " to " + dest); | |
149 | if (!ignoreErrors) { | |
150 | throw new BuildException(ioe, getLocation()); | |
151 | } | |
152 | } | |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
258 | 258 | |
259 | 259 | @Override |
260 | 260 | public void log(final String msg, final int msgLevel) { |
261 | if (!quiet || msgLevel >= Project.MSG_ERR) { | |
261 | if (!quiet || msgLevel <= Project.MSG_ERR) { | |
262 | 262 | super.log(msg, msgLevel); |
263 | 263 | } |
264 | 264 | } |
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
415 | * The number of retries to attempt upon error, defaults to 3. | |
416 | * | |
417 | * @param r retry count | |
415 | * The number of attempts to make for opening the URI, defaults to 3. | |
416 | * | |
417 | * <p>The name of the method is misleading as a value of 1 means | |
418 | * "don't retry on error" and a value of 0 meant don't even try to | |
419 | * reach the URI at all.</p> | |
420 | * | |
421 | * @param r number of attempts to make | |
418 | 422 | * |
419 | 423 | * @since Ant 1.8.0 |
420 | 424 | */ |
421 | 425 | public void setRetries(final int r) { |
426 | if (r <= 0) { | |
427 | log("Setting retries to " + r | |
428 | + " will make the task not even try to reach the URI at all", | |
429 | Project.MSG_WARN); | |
430 | } | |
422 | 431 | this.numberRetries = r; |
423 | 432 | } |
424 | 433 |
42 | 42 | public class HostInfo extends Task { |
43 | 43 | private static final String DEF_REM_ADDR6 = "::"; |
44 | 44 | |
45 | private static final String DEF_REM_ADDR4 = "0.0.0.0"; | |
45 | private static final String DEF_REM_ADDR4 = "0.0.0.0"; //NOSONAR | |
46 | 46 | |
47 | 47 | private static final String DEF_LOCAL_ADDR6 = "::1"; |
48 | 48 | |
49 | private static final String DEF_LOCAL_ADDR4 = "127.0.0.1"; | |
49 | private static final String DEF_LOCAL_ADDR4 = "127.0.0.1"; //NOSONAR | |
50 | 50 | |
51 | 51 | private static final String DEF_LOCAL_NAME = "localhost"; |
52 | 52 | private static final String DEF_DOMAIN = "localdomain"; |
412 | 412 | */ |
413 | 413 | public void setFilesetmanifest(FilesetManifestConfig config) { |
414 | 414 | filesetManifestConfig = config; |
415 | mergeManifestsMain = "merge".equals(config.getValue()); | |
415 | mergeManifestsMain = config != null && "merge".equals(config.getValue()); | |
416 | 416 | |
417 | 417 | if (filesetManifestConfig != null |
418 | 418 | && !filesetManifestConfig.getValue().equals("skip")) { |
1035 | 1035 | * @since Ant 1.6.2 |
1036 | 1036 | */ |
1037 | 1037 | protected final void writeIndexLikeList(List<String> dirs, List<String> files, |
1038 | PrintWriter writer) | |
1039 | throws IOException { | |
1038 | PrintWriter writer) { | |
1040 | 1039 | // JarIndex is sorting the directories by ascending order. |
1041 | 1040 | // it has no value but cosmetic since it will be read into a |
1042 | 1041 | // hashtable by the classloader, but we'll do so anyway. |
39 | 39 | import org.apache.tools.ant.types.RedirectorElement; |
40 | 40 | import org.apache.tools.ant.types.Reference; |
41 | 41 | import org.apache.tools.ant.util.KeepAliveInputStream; |
42 | import org.apache.tools.ant.util.StringUtils; | |
42 | 43 | |
43 | 44 | /** |
44 | 45 | * Launcher for Java applications. Allows use of |
996 | 997 | * @since 1.6.2 |
997 | 998 | */ |
998 | 999 | private void log(Throwable t) { |
999 | StringWriter sw = new StringWriter(); | |
1000 | PrintWriter w = new PrintWriter(sw); | |
1001 | t.printStackTrace(w); | |
1002 | w.close(); | |
1003 | log(sw.toString(), Project.MSG_ERR); | |
1000 | log(StringUtils.getStackTrace(t), Project.MSG_ERR); | |
1004 | 1001 | } |
1005 | 1002 | |
1006 | 1003 | /** |
66 | 66 | * <li>includejavaruntime |
67 | 67 | * <li>source |
68 | 68 | * <li>compiler |
69 | * <li>release | |
69 | 70 | * </ul> |
70 | 71 | * Of these arguments, the <b>sourcedir</b> and <b>destdir</b> are required. |
71 | 72 | * <p> |
84 | 85 | private static final String FAIL_MSG |
85 | 86 | = "Compile failed; see the compiler error output for details."; |
86 | 87 | |
88 | private static final String JAVAC9 = "javac9"; | |
87 | 89 | private static final String JAVAC19 = "javac1.9"; |
88 | 90 | private static final String JAVAC18 = "javac1.8"; |
89 | 91 | private static final String JAVAC17 = "javac1.7"; |
106 | 108 | |
107 | 109 | private Path src; |
108 | 110 | private File destDir; |
111 | private File nativeHeaderDir; | |
109 | 112 | private Path compileClasspath; |
110 | 113 | private Path modulepath; |
111 | 114 | private Path upgrademodulepath; |
118 | 121 | private boolean depend = false; |
119 | 122 | private boolean verbose = false; |
120 | 123 | private String targetAttribute; |
124 | private String release; | |
121 | 125 | private Path bootclasspath; |
122 | 126 | private Path extdirs; |
123 | 127 | private Boolean includeAntRuntime; |
165 | 169 | return JAVAC17; |
166 | 170 | } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) { |
167 | 171 | return JAVAC18; |
168 | } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_9)) { | |
169 | return JAVAC19; | |
172 | } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_9)) { | |
173 | return JAVAC9; | |
170 | 174 | } else { |
171 | 175 | return CLASSIC; |
172 | 176 | } |
284 | 288 | } |
285 | 289 | |
286 | 290 | /** |
291 | * Set the destination directory into which the generated native | |
292 | * header files should be placed. | |
293 | * @param nhDir where to place generated native header files | |
294 | * @since Ant 1.9.8 | |
295 | */ | |
296 | public void setNativeHeaderDir(final File nhDir) { | |
297 | this.nativeHeaderDir = nhDir; | |
298 | } | |
299 | ||
300 | /** | |
301 | * Gets the destination directory into which the generated native | |
302 | * header files should be placed. | |
303 | * @return where to place generated native header files | |
304 | * @since Ant 1.9.8 | |
305 | */ | |
306 | public File getNativeHeaderDir() { | |
307 | return nativeHeaderDir; | |
308 | } | |
309 | ||
310 | /** | |
287 | 311 | * Set the sourcepath to be used for this compilation. |
288 | 312 | * @param sourcepath the source path |
289 | 313 | */ |
762 | 786 | return targetAttribute != null |
763 | 787 | ? targetAttribute |
764 | 788 | : getProject().getProperty(MagicNames.BUILD_JAVAC_TARGET); |
789 | } | |
790 | ||
791 | /** | |
792 | * Sets the version to use for the {@code --release} switch that | |
793 | * combines {@code source}, {@code target} and setting the | |
794 | * bootclasspath. | |
795 | * | |
796 | * Values depend on the compiler, for jdk 9 the valid values are | |
797 | * "6", "7", "8", "9". | |
798 | * @param release the value of the release attribute | |
799 | * @since Ant 1.9.8 | |
800 | */ | |
801 | public void setRelease(final String release) { | |
802 | this.release = release; | |
803 | } | |
804 | ||
805 | /** | |
806 | * Gets the version to use for the {@code --release} switch that | |
807 | * combines {@code source}, {@code target} and setting the | |
808 | * bootclasspath. | |
809 | * | |
810 | * @return the value of the release attribute | |
811 | * @since Ant 1.9.8 | |
812 | */ | |
813 | public String getRelease() { | |
814 | return release; | |
765 | 815 | } |
766 | 816 | |
767 | 817 | /** |
911 | 961 | } |
912 | 962 | |
913 | 963 | private String getAltCompilerName(final String anImplementation) { |
914 | if (JAVAC19.equalsIgnoreCase(anImplementation) | |
964 | if (JAVAC9.equalsIgnoreCase(anImplementation) | |
965 | || JAVAC19.equalsIgnoreCase(anImplementation) | |
915 | 966 | || JAVAC18.equalsIgnoreCase(anImplementation) |
916 | 967 | || JAVAC17.equalsIgnoreCase(anImplementation) |
917 | 968 | || JAVAC16.equalsIgnoreCase(anImplementation) |
926 | 977 | } |
927 | 978 | if (MODERN.equalsIgnoreCase(anImplementation)) { |
928 | 979 | final String nextSelected = assumedJavaVersion(); |
929 | if (JAVAC19.equalsIgnoreCase(nextSelected) | |
980 | if (JAVAC9.equalsIgnoreCase(nextSelected) | |
930 | 981 | || JAVAC18.equalsIgnoreCase(nextSelected) |
931 | 982 | || JAVAC17.equalsIgnoreCase(nextSelected) |
932 | 983 | || JAVAC16.equalsIgnoreCase(nextSelected) |
1193 | 1244 | * @param compilerImpl the name of the compiler implementation |
1194 | 1245 | * @return true if compilerImpl is "modern", "classic", |
1195 | 1246 | * "javac1.1", "javac1.2", "javac1.3", "javac1.4", "javac1.5", |
1196 | * "javac1.6", "javac1.7", "javac1.8" or "javac1.9". | |
1247 | * "javac1.6", "javac1.7", "javac1.8", "javac1.9" or "javac9". | |
1197 | 1248 | */ |
1198 | 1249 | protected boolean isJdkCompiler(final String compilerImpl) { |
1199 | 1250 | return MODERN.equals(compilerImpl) |
1200 | 1251 | || CLASSIC.equals(compilerImpl) |
1201 | || JAVAC19.equals(compilerImpl) | |
1252 | || JAVAC9.equals(compilerImpl) | |
1202 | 1253 | || JAVAC18.equals(compilerImpl) |
1203 | 1254 | || JAVAC17.equals(compilerImpl) |
1204 | 1255 | || JAVAC16.equals(compilerImpl) |
1312 | 1312 | * cannot be static in inner classes.) The first letter |
1313 | 1313 | * from each element is used to build up the scope string. |
1314 | 1314 | */ |
1315 | static final String[] SCOPE_ELEMENTS = { | |
1315 | static final String[] SCOPE_ELEMENTS = { //NOSONAR | |
1316 | 1316 | "overview", "packages", "types", "constructors", |
1317 | 1317 | "methods", "fields" |
1318 | 1318 | }; |
1771 | 1771 | useExternalFile, tmpList, srcListWriter); |
1772 | 1772 | |
1773 | 1773 | if (useExternalFile) { |
1774 | srcListWriter.flush(); | |
1774 | srcListWriter.flush(); //NOSONAR | |
1775 | 1775 | } |
1776 | 1776 | } catch (final IOException e) { |
1777 | tmpList.delete(); | |
1777 | if (tmpList != null) { | |
1778 | tmpList.delete(); | |
1779 | } | |
1778 | 1780 | throw new BuildException("Error creating temporary file", |
1779 | 1781 | e, getLocation()); |
1780 | 1782 | } finally { |
2023 | 2025 | // is the href a valid URL |
2024 | 2026 | try { |
2025 | 2027 | final URL base = new URL("file://."); |
2026 | new URL(base, la.getHref()); | |
2028 | // created for the side effect of throwing a MalformedURLException | |
2029 | new URL(base, la.getHref()); //NOSONAR | |
2027 | 2030 | link = la.getHref(); |
2028 | 2031 | } catch (final MalformedURLException mue) { |
2029 | 2032 | // ok - just skip |
27 | 27 | import java.util.StringTokenizer; |
28 | 28 | |
29 | 29 | import org.apache.tools.ant.BuildException; |
30 | import org.apache.tools.ant.Project; | |
30 | 31 | import org.apache.tools.ant.Task; |
31 | 32 | import org.apache.tools.ant.util.FileUtils; |
33 | import org.apache.tools.ant.util.StringUtils; | |
32 | 34 | |
33 | 35 | /** |
34 | 36 | * Keyword substitution. Input file is written to output file. |
79 | 81 | } |
80 | 82 | bw.flush(); |
81 | 83 | } catch (IOException ioe) { |
82 | ioe.printStackTrace(); | |
84 | log(StringUtils.getStackTrace(ioe), Project.MSG_ERR); | |
83 | 85 | } finally { |
84 | 86 | FileUtils.close(bw); |
85 | 87 | FileUtils.close(br); |
152 | 154 | System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $", |
153 | 155 | hash)); |
154 | 156 | } catch (Exception e) { |
155 | e.printStackTrace(); | |
157 | e.printStackTrace(); //NOSONAR | |
156 | 158 | } |
157 | 159 | } |
158 | 160 |
246 | 246 | |
247 | 247 | /** EnumeratedAttribute operation mode */ |
248 | 248 | public static class FileMode extends EnumeratedAttribute { |
249 | static final String[] MODES = new String[] {EACH, ALL}; | |
249 | static final String[] MODES = new String[] {EACH, ALL}; //NOSONAR | |
250 | 250 | |
251 | 251 | /** |
252 | 252 | * Return the possible values for FileMode. |
76 | 76 | super.processBuffer(); |
77 | 77 | } catch (IOException e) { |
78 | 78 | // impossible since *our* processLine doesn't throw an IOException |
79 | throw new RuntimeException("Impossible IOException caught: " + e); | |
79 | throw new RuntimeException("Impossible IOException caught: " + e); //NOSONAR | |
80 | 80 | } |
81 | 81 | } |
82 | 82 |
182 | 182 | ret.setTaskName("sequential"); |
183 | 183 | ret.setNamespace(""); |
184 | 184 | ret.setQName("sequential"); |
185 | new RuntimeConfigurable(ret, "sequential"); | |
185 | // stores RuntimeConfigurable as "RuntimeConfigurableWrapper" | |
186 | // in ret as side effect | |
187 | new RuntimeConfigurable(ret, "sequential"); //NOSONAR | |
186 | 188 | final int size = nestedSequential.getNested().size(); |
187 | 189 | for (int i = 0; i < size; ++i) { |
188 | 190 | UnknownElement e = |
80 | 80 | * @param value the value of the attribute |
81 | 81 | */ |
82 | 82 | public void setDynamicAttribute(String name, String value) { |
83 | map.put(name, value); | |
83 | map.put(name.toLowerCase(Locale.ENGLISH), value); | |
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
196 | 196 | } |
197 | 197 | break; |
198 | 198 | case STATE_EXPECT_NAME: |
199 | // macroName cannot be null as this state is only | |
200 | // ever reached from STATE_EXPECT_BRACKET after it | |
201 | // has been set | |
199 | 202 | if (ch == '}') { |
200 | 203 | state = STATE_NORMAL; |
201 | String name = macroName.toString().toLowerCase(Locale.ENGLISH); | |
204 | String name = macroName.toString().toLowerCase(Locale.ENGLISH); //NOSONAR | |
202 | 205 | String value = (String) macroMapping.get(name); |
203 | 206 | if (value == null) { |
204 | 207 | ret.append("@{"); |
209 | 212 | } |
210 | 213 | macroName = null; |
211 | 214 | } else { |
212 | macroName.append(ch); | |
215 | macroName.append(ch); //NOSONAR | |
213 | 216 | } |
214 | 217 | break; |
215 | 218 | default: |
223 | 226 | ret.append('@'); |
224 | 227 | break; |
225 | 228 | case STATE_EXPECT_NAME: |
229 | // macroName cannot be null as this state is only | |
230 | // ever reached from STATE_EXPECT_BRACKET after it | |
231 | // has been set | |
226 | 232 | ret.append("@{"); |
227 | ret.append(macroName.toString()); | |
233 | ret.append(macroName.toString()); //NOSONAR | |
228 | 234 | break; |
229 | 235 | default: |
230 | 236 | break; |
1065 | 1065 | try { |
1066 | 1066 | write(new PrintWriter(sw)); |
1067 | 1067 | } catch (IOException e) { |
1068 | return null; | |
1068 | return ""; | |
1069 | 1069 | } |
1070 | 1070 | return sw.toString(); |
1071 | 1071 | } |
311 | 311 | Thread timeoutThread = new Thread() { |
312 | 312 | public synchronized void run() { |
313 | 313 | try { |
314 | wait(timeout); | |
314 | final long start = System.currentTimeMillis(); | |
315 | final long end = start + timeout; | |
316 | long now = System.currentTimeMillis(); | |
317 | while (now < end) { | |
318 | wait(end - now); | |
319 | now = System.currentTimeMillis(); | |
320 | } | |
315 | 321 | synchronized (semaphore) { |
316 | 322 | stillRunning = false; |
317 | 323 | timedOut = true; |
351 | 357 | // System.out.println("Thread " + i + " is still |
352 | 358 | // alive "); |
353 | 359 | // still running - wait for it |
354 | semaphore.wait(); | |
360 | semaphore.wait(); //NOSONAR | |
355 | 361 | continue outer2; |
356 | 362 | } |
357 | 363 | } |
83 | 83 | } catch (NoSuchMethodException e) { |
84 | 84 | // it just won't be added as a shutdown hook... :( |
85 | 85 | } catch (Exception e) { |
86 | e.printStackTrace(); | |
86 | e.printStackTrace(); //NOSONAR | |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
99 | 99 | addShutdownHookMethod.invoke(Runtime.getRuntime(), args); |
100 | 100 | added = true; |
101 | 101 | } catch (IllegalAccessException e) { |
102 | e.printStackTrace(); | |
102 | e.printStackTrace(); //NOSONAR | |
103 | 103 | } catch (InvocationTargetException e) { |
104 | 104 | Throwable t = e.getTargetException(); |
105 | 105 | if (t != null && t.getClass() == IllegalStateException.class) { |
106 | 106 | // shutdown already is in progress |
107 | 107 | running = true; |
108 | 108 | } else { |
109 | e.printStackTrace(); | |
109 | e.printStackTrace(); //NOSONAR | |
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
128 | 128 | System.err.println("Could not remove shutdown hook"); |
129 | 129 | } |
130 | 130 | } catch (IllegalAccessException e) { |
131 | e.printStackTrace(); | |
131 | e.printStackTrace(); //NOSONAR | |
132 | 132 | } catch (InvocationTargetException e) { |
133 | 133 | Throwable t = e.getTargetException(); |
134 | 134 | if (t != null && t.getClass() == IllegalStateException.class) { |
135 | 135 | // shutdown already is in progress |
136 | 136 | running = true; |
137 | 137 | } else { |
138 | e.printStackTrace(); | |
138 | e.printStackTrace(); //NOSONAR | |
139 | 139 | } |
140 | 140 | } |
141 | 141 | // start the hook thread, a unstarted thread may not be |
110 | 110 | } else { |
111 | 111 | out.println(StringUtils.LINE_SEP + "BUILD FAILED" |
112 | 112 | + StringUtils.LINE_SEP); |
113 | error.printStackTrace(out); | |
113 | error.printStackTrace(out); //NOSONAR | |
114 | 114 | } |
115 | 115 | } |
116 | 116 | cleanup(); |
136 | 136 | if (autoflush) { |
137 | 137 | os.flush(); |
138 | 138 | } |
139 | if (finish) { | |
139 | if (finish) { //NOSONAR | |
140 | 140 | break; |
141 | 141 | } |
142 | 142 | } |
33 | 33 | import org.apache.tools.ant.types.PropertySet; |
34 | 34 | import org.apache.tools.ant.types.Reference; |
35 | 35 | import org.apache.tools.ant.types.ResourceCollection; |
36 | ||
36 | import org.apache.tools.ant.util.StringUtils; | |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Calls a given target for all defined sub-builds. This is an extension |
254 | 254 | log("Target '" + file |
255 | 255 | + "' failed with message '" |
256 | 256 | + thrownException.getMessage() + "'.", Project.MSG_ERR); |
257 | thrownException.printStackTrace(System.err); | |
257 | log(StringUtils.getStackTrace(thrownException), Project.MSG_ERR); | |
258 | 258 | if (buildException == null) { |
259 | 259 | buildException = |
260 | 260 | new BuildException(thrownException); |
402 | 402 | if (resources == null) { |
403 | 403 | Restrict r = new Restrict(); |
404 | 404 | r.add(new Exists()); |
405 | r.add(resources = new Resources()); | |
405 | resources = new Resources(); | |
406 | r.add(resources); | |
406 | 407 | myCopy.add(r); |
407 | 408 | } |
408 | 409 | resources.add(rc); |
60 | 60 | |
61 | 61 | public static final DateFormatFactory DEFAULT_DF_FACTORY |
62 | 62 | = new DateFormatFactory() { |
63 | /* | |
64 | * The initial version used DateFormat.SHORT for the | |
65 | * time format, which ignores seconds. If we want | |
66 | * seconds as well, we need DateFormat.MEDIUM, which | |
67 | * in turn would break all old build files. | |
68 | * | |
69 | * First try to parse with DateFormat.SHORT and if | |
70 | * that fails with MEDIUM - throw an exception if both | |
71 | * fail. | |
72 | */ | |
63 | ||
64 | private ThreadLocal<DateFormat> primary = | |
65 | new ThreadLocal<DateFormat>() { | |
66 | @Override | |
67 | protected DateFormat initialValue() { | |
68 | return new SimpleDateFormat("MM/dd/yyyy hh:mm a", | |
69 | Locale.US); | |
70 | } | |
71 | }; | |
72 | private ThreadLocal<DateFormat> fallback = | |
73 | new ThreadLocal<DateFormat>() { | |
74 | @Override | |
75 | protected DateFormat initialValue() { | |
76 | return new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a", | |
77 | Locale.US); | |
78 | } | |
79 | }; | |
80 | ||
73 | 81 | public DateFormat getPrimaryFormat() { |
74 | return DateFormat.getDateTimeInstance(DateFormat.SHORT, | |
75 | DateFormat.SHORT, Locale.US); | |
82 | return primary.get(); | |
76 | 83 | } |
77 | 84 | public DateFormat getFallbackFormat() { |
78 | return DateFormat.getDateTimeInstance(DateFormat.SHORT, | |
79 | DateFormat.MEDIUM, Locale.US); | |
85 | return fallback.get(); | |
80 | 86 | } |
81 | 87 | }; |
82 | 88 | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); |
166 | 166 | } |
167 | 167 | RandomAccessFile raf = null; |
168 | 168 | try { |
169 | raf = new RandomAccessFile(f, READ_WRITE); | |
169 | raf = new RandomAccessFile(f, READ_WRITE); //NOSONAR | |
170 | 170 | } catch (Exception e) { |
171 | 171 | throw new BuildException("Could not open " + f + " for writing", e); |
172 | 172 | } |
43 | 43 | * @throws Exception thrown if any problems happens. |
44 | 44 | * @since Ant 1.4 |
45 | 45 | */ |
46 | void setStylesheet(File stylesheet) throws Exception; | |
46 | void setStylesheet(File stylesheet) throws Exception; //NOSONAR | |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Add a parameter to be set during the XSL transformation. |
53 | 53 | * @see XSLTLiaison4#addParam(java.lang.String, java.lang.Object) |
54 | 54 | * @since Ant 1.3 |
55 | 55 | */ |
56 | void addParam(String name, String expression) throws Exception; | |
56 | void addParam(String name, String expression) throws Exception; //NOSONAR | |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Perform the transformation of a file into another. |
63 | 63 | * @see #setStylesheet(File) |
64 | 64 | * @since Ant 1.4 |
65 | 65 | */ |
66 | void transform(File infile, File outfile) throws Exception; | |
66 | void transform(File infile, File outfile) throws Exception; //NOSONAR | |
67 | 67 | |
68 | 68 | } //-- XSLTLiaison |
38 | 38 | import org.apache.tools.ant.DirectoryScanner; |
39 | 39 | import org.apache.tools.ant.DynamicConfigurator; |
40 | 40 | import org.apache.tools.ant.Project; |
41 | import org.apache.tools.ant.ProjectComponent; | |
41 | 42 | import org.apache.tools.ant.PropertyHelper; |
42 | 43 | import org.apache.tools.ant.types.CommandlineJava; |
43 | 44 | import org.apache.tools.ant.types.Environment; |
52 | 53 | import org.apache.tools.ant.types.resources.FileResource; |
53 | 54 | import org.apache.tools.ant.types.resources.Resources; |
54 | 55 | import org.apache.tools.ant.types.resources.Union; |
56 | import org.apache.tools.ant.util.ClasspathUtils; | |
55 | 57 | import org.apache.tools.ant.util.FileNameMapper; |
56 | 58 | import org.apache.tools.ant.util.FileUtils; |
57 | 59 | import org.apache.tools.ant.util.ResourceUtils; |
60 | import org.apache.tools.ant.util.StringUtils; | |
58 | 61 | |
59 | 62 | /** |
60 | 63 | * Processes a set of XML documents via XSLT. This is |
717 | 720 | * @return the requested class. |
718 | 721 | * @exception Exception if the class could not be loaded. |
719 | 722 | */ |
720 | private Class loadClass(final String classname) throws Exception { | |
723 | private Class loadClass(final String classname) throws ClassNotFoundException { | |
721 | 724 | setupLoader(); |
722 | 725 | if (loader == null) { |
723 | 726 | return Class.forName(classname); |
828 | 831 | if (outFileName == null || outFileName.length == 0) { |
829 | 832 | log("Skipping " + inFile + " it cannot get mapped to output.", Project.MSG_VERBOSE); |
830 | 833 | return; |
831 | } else if (outFileName == null || outFileName.length > 1) { | |
834 | } else if (outFileName.length > 1) { | |
832 | 835 | log("Skipping " + inFile + " its mapping is ambiguos.", Project.MSG_VERBOSE); |
833 | 836 | return; |
834 | 837 | } |
949 | 952 | try { |
950 | 953 | resolveProcessor(PROCESSOR_TRAX); |
951 | 954 | } catch (final Throwable e1) { |
952 | e1.printStackTrace(); | |
955 | log(StringUtils.getStackTrace(e1), Project.MSG_ERR); | |
953 | 956 | handleError(e1); |
954 | 957 | } |
955 | 958 | } |
1376 | 1379 | * @since Ant 1.7 |
1377 | 1380 | */ |
1378 | 1381 | private void setLiaisonDynamicFileParameters( |
1379 | final XSLTLiaison liaison, final File inFile) throws Exception { | |
1382 | final XSLTLiaison liaison, final File inFile) throws Exception { //NOSONAR | |
1380 | 1383 | if (fileNameParameter != null) { |
1381 | 1384 | liaison.addParam(fileNameParameter, inFile.getName()); |
1382 | 1385 | } |
1461 | 1464 | /** |
1462 | 1465 | * the list of factory attributes to use for TraXLiaison |
1463 | 1466 | */ |
1464 | private final Vector attributes = new Vector(); | |
1467 | private final List<Attribute> attributes = new ArrayList<Attribute>(); | |
1468 | ||
1469 | /** | |
1470 | * the list of factory features to use for TraXLiaison | |
1471 | */ | |
1472 | private final List<Feature> features = new ArrayList<Feature>(); | |
1465 | 1473 | |
1466 | 1474 | /** |
1467 | 1475 | * @return the name of the factory. |
1483 | 1491 | * @param attr the newly created factory attribute |
1484 | 1492 | */ |
1485 | 1493 | public void addAttribute(final Attribute attr) { |
1486 | attributes.addElement(attr); | |
1494 | attributes.add(attr); | |
1487 | 1495 | } |
1488 | 1496 | |
1489 | 1497 | /** |
1491 | 1499 | * @return the enumeration of attributes |
1492 | 1500 | */ |
1493 | 1501 | public Enumeration getAttributes() { |
1494 | return attributes.elements(); | |
1502 | return Collections.enumeration(attributes); | |
1503 | } | |
1504 | ||
1505 | /** | |
1506 | * Create an instance of a factory feature. | |
1507 | * @param feature the newly created feature | |
1508 | * @since Ant 1.9.8 | |
1509 | */ | |
1510 | public void addFeature(final Feature feature) { | |
1511 | features.add(feature); | |
1512 | } | |
1513 | ||
1514 | /** | |
1515 | * The configured features. | |
1516 | * @since Ant 1.9.8 | |
1517 | */ | |
1518 | public Iterable<Feature> getFeatures() { | |
1519 | return features; | |
1495 | 1520 | } |
1496 | 1521 | |
1497 | 1522 | /** |
1502 | 1527 | * <li>http://xml.apache.org/xalan/features/incremental (true|false) </li> |
1503 | 1528 | * </ul> |
1504 | 1529 | */ |
1505 | public static class Attribute implements DynamicConfigurator { | |
1530 | public static class Attribute | |
1531 | extends ProjectComponent | |
1532 | implements DynamicConfigurator { | |
1506 | 1533 | |
1507 | 1534 | /** attribute name, mostly processor specific */ |
1508 | 1535 | private String name; |
1518 | 1545 | } |
1519 | 1546 | |
1520 | 1547 | /** |
1521 | * @return the output property value. | |
1548 | * @return the attribute value. | |
1522 | 1549 | */ |
1523 | 1550 | public Object getValue() { |
1524 | 1551 | return value; |
1559 | 1586 | this.value = value; |
1560 | 1587 | } |
1561 | 1588 | } |
1589 | } else if ("valueref".equalsIgnoreCase(name)) { | |
1590 | this.value = getProject().getReference(value); | |
1591 | } else if ("classloaderforpath".equalsIgnoreCase(name)) { | |
1592 | this.value = | |
1593 | ClasspathUtils.getClassLoaderForPath(getProject(), | |
1594 | new Reference(getProject(), | |
1595 | value)); | |
1562 | 1596 | } else { |
1563 | 1597 | throw new BuildException("Unsupported attribute: " + name); |
1564 | 1598 | } |
1565 | 1599 | } |
1566 | 1600 | } // -- class Attribute |
1601 | ||
1602 | /** | |
1603 | * A feature for the TraX factory. | |
1604 | * @since Ant 1.9.8 | |
1605 | */ | |
1606 | public static class Feature { | |
1607 | private String name; | |
1608 | private boolean value; | |
1609 | ||
1610 | public Feature() { } | |
1611 | public Feature(String name, boolean value) { | |
1612 | this.name = name; | |
1613 | this.value = value; | |
1614 | } | |
1615 | ||
1616 | /** | |
1617 | * @param name the feature name. | |
1618 | */ | |
1619 | public void setName(String name) { | |
1620 | this.name = name; | |
1621 | } | |
1622 | ||
1623 | /** | |
1624 | * @param value the feature value. | |
1625 | */ | |
1626 | public void setValue(boolean value) { | |
1627 | this.value = value; | |
1628 | } | |
1629 | ||
1630 | /** | |
1631 | * @return the feature name. | |
1632 | */ | |
1633 | public String getName() { | |
1634 | return name; | |
1635 | } | |
1636 | ||
1637 | /** | |
1638 | * @return the feature value. | |
1639 | */ | |
1640 | public boolean getValue() { | |
1641 | return value; | |
1642 | } | |
1643 | } | |
1567 | 1644 | } // -- class Factory |
1568 | 1645 | |
1569 | 1646 | /** |
383 | 383 | if (containingPath != null && nodeName.equals(PATH)) { |
384 | 384 | // A "path" attribute for a node within a Path object. |
385 | 385 | containingPath.setPath(attributeValue); |
386 | } else if (container instanceof Path && nodeName.equals(REF_ID)) { | |
386 | } else if (containingPath != null | |
387 | && container instanceof Path && nodeName.equals(REF_ID)) { | |
387 | 388 | // A "refid" attribute for a node within a Path object. |
388 | 389 | containingPath.setPath(attributeValue); |
389 | } else if (container instanceof Path && nodeName.equals(LOCATION)) { | |
390 | } else if (containingPath != null && container instanceof Path | |
391 | && nodeName.equals(LOCATION)) { | |
390 | 392 | // A "location" attribute for a node within a |
391 | 393 | // Path object. |
392 | 394 | containingPath.setLocation(resolveFile(attributeValue)); |
77 | 77 | */ |
78 | 78 | public class Zip extends MatchingTask { |
79 | 79 | private static final int BUFFER_SIZE = 8 * 1024; |
80 | private static final int ROUNDUP_MILLIS = 1999; // 2 seconds - 1 | |
80 | /** | |
81 | * The granularity of timestamps inside a ZIP archive. | |
82 | */ | |
83 | private static final int ZIP_FILE_TIMESTAMP_GRANULARITY = 2000; | |
84 | private static final int ROUNDUP_MILLIS = ZIP_FILE_TIMESTAMP_GRANULARITY - 1; | |
81 | 85 | // CheckStyle:VisibilityModifier OFF - bc |
82 | 86 | |
83 | 87 | protected File zipFile; |
1021 | 1025 | * Determine a Resource's Unix mode or return the given default |
1022 | 1026 | * value if not available. |
1023 | 1027 | */ |
1024 | private int getUnixMode(final Resource r, final ZipFile zf, final int defaultMode) | |
1025 | throws IOException { | |
1028 | private int getUnixMode(final Resource r, final ZipFile zf, final int defaultMode) { | |
1026 | 1029 | |
1027 | 1030 | int unixMode = defaultMode; |
1028 | 1031 | if (zf != null) { |
1547 | 1550 | final Resource[] rs = selectFileResources(initial); |
1548 | 1551 | Resource[] result = |
1549 | 1552 | ResourceUtils.selectOutOfDateSources(this, rs, mapper, |
1550 | getZipScanner()); | |
1553 | getZipScanner(), | |
1554 | ZIP_FILE_TIMESTAMP_GRANULARITY); | |
1551 | 1555 | if (!doFilesonly) { |
1552 | 1556 | final Union u = new Union(); |
1553 | 1557 | u.addAll(Arrays.asList(selectDirectoryResources(initial))); |
121 | 121 | || compilerType.equalsIgnoreCase("javac1.6") |
122 | 122 | || compilerType.equalsIgnoreCase("javac1.7") |
123 | 123 | || compilerType.equalsIgnoreCase("javac1.8") |
124 | || compilerType.equalsIgnoreCase("javac1.9")) { | |
124 | || compilerType.equalsIgnoreCase("javac1.9") | |
125 | || compilerType.equalsIgnoreCase("javac9")) { | |
125 | 126 | // does the modern compiler exist? |
126 | 127 | if (doesModernCompilerExist()) { |
127 | 128 | return new Javac13(); |
69 | 69 | protected boolean depend = false; |
70 | 70 | protected boolean verbose = false; |
71 | 71 | protected String target; |
72 | protected String release; | |
72 | 73 | protected Path bootclasspath; |
73 | 74 | protected Path extdirs; |
74 | 75 | protected Path compileClasspath; |
110 | 111 | depend = attributes.getDepend(); |
111 | 112 | verbose = attributes.getVerbose(); |
112 | 113 | target = attributes.getTarget(); |
114 | release = attributes.getRelease(); | |
113 | 115 | bootclasspath = attributes.getBootclasspath(); |
114 | 116 | extdirs = attributes.getExtdirs(); |
115 | 117 | compileList = attributes.getFileList(); |
320 | 322 | cmd.createArgument().setValue("-sourcepath"); |
321 | 323 | cmd.createArgument().setPath(sourcepath); |
322 | 324 | } |
323 | if (target != null) { | |
324 | cmd.createArgument().setValue("-target"); | |
325 | cmd.createArgument().setValue(target); | |
326 | } | |
327 | ||
328 | final Path bp = getBootClassPath(); | |
329 | if (bp.size() > 0) { | |
330 | cmd.createArgument().setValue("-bootclasspath"); | |
331 | cmd.createArgument().setPath(bp); | |
325 | if (release == null || !assumeJava19()) { | |
326 | if (target != null) { | |
327 | cmd.createArgument().setValue("-target"); | |
328 | cmd.createArgument().setValue(target); | |
329 | } | |
330 | ||
331 | final Path bp = getBootClassPath(); | |
332 | if (bp.size() > 0) { | |
333 | cmd.createArgument().setValue("-bootclasspath"); | |
334 | cmd.createArgument().setPath(bp); | |
335 | } | |
332 | 336 | } |
333 | 337 | |
334 | 338 | if (extdirs != null && extdirs.size() > 0) { |
389 | 393 | setupJavacCommandlineSwitches(cmd, true); |
390 | 394 | if (!assumeJava13()) { // -source added with JDK 1.4 |
391 | 395 | final String t = attributes.getTarget(); |
392 | if (attributes.getSource() != null) { | |
393 | cmd.createArgument().setValue("-source"); | |
394 | cmd.createArgument() | |
395 | .setValue(adjustSourceValue(attributes.getSource())); | |
396 | ||
397 | } else if (t != null && mustSetSourceForTarget(t)) { | |
398 | setImplicitSourceSwitch(cmd, t, adjustSourceValue(t)); | |
396 | final String s = attributes.getSource(); | |
397 | if (release == null || !assumeJava19()) { | |
398 | if (release != null) { | |
399 | attributes.log("Support for javac --release has been added" | |
400 | + " in Java9 ignoring it"); | |
401 | } | |
402 | if (s != null) { | |
403 | cmd.createArgument().setValue("-source"); | |
404 | cmd.createArgument().setValue(adjustSourceValue(s)); | |
405 | ||
406 | } else if (t != null && mustSetSourceForTarget(t)) { | |
407 | setImplicitSourceSwitch(cmd, t, adjustSourceValue(t)); | |
408 | } | |
409 | } else { // Java 9+ and release has been set | |
410 | if (t != null || s != null || getBootClassPath().size() > 0) { | |
411 | attributes.log("Ignoring source, target and bootclasspath" | |
412 | + " as release has been set", | |
413 | Project.MSG_WARN); | |
414 | } | |
415 | cmd.createArgument().setValue("--release"); | |
416 | cmd.createArgument().setValue(release); | |
399 | 417 | } |
400 | 418 | } |
401 | 419 | final Path msp = getModulesourcepath(); |
402 | 420 | if (msp.size() > 0) { |
403 | cmd.createArgument().setValue("-modulesourcepath"); | |
421 | cmd.createArgument().setValue("--module-source-path"); | |
404 | 422 | cmd.createArgument().setPath(msp); |
405 | 423 | } |
406 | 424 | final Path mp = getModulepath(); |
407 | 425 | if (mp.size() > 0) { |
408 | cmd.createArgument().setValue("-modulepath"); | |
426 | cmd.createArgument().setValue("--module-path"); | |
409 | 427 | cmd.createArgument().setPath(mp); |
410 | 428 | } |
411 | 429 | final Path ump = getUpgrademodulepath(); |
412 | 430 | if (ump.size() > 0) { |
413 | cmd.createArgument().setValue("-upgrademodulepath"); | |
431 | cmd.createArgument().setValue("--upgrade-module-path"); | |
414 | 432 | cmd.createArgument().setPath(ump); |
433 | } | |
434 | if (attributes.getNativeHeaderDir() != null) { | |
435 | if (assumeJava13() || assumeJava14() || assumeJava15() | |
436 | || assumeJava16() || assumeJava17()) { | |
437 | attributes.log("Support for javac -h has been added in Java8," | |
438 | + " ignoring it"); | |
439 | } else { | |
440 | cmd.createArgument().setValue("-h"); | |
441 | cmd.createArgument().setFile(attributes.getNativeHeaderDir()); | |
442 | } | |
415 | 443 | } |
416 | 444 | return cmd; |
417 | 445 | } |
671 | 699 | } |
672 | 700 | |
673 | 701 | /** |
674 | * Shall we assume JDK 1.9 command line switches? | |
675 | * @return true if JDK 1.9 | |
702 | * Shall we assume JDK 9 command line switches? | |
703 | * @return true if JDK 9 | |
676 | 704 | * @since Ant 1.9.4 |
705 | * @deprecated use #assumeJava9 instead | |
677 | 706 | */ |
678 | 707 | protected boolean assumeJava19() { |
679 | return assumeJavaXY("javac1.9", JavaEnvUtils.JAVA_1_9); | |
708 | return assumeJavaXY("javac1.9", JavaEnvUtils.JAVA_9) | |
709 | || assumeJavaXY("javac9", JavaEnvUtils.JAVA_9); | |
710 | } | |
711 | ||
712 | /** | |
713 | * Shall we assume JDK 9 command line switches? | |
714 | * @return true if JDK 9 | |
715 | * @since Ant 1.9.8 | |
716 | */ | |
717 | protected boolean assumeJava9() { | |
718 | return assumeJava19(); | |
680 | 719 | } |
681 | 720 | |
682 | 721 | /** |
685 | 724 | */ |
686 | 725 | private boolean assumeJavaXY(final String javacXY, final String javaEnvVersionXY) { |
687 | 726 | return javacXY.equals(attributes.getCompilerVersion()) |
688 | || ("classic".equals(attributes.getCompilerVersion()) | |
689 | && JavaEnvUtils.isJavaVersion(javaEnvVersionXY)) | |
690 | || ("modern".equals(attributes.getCompilerVersion()) | |
691 | && JavaEnvUtils.isJavaVersion(javaEnvVersionXY)) | |
692 | || ("extJavac".equals(attributes.getCompilerVersion()) | |
693 | && JavaEnvUtils.isJavaVersion(javaEnvVersionXY)); | |
727 | || (JavaEnvUtils.isJavaVersion(javaEnvVersionXY) && | |
728 | ("classic".equals(attributes.getCompilerVersion()) | |
729 | || "modern".equals(attributes.getCompilerVersion()) | |
730 | || "extJavac".equals(attributes.getCompilerVersion()))); | |
694 | 731 | } |
695 | 732 | |
696 | 733 | /** |
754 | 791 | if (assumeJava18()) { |
755 | 792 | return "1.8 in JDK 1.8"; |
756 | 793 | } |
757 | if (assumeJava19()) { | |
758 | return "1.9 in JDK 1.9"; | |
794 | if (assumeJava9()) { | |
795 | return "9 in JDK 9"; | |
759 | 796 | } |
760 | 797 | return ""; |
761 | 798 | } |
781 | 818 | && !assumeJava15() && !assumeJava16()) |
782 | 819 | || (t.equals("7") && !assumeJava17()) |
783 | 820 | || (t.equals("8") && !assumeJava18()) |
784 | || (t.equals("9") && !assumeJava19()); | |
821 | || (t.equals("9") && !assumeJava9()); | |
785 | 822 | } |
786 | 823 | |
787 | 824 |
77 | 77 | } |
78 | 78 | if (atLeast != null) { |
79 | 79 | try { |
80 | new DeweyDecimal(atLeast); | |
80 | // only created for side effect | |
81 | new DeweyDecimal(atLeast); //NOSONAR | |
81 | 82 | } catch (NumberFormatException e) { |
82 | 83 | throw new BuildException( |
83 | 84 | "The 'atleast' attribute is not a Dewey Decimal eg 1.1.0 : " |
85 | 86 | } |
86 | 87 | } else { |
87 | 88 | try { |
88 | new DeweyDecimal(exactly); | |
89 | // only created for side effect | |
90 | new DeweyDecimal(exactly); //NOSONAR | |
89 | 91 | } catch (NumberFormatException e) { |
90 | 92 | throw new BuildException( |
91 | 93 | "The 'exactly' attribute is not a Dewey Decimal eg 1.1.0 : " |
43 | 43 | private static final int GET_REVISION = 4; |
44 | 44 | private static final int GET_PREVIOUS_REV = 5; |
45 | 45 | |
46 | // FIXME formatters are not thread-safe | |
47 | ||
48 | 46 | /** input format for dates read in from cvs log */ |
49 | private static final SimpleDateFormat INPUT_DATE | |
47 | private final SimpleDateFormat inputDate | |
50 | 48 | = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US); |
51 | 49 | /** |
52 | 50 | * New formatter used to parse CVS date/timestamp. |
53 | 51 | */ |
54 | private static final SimpleDateFormat CVS1129_INPUT_DATE = | |
52 | private final SimpleDateFormat cvs1129InputDate = | |
55 | 53 | new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.US); |
56 | 54 | |
57 | 55 | static { |
58 | TimeZone utc = TimeZone.getTimeZone("UTC"); | |
59 | INPUT_DATE.setTimeZone(utc); | |
60 | CVS1129_INPUT_DATE.setTimeZone(utc); | |
61 | 56 | } |
62 | 57 | |
63 | 58 | //The following is data used while processing stdout of CVS command |
101 | 96 | for (int i = 0; i < moduleNames.length; i++) { |
102 | 97 | moduleNameLengths[i] = moduleNames[i].length(); |
103 | 98 | } |
99 | ||
100 | TimeZone utc = TimeZone.getTimeZone("UTC"); | |
101 | inputDate.setTimeZone(utc); | |
102 | cvs1129InputDate.setTimeZone(utc); | |
104 | 103 | } |
105 | 104 | |
106 | 105 | /** |
296 | 295 | */ |
297 | 296 | private Date parseDate(final String date) { |
298 | 297 | try { |
299 | return INPUT_DATE.parse(date); | |
298 | return inputDate.parse(date); | |
300 | 299 | } catch (ParseException e) { |
301 | 300 | try { |
302 | return CVS1129_INPUT_DATE.parse(date); | |
301 | return cvs1129InputDate.parse(date); | |
303 | 302 | } catch (ParseException e2) { |
304 | 303 | throw new IllegalStateException("Invalid date format: " + date); |
305 | 304 | } |
33 | 33 | */ |
34 | 34 | public class ChangeLogWriter { |
35 | 35 | /** output format for dates written to xml file */ |
36 | private static final SimpleDateFormat OUTPUT_DATE | |
36 | private final SimpleDateFormat outputDate | |
37 | 37 | = new SimpleDateFormat("yyyy-MM-dd"); |
38 | 38 | /** output format for times written to xml file */ |
39 | private static final SimpleDateFormat OUTPUT_TIME | |
39 | private SimpleDateFormat outputTime | |
40 | 40 | = new SimpleDateFormat("HH:mm"); |
41 | 41 | /** stateless helper for writing the XML document */ |
42 | 42 | private static final DOMElementWriter DOM_WRITER = new DOMElementWriter(); |
43 | 43 | |
44 | static { | |
44 | public ChangeLogWriter() { | |
45 | 45 | TimeZone utc = TimeZone.getTimeZone("UTC"); |
46 | OUTPUT_DATE.setTimeZone(utc); | |
47 | OUTPUT_TIME.setTimeZone(utc); | |
46 | outputDate.setTimeZone(utc); | |
47 | outputTime.setTimeZone(utc); | |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
86 | 86 | final CVSEntry entry) throws IOException { |
87 | 87 | Element ent = doc.createElement("entry"); |
88 | 88 | DOMUtils.appendTextElement(ent, "date", |
89 | OUTPUT_DATE.format(entry.getDate())); | |
89 | outputDate.format(entry.getDate())); | |
90 | 90 | DOMUtils.appendTextElement(ent, "time", |
91 | OUTPUT_TIME.format(entry.getDate())); | |
91 | outputTime.format(entry.getDate())); | |
92 | 92 | DOMUtils.appendCDATAElement(ent, "author", entry.getAuthor()); |
93 | 93 | |
94 | 94 | final Enumeration enumeration = entry.getFiles().elements(); |
298 | 298 | BufferedReader reader = null; |
299 | 299 | |
300 | 300 | try { |
301 | reader = new BufferedReader(new FileReader(tmpFile)); | |
301 | reader = new BufferedReader(new FileReader(tmpFile)); //NOSONAR | |
302 | 302 | |
303 | 303 | // entries are of the form: |
304 | 304 | //CVS 1.11 |
439 | 439 | Tuple that = (Tuple) o; |
440 | 440 | return key.compareTo(that.key); |
441 | 441 | } |
442 | ||
443 | @Override | |
444 | public boolean equals(Object o) { | |
445 | if (o == this) { | |
446 | return true; | |
447 | } | |
448 | if (o == null || o.getClass() != getClass()) { | |
449 | return false; | |
450 | } | |
451 | Tuple that = (Tuple) o; | |
452 | return (key == null ? that.key == null : key.equals(that.key)) | |
453 | && (value == null ? that.value == null : value.equals(that.value)); | |
454 | } | |
455 | ||
456 | @Override | |
457 | public int hashCode() { | |
458 | return key != null ? key.hashCode() : 0; | |
459 | } | |
442 | 460 | } |
443 | 461 | |
444 | 462 | private List sortProperties(Properties props) { |
867 | 867 | PrintWriter w = null; |
868 | 868 | int rc = |
869 | 869 | COM.ibm.netrexx.process.NetRexxC.main(new Rexx(compileArgs), |
870 | w = new PrintWriter(out)); | |
870 | w = new PrintWriter(out)); //NOSONAR | |
871 | 871 | String sdir = srcDir.getAbsolutePath(); |
872 | 872 | String ddir = destDir.getAbsolutePath(); |
873 | 873 | boolean doReplace = !(sdir.equals(ddir)); |
259 | 259 | throw new BuildException(x, getLocation()); |
260 | 260 | } |
261 | 261 | try { |
262 | OutputStream os = new FileOutputStream(propertyfile); | |
262 | OutputStream os = new FileOutputStream(propertyfile); //NOSONAR | |
263 | 263 | try { |
264 | 264 | try { |
265 | 265 | os.write(baos.toByteArray()); |
400 | 400 | } catch (NullPointerException npe) { |
401 | 401 | // Default to string type |
402 | 402 | // which means do nothing |
403 | npe.printStackTrace(); | |
403 | npe.printStackTrace(); //NOSONAR | |
404 | 404 | } |
405 | 405 | |
406 | 406 | if (newValue == null) { |
148 | 148 | } |
149 | 149 | } else { |
150 | 150 | if (output != null) { |
151 | FileOutputStream fos = null; | |
151 | 152 | try { |
152 | BufferedOutputStream bos | |
153 | = new BufferedOutputStream(new FileOutputStream(output)); | |
153 | fos = new FileOutputStream(output); //NOSONAR | |
154 | BufferedOutputStream bos = new BufferedOutputStream(fos); | |
154 | 155 | outputstream = new PrintStream(bos); |
155 | 156 | } catch (IOException e) { |
157 | FileUtils.close(fos); | |
156 | 158 | throw new BuildException(e, getLocation()); |
157 | 159 | } |
158 | 160 | } else if (!quiet) { |
161 | 163 | outputstream = new LogOutputStream(this, Project.MSG_DEBUG); |
162 | 164 | } |
163 | 165 | if (error != null) { |
166 | FileOutputStream fos = null; | |
164 | 167 | try { |
165 | BufferedOutputStream bos | |
166 | = new BufferedOutputStream(new FileOutputStream(error)); | |
168 | fos = new FileOutputStream(error); | |
169 | BufferedOutputStream bos = new BufferedOutputStream(fos); | |
167 | 170 | errorstream = new PrintStream(bos); |
168 | 171 | } catch (IOException e) { |
172 | FileUtils.close(fos); | |
169 | 173 | throw new BuildException(e, getLocation()); |
170 | 174 | } |
171 | 175 | } else if (!quiet) { |
27 | 27 | import java.io.OutputStream; |
28 | 28 | import java.lang.reflect.Field; |
29 | 29 | import java.net.URL; |
30 | import java.util.ArrayList; | |
30 | 31 | import java.util.Enumeration; |
32 | import java.util.HashMap; | |
31 | 33 | import java.util.Hashtable; |
34 | import java.util.List; | |
35 | import java.util.Map; | |
32 | 36 | import java.util.Vector; |
33 | 37 | |
34 | 38 | import javax.xml.parsers.ParserConfigurationException; |
59 | 63 | import org.apache.tools.ant.types.resources.URLProvider; |
60 | 64 | import org.apache.tools.ant.util.FileUtils; |
61 | 65 | import org.apache.tools.ant.util.JAXPUtils; |
66 | import org.apache.tools.ant.util.JavaEnvUtils; | |
62 | 67 | import org.xml.sax.EntityResolver; |
63 | 68 | import org.xml.sax.InputSource; |
64 | 69 | import org.xml.sax.SAXException; |
122 | 127 | private final Hashtable<String, Object> params = new Hashtable<String, Object>(); |
123 | 128 | |
124 | 129 | /** factory attributes */ |
125 | private final Vector attributes = new Vector(); | |
130 | private final List<Object[]> attributes = new ArrayList<Object[]>(); | |
131 | ||
132 | /** factory features */ | |
133 | private final Map<String, Boolean> features = new HashMap<String, Boolean>(); | |
126 | 134 | |
127 | 135 | /** whether to suppress warnings */ |
128 | 136 | private boolean suppressWarnings = false; |
134 | 142 | * Constructor for TraXLiaison. |
135 | 143 | * @throws Exception never |
136 | 144 | */ |
137 | public TraXLiaison() throws Exception { | |
145 | public TraXLiaison() throws Exception { //NOSONAR | |
138 | 146 | } |
139 | 147 | |
140 | 148 | /** |
313 | 321 | * @see #addParam(java.lang.String, java.lang.String) |
314 | 322 | * @see #setOutputProperty(java.lang.String, java.lang.String) |
315 | 323 | */ |
316 | private void createTransformer() throws Exception { | |
324 | private void createTransformer() | |
325 | throws IOException, ParserConfigurationException, SAXException, TransformerException { | |
317 | 326 | if (templates == null) { |
318 | 327 | readTemplates(); |
319 | 328 | } |
332 | 341 | } |
333 | 342 | |
334 | 343 | if (traceConfiguration != null) { |
335 | if ("org.apache.xalan.transformer.TransformerImpl" | |
344 | if ("org.apache.xalan.transformer.TransformerImpl" //NOSONAR | |
336 | 345 | .equals(transformer.getClass().getName())) { |
337 | 346 | try { |
338 | 347 | final Class traceSupport = |
420 | 429 | } |
421 | 430 | } |
422 | 431 | |
423 | try { // #51668, #52382 | |
424 | final Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing"); | |
425 | _isNotSecureProcessing.setAccessible(true); | |
426 | _isNotSecureProcessing.set(tfactory, Boolean.TRUE); | |
427 | } catch (final Exception x) { | |
428 | if (project != null) { | |
429 | project.log(x.toString(), Project.MSG_DEBUG); | |
430 | } | |
431 | } | |
432 | applyReflectionHackForExtensionMethods(); | |
432 | 433 | |
433 | 434 | tfactory.setErrorListener(this); |
434 | 435 | |
435 | 436 | // specific attributes for the transformer |
436 | 437 | final int size = attributes.size(); |
437 | 438 | for (int i = 0; i < size; i++) { |
438 | final Object[] pair = (Object[]) attributes.elementAt(i); | |
439 | final Object[] pair = attributes.get(i); | |
439 | 440 | tfactory.setAttribute((String) pair[0], pair[1]); |
441 | } | |
442 | ||
443 | for (Map.Entry<String, Boolean> feature : features.entrySet()) { | |
444 | try { | |
445 | tfactory.setFeature(feature.getKey(), feature.getValue()); | |
446 | } catch (TransformerConfigurationException ex) { | |
447 | throw new BuildException(ex); | |
448 | } | |
440 | 449 | } |
441 | 450 | |
442 | 451 | if (uriResolver != null) { |
444 | 453 | } |
445 | 454 | return tfactory; |
446 | 455 | } |
447 | ||
448 | 456 | |
449 | 457 | /** |
450 | 458 | * Set the factory name to use instead of JAXP default lookup. |
465 | 473 | */ |
466 | 474 | public void setAttribute(final String name, final Object value) { |
467 | 475 | final Object[] pair = new Object[]{name, value}; |
468 | attributes.addElement(pair); | |
476 | attributes.add(pair); | |
477 | } | |
478 | ||
479 | /** | |
480 | * Set a custom feature for the JAXP factory implementation. | |
481 | * @param name the feature name. | |
482 | * @param value the value of the feature | |
483 | * @since Ant 1.9.8 | |
484 | */ | |
485 | public void setFeature(final String name, final boolean value) { | |
486 | features.put(name, value); | |
469 | 487 | } |
470 | 488 | |
471 | 489 | /** |
624 | 642 | (XSLTProcess.Factory.Attribute) attrs.nextElement(); |
625 | 643 | setAttribute(attr.getName(), attr.getValue()); |
626 | 644 | } |
645 | for (final XSLTProcess.Factory.Feature feature | |
646 | : factory.getFeatures()) { | |
647 | setFeature(feature.getName(), feature.getValue()); | |
648 | } | |
627 | 649 | } |
628 | 650 | |
629 | 651 | final XMLCatalog xmlCatalog = xsltTask.getXMLCatalog(); |
646 | 668 | |
647 | 669 | traceConfiguration = xsltTask.getTraceConfiguration(); |
648 | 670 | } |
671 | ||
672 | private void applyReflectionHackForExtensionMethods() { | |
673 | // Jigsaw doesn't allow reflection to work, so we can stop trying | |
674 | if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_7) | |
675 | && !JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | |
676 | try { // #51668, #52382 | |
677 | final Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing"); | |
678 | _isNotSecureProcessing.setAccessible(true); | |
679 | _isNotSecureProcessing.set(tfactory, Boolean.TRUE); | |
680 | } catch (final Exception x) { | |
681 | if (project != null) { | |
682 | project.log(x.toString(), Project.MSG_DEBUG); | |
683 | } | |
684 | } | |
685 | } | |
686 | } | |
687 | ||
649 | 688 | } |
29 | 29 | import org.apache.tools.ant.taskdefs.Execute; |
30 | 30 | import org.apache.tools.ant.taskdefs.ExecuteStreamHandler; |
31 | 31 | import org.apache.tools.ant.types.Commandline; |
32 | ||
32 | import org.apache.tools.ant.util.StringUtils; | |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Creates new Continuus ccm task and sets it as the default. |
321 | 321 | } // end of if () |
322 | 322 | } catch (NullPointerException npe) { |
323 | 323 | log("error procession stream , null pointer exception", Project.MSG_ERR); |
324 | npe.printStackTrace(); | |
324 | log(StringUtils.getStackTrace(npe), Project.MSG_ERR); | |
325 | 325 | throw new BuildException(npe.getClass().getName()); |
326 | 326 | } catch (Exception e) { |
327 | 327 | log("error procession stream " + e.getMessage(), Project.MSG_ERR); |
48 | 48 | private String mClearToolDir = ""; |
49 | 49 | private String mviewPath = null; |
50 | 50 | private String mobjSelect = null; |
51 | private static int pcnt = 0; | |
51 | private int pcnt = 0; | |
52 | 52 | private boolean mFailonerr = true; |
53 | 53 | /** |
54 | 54 | * Set the directory where the cleartool executable is located. |
196 | 196 | dependencyList = new Vector(); |
197 | 197 | className = line.substring(prependLength); |
198 | 198 | dependencyMap.put(className, dependencyList); |
199 | } else { | |
199 | } else if (dependencyList != null) { | |
200 | 200 | dependencyList.addElement(line); |
201 | 201 | } |
202 | 202 | } |
132 | 132 | FileInputStream inFileStream |
133 | 133 | = new FileInputStream(element); |
134 | 134 | |
135 | if (element.getName().endsWith(".class")) { | |
135 | try { | |
136 | if (element.getName().endsWith(".class")) { | |
136 | 137 | |
137 | // create a data input stream from the jar | |
138 | // input stream | |
139 | ClassFile javaClass = new ClassFile(); | |
138 | // create a data input stream from the jar | |
139 | // input stream | |
140 | ClassFile javaClass = new ClassFile(); | |
140 | 141 | |
141 | javaClass.read(inFileStream); | |
142 | javaClass.read(inFileStream); | |
142 | 143 | |
143 | nextElement = javaClass; | |
144 | nextElement = javaClass; | |
145 | } | |
146 | } finally { | |
147 | inFileStream.close(); | |
144 | 148 | } |
145 | 149 | } |
146 | 150 | } else { |
20 | 20 | import java.io.InputStream; |
21 | 21 | import java.util.zip.ZipEntry; |
22 | 22 | import java.util.zip.ZipInputStream; |
23 | ||
24 | import org.apache.tools.ant.BuildException; | |
23 | 25 | |
24 | 26 | /** |
25 | 27 | * A class file iterator which iterates through the contents of a Java jar |
78 | 80 | text += ": " + message; |
79 | 81 | } |
80 | 82 | |
81 | throw new RuntimeException("Problem reading JAR file: " + text); | |
83 | throw new BuildException("Problem reading JAR file: " + text); | |
82 | 84 | } |
83 | 85 | |
84 | 86 | return nextElement; |
42 | 42 | import org.xml.sax.SAXException; |
43 | 43 | |
44 | 44 | import org.apache.tools.ant.util.FileUtils; |
45 | import org.apache.tools.ant.util.StringUtils; | |
45 | 46 | |
46 | 47 | /** |
47 | 48 | * Compiles EJB stubs and skeletons for the iPlanet Application |
309 | 310 | // SAXException or ParserConfigurationException may be thrown |
310 | 311 | System.out.println("An exception was generated while trying to "); |
311 | 312 | System.out.println("create a new SAXParser."); |
312 | e.printStackTrace(); | |
313 | e.printStackTrace(); //NOSONAR | |
313 | 314 | return; |
314 | 315 | } |
315 | 316 | |
442 | 443 | p.destroy(); |
443 | 444 | } catch (IOException e) { |
444 | 445 | log("An IOException has occurred while trying to execute ejbc."); |
445 | e.printStackTrace(); | |
446 | log(StringUtils.getStackTrace(e)); | |
446 | 447 | } catch (InterruptedException e) { |
447 | 448 | // Do nothing |
448 | 449 | } |
726 | 727 | } else { |
727 | 728 | location = (String) fileDtds.get(publicId); |
728 | 729 | if (location != null) { |
729 | inputStream = new FileInputStream(location); | |
730 | // closed when the InputSource is closed | |
731 | inputStream = new FileInputStream(location); //NOSONAR | |
730 | 732 | } |
731 | 733 | } |
732 | 734 | } catch (IOException e) { |
1482 | 1484 | System.out.println(text); |
1483 | 1485 | } |
1484 | 1486 | } catch (IOException e) { |
1485 | e.printStackTrace(); | |
1487 | e.printStackTrace(); //NOSONAR | |
1486 | 1488 | } finally { |
1487 | 1489 | FileUtils.close(reader); |
1488 | 1490 | } |
129 | 129 | final boolean includeImpl, |
130 | 130 | final boolean includeURL) |
131 | 131 | throws BuildException { |
132 | JarFile jarFile = null; | |
132 | 133 | try { |
133 | final JarFile jarFile = new JarFile(file); | |
134 | jarFile = new JarFile(file); | |
134 | 135 | final Extension[] extensions = |
135 | 136 | Extension.getAvailable(jarFile.getManifest()); |
136 | 137 | for (int i = 0; i < extensions.length; i++) { |
139 | 140 | } |
140 | 141 | } catch (final Exception e) { |
141 | 142 | throw new BuildException(e.getMessage(), e); |
143 | } finally { | |
144 | close(jarFile); | |
142 | 145 | } |
143 | 146 | } |
144 | 147 | |
200 | 203 | */ |
201 | 204 | static Manifest getManifest(final File file) |
202 | 205 | throws BuildException { |
206 | JarFile jarFile = null; | |
203 | 207 | try { |
204 | final JarFile jarFile = new JarFile(file); | |
208 | jarFile = new JarFile(file); | |
205 | 209 | Manifest m = jarFile.getManifest(); |
206 | 210 | if (m == null) { |
207 | 211 | throw new BuildException(file + " doesn't have a MANIFEST"); |
209 | 213 | return m; |
210 | 214 | } catch (final IOException ioe) { |
211 | 215 | throw new BuildException(ioe.getMessage(), ioe); |
216 | } finally { | |
217 | close(jarFile); | |
218 | } | |
219 | } | |
220 | ||
221 | private static void close(JarFile device) { | |
222 | if (null != device) { | |
223 | try { | |
224 | device.close(); | |
225 | } catch (IOException e) { | |
226 | //ignore | |
227 | } | |
212 | 228 | } |
213 | 229 | } |
214 | 230 | } |
39 | 39 | import org.apache.tools.ant.util.FileNameMapper; |
40 | 40 | import org.apache.tools.ant.util.FileUtils; |
41 | 41 | import org.apache.tools.ant.util.IdentityMapper; |
42 | import org.apache.tools.ant.util.StringUtils; | |
42 | 43 | |
43 | 44 | import com.sun.media.jai.codec.FileSeekableStream; |
44 | 45 | |
391 | 392 | } |
392 | 393 | |
393 | 394 | } catch (Exception err) { |
394 | err.printStackTrace(); | |
395 | log(StringUtils.getStackTrace(err), Project.MSG_ERR); | |
395 | 396 | throw new BuildException(err.getMessage()); |
396 | 397 | } |
397 | 398 | } |
76 | 76 | protected static final int TASKDEF_TYPE_JJTREE = 2; |
77 | 77 | protected static final int TASKDEF_TYPE_JJDOC = 3; |
78 | 78 | |
79 | protected static final String[] ARCHIVE_LOCATIONS = | |
79 | protected static final String[] ARCHIVE_LOCATIONS = //NOSONAR | |
80 | 80 | new String[] { |
81 | 81 | "JavaCC.zip", |
82 | 82 | "bin/lib/JavaCC.zip", |
84 | 84 | "javacc.jar", // used by jpackage for JavaCC 3.x |
85 | 85 | }; |
86 | 86 | |
87 | protected static final int[] ARCHIVE_LOCATIONS_VS_MAJOR_VERSION = | |
87 | protected static final int[] ARCHIVE_LOCATIONS_VS_MAJOR_VERSION = //NOSONAR | |
88 | 88 | new int[] { |
89 | 89 | 1, |
90 | 90 | 2, |
0 | /* | |
1 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
2 | * contributor license agreements. See the NOTICE file distributed with | |
3 | * this work for additional information regarding copyright ownership. | |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | * (the "License"); you may not use this file except in compliance with | |
6 | * the License. You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | */ | |
17 | package org.apache.tools.ant.taskdefs.optional.javah; | |
18 | ||
19 | import java.io.IOException; | |
20 | ||
21 | import org.apache.tools.ant.BuildException; | |
22 | import org.apache.tools.ant.Project; | |
23 | import org.apache.tools.ant.taskdefs.Execute; | |
24 | import org.apache.tools.ant.taskdefs.LogStreamHandler; | |
25 | import org.apache.tools.ant.taskdefs.optional.Javah; | |
26 | import org.apache.tools.ant.types.Commandline; | |
27 | import org.apache.tools.ant.util.JavaEnvUtils; | |
28 | ||
29 | /** | |
30 | * This implementation runs the javah executable in a separate process. | |
31 | * | |
32 | * @since Ant 1.9.8 | |
33 | */ | |
34 | public class ForkingJavah implements JavahAdapter { | |
35 | ||
36 | /** | |
37 | * the name of this adapter for users to select | |
38 | */ | |
39 | public static final String IMPLEMENTATION_NAME = "forking"; | |
40 | ||
41 | /** | |
42 | * Performs the actual compilation. | |
43 | * @param javah the calling javah task. | |
44 | * @return true if the compilation was successful. | |
45 | * @throws BuildException if there is an error. | |
46 | */ | |
47 | public boolean compile(Javah javah) throws BuildException { | |
48 | Commandline cmd = SunJavah.setupJavahCommand(javah); | |
49 | Project project = javah.getProject(); | |
50 | String executable = JavaEnvUtils.getJdkExecutable("javah"); | |
51 | javah.log("Running " + executable, Project.MSG_VERBOSE); | |
52 | cmd.setExecutable(executable); | |
53 | ||
54 | //set up the args | |
55 | String[] args = cmd.getCommandline(); | |
56 | ||
57 | try { | |
58 | Execute exe = new Execute(new LogStreamHandler(javah, | |
59 | Project.MSG_INFO, | |
60 | Project.MSG_WARN)); | |
61 | exe.setAntRun(project); | |
62 | exe.setWorkingDirectory(project.getBaseDir()); | |
63 | exe.setCommandline(args); | |
64 | exe.execute(); | |
65 | return !exe.isFailure(); | |
66 | } catch (IOException exception) { | |
67 | throw new BuildException("Error running " + executable | |
68 | + " -maybe it is not on the path", exception); | |
69 | } | |
70 | } | |
71 | } |
43 | 43 | return Kaffeh.IMPLEMENTATION_NAME; |
44 | 44 | } else if (JavaEnvUtils.isGij()) { |
45 | 45 | return Gcjh.IMPLEMENTATION_NAME; |
46 | } else if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | |
47 | return ForkingJavah.IMPLEMENTATION_NAME; | |
46 | 48 | } |
47 | 49 | return SunJavah.IMPLEMENTATION_NAME; |
48 | 50 | } |
86 | 88 | } else if ((JavaEnvUtils.isGij() && choice == null) |
87 | 89 | || Gcjh.IMPLEMENTATION_NAME.equals(choice)) { |
88 | 90 | return new Gcjh(); |
91 | } else if ((JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9) | |
92 | && choice == null) | |
93 | || ForkingJavah.IMPLEMENTATION_NAME.equals(choice)) { | |
94 | return new ForkingJavah(); | |
89 | 95 | } else if (SunJavah.IMPLEMENTATION_NAME.equals(choice)) { |
90 | 96 | return new SunJavah(); |
91 | 97 | } else if (choice != null) { |
68 | 68 | return ej.fork(javah) == 0; |
69 | 69 | } |
70 | 70 | |
71 | private Commandline setupJavahCommand(Javah javah) { | |
71 | static Commandline setupJavahCommand(Javah javah) { | |
72 | 72 | Commandline cmd = new Commandline(); |
73 | 73 | |
74 | 74 | if (javah.getDestdir() != null) { |
458 | 458 | PrintWriter pw = null; |
459 | 459 | if (getOutputFile() != null) { |
460 | 460 | try { |
461 | fw = new FileWriter(getOutputFile().getPath()); | |
461 | fw = new FileWriter(getOutputFile().getPath()); //NOSONAR | |
462 | 462 | } catch (IOException e) { |
463 | 463 | String msg = "JDepend Failed when creating the output file: " |
464 | 464 | + e.getMessage(); |
552 | 552 | } |
553 | 553 | |
554 | 554 | jdepend.analyze(); |
555 | if (pw.checkError()) { | |
555 | if (pw != null && pw.checkError()) { | |
556 | 556 | throw new IOException("Encountered an error writing JDepend" |
557 | 557 | + " output"); |
558 | 558 | } |
143 | 143 | * a rational manner to outfile. |
144 | 144 | * @throws Exception on error. |
145 | 145 | */ |
146 | public void link() throws Exception { | |
146 | public void link() throws Exception { //NOSONAR | |
147 | 147 | ZipOutputStream output = new ZipOutputStream(new FileOutputStream(outfile)); |
148 | 148 | |
149 | 149 | if (compression) { |
222 | 222 | return; |
223 | 223 | } |
224 | 224 | ZipFile zipf = new ZipFile(f); |
225 | Enumeration entries = zipf.entries(); | |
226 | ||
227 | while (entries.hasMoreElements()) { | |
228 | ZipEntry inputEntry = (ZipEntry) entries.nextElement(); | |
229 | //Ignore manifest entries. They're bound to cause conflicts between | |
230 | //files that are being merged. User should supply their own | |
231 | //manifest file when doing the merge. | |
232 | String inputEntryName = inputEntry.getName(); | |
233 | int index = inputEntryName.indexOf("META-INF"); | |
234 | ||
235 | if (index < 0) { | |
236 | //META-INF not found in the name of the entry. Go ahead and process it. | |
237 | try { | |
238 | output.putNextEntry(processEntry(zipf, inputEntry)); | |
239 | } catch (ZipException ex) { | |
240 | //If we get here, it could be because we are trying to put a | |
241 | //directory entry that already exists. | |
242 | //For example, we're trying to write "com", but a previous | |
243 | //entry from another mergefile was called "com". | |
244 | //In that case, just ignore the error and go on to the | |
245 | //next entry. | |
246 | String mess = ex.getMessage(); | |
247 | ||
248 | if (mess.indexOf("duplicate") >= 0) { | |
249 | //It was the duplicate entry. | |
250 | continue; | |
251 | } else { | |
252 | // I hate to admit it, but we don't know what happened | |
253 | // here. Throw the Exception. | |
254 | throw ex; | |
225 | try { | |
226 | Enumeration entries = zipf.entries(); | |
227 | ||
228 | while (entries.hasMoreElements()) { | |
229 | ZipEntry inputEntry = (ZipEntry) entries.nextElement(); | |
230 | //Ignore manifest entries. They're bound to cause conflicts between | |
231 | //files that are being merged. User should supply their own | |
232 | //manifest file when doing the merge. | |
233 | String inputEntryName = inputEntry.getName(); | |
234 | int index = inputEntryName.indexOf("META-INF"); | |
235 | ||
236 | if (index < 0) { | |
237 | //META-INF not found in the name of the entry. Go ahead and process it. | |
238 | try { | |
239 | output.putNextEntry(processEntry(zipf, inputEntry)); | |
240 | } catch (ZipException ex) { | |
241 | //If we get here, it could be because we are trying to put a | |
242 | //directory entry that already exists. | |
243 | //For example, we're trying to write "com", but a previous | |
244 | //entry from another mergefile was called "com". | |
245 | //In that case, just ignore the error and go on to the | |
246 | //next entry. | |
247 | String mess = ex.getMessage(); | |
248 | ||
249 | if (mess.indexOf("duplicate") >= 0) { | |
250 | //It was the duplicate entry. | |
251 | continue; | |
252 | } else { | |
253 | // I hate to admit it, but we don't know what happened | |
254 | // here. Throw the Exception. | |
255 | throw ex; | |
256 | } | |
255 | 257 | } |
258 | ||
259 | InputStream in = zipf.getInputStream(inputEntry); | |
260 | int len = buffer.length; | |
261 | int count = -1; | |
262 | ||
263 | while ((count = in.read(buffer, 0, len)) > 0) { | |
264 | output.write(buffer, 0, count); | |
265 | } | |
266 | in.close(); | |
267 | output.closeEntry(); | |
256 | 268 | } |
257 | ||
258 | InputStream in = zipf.getInputStream(inputEntry); | |
259 | int len = buffer.length; | |
260 | int count = -1; | |
261 | ||
262 | while ((count = in.read(buffer, 0, len)) > 0) { | |
263 | output.write(buffer, 0, count); | |
264 | } | |
265 | in.close(); | |
266 | output.closeEntry(); | |
267 | } | |
268 | } | |
269 | zipf.close(); | |
269 | } | |
270 | } finally { | |
271 | zipf.close(); | |
272 | } | |
270 | 273 | } |
271 | 274 | |
272 | 275 |
32 | 32 | /** |
33 | 33 | * this is the list of keywords which can not be used as classnames |
34 | 34 | */ |
35 | public static final String[] keywords = { | |
35 | public static final String[] keywords = { //NOSONAR | |
36 | 36 | "assert", |
37 | 37 | "abstract", "boolean", "break", "byte", |
38 | 38 | "case", "catch", "char", "class", |
28 | 28 | |
29 | 29 | import javax.xml.parsers.DocumentBuilder; |
30 | 30 | import javax.xml.parsers.DocumentBuilderFactory; |
31 | import javax.xml.transform.TransformerFactory; | |
32 | import javax.xml.transform.TransformerFactoryConfigurationError; | |
31 | 33 | |
32 | 34 | import org.apache.tools.ant.BuildException; |
33 | 35 | import org.apache.tools.ant.Project; |
42 | 44 | import org.apache.tools.ant.types.resources.URLResource; |
43 | 45 | import org.apache.tools.ant.util.FileUtils; |
44 | 46 | import org.apache.tools.ant.util.JAXPUtils; |
47 | import org.apache.tools.ant.util.JavaEnvUtils; | |
45 | 48 | import org.w3c.dom.Document; |
46 | 49 | |
47 | 50 | /** |
97 | 100 | private XSLTProcess xsltTask; |
98 | 101 | |
99 | 102 | /** |
103 | * The JAXP factory used for the internal XSLT task. | |
104 | */ | |
105 | private XSLTProcess.Factory xsltFactory; | |
106 | ||
107 | /** | |
100 | 108 | * Instance of a utility class to use for file operations. |
101 | 109 | * |
102 | 110 | * @since Ant 1.7 |
106 | 114 | /** |
107 | 115 | * Used to ensure the uniqueness of a property |
108 | 116 | */ |
109 | private static int counter = 0; | |
117 | private volatile static int counter = 0; | |
110 | 118 | |
111 | 119 | /** the format to use for the report. Must be <tt>FRAMES</tt> or <tt>NOFRAMES</tt> */ |
112 | 120 | protected String format = FRAMES; |
230 | 238 | * @since Ant 1.9.5 |
231 | 239 | */ |
232 | 240 | public XSLTProcess.Factory createFactory() { |
233 | return xsltTask.createFactory(); | |
241 | if (xsltFactory == null) { | |
242 | xsltFactory = xsltTask.createFactory(); | |
243 | } | |
244 | return xsltFactory; | |
234 | 245 | } |
235 | 246 | |
236 | 247 | /** |
250 | 261 | xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); |
251 | 262 | File outputFile = null; |
252 | 263 | if (format.equals(FRAMES)) { |
253 | String tempFileProperty = getClass().getName() + String.valueOf(counter++); | |
264 | String tempFileProperty = getClass().getName() + String.valueOf(counter++); //NOSONAR | |
254 | 265 | File tmp = FILE_UTILS.resolveFile(project.getBaseDir(), project |
255 | 266 | .getProperty("java.io.tmpdir")); |
256 | 267 | tempFileTask.setDestDir(tmp); |
265 | 276 | paramx.setProject(task.getProject()); |
266 | 277 | paramx.setName("output.dir"); |
267 | 278 | paramx.setExpression(toDir.getAbsolutePath()); |
279 | configureForRedirectExtension(); | |
268 | 280 | final long t0 = System.currentTimeMillis(); |
269 | 281 | try { |
270 | 282 | xsltTask.execute(); |
342 | 354 | return JAXPUtils.getSystemId(file); |
343 | 355 | } |
344 | 356 | |
357 | private static final String JDK_INTERNAL_FACTORY = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"; | |
358 | ||
359 | /** | |
360 | * If we end up using the JDK's own TraX factory on Java 9+, then | |
361 | * set the features and attributes necessary to allow redirect | |
362 | * extensions to be used. | |
363 | * @since Ant 1.9.8 | |
364 | */ | |
365 | protected void configureForRedirectExtension() { | |
366 | XSLTProcess.Factory factory = createFactory(); | |
367 | String factoryName = factory.getName(); | |
368 | if (factoryName == null) { | |
369 | try { | |
370 | factoryName = TransformerFactory.newInstance().getClass().getName(); | |
371 | } catch (TransformerFactoryConfigurationError exc) { | |
372 | throw new BuildException(exc); | |
373 | } | |
374 | } | |
375 | if (JDK_INTERNAL_FACTORY.equals(factoryName) | |
376 | && JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | |
377 | factory.addFeature(new XSLTProcess.Factory.Feature("http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions", | |
378 | true)); | |
379 | } | |
380 | } | |
345 | 381 | } |
37 | 37 | import org.apache.tools.ant.Project; |
38 | 38 | import org.apache.tools.ant.ProjectComponent; |
39 | 39 | import org.apache.tools.ant.util.FileUtils; |
40 | import org.apache.tools.ant.util.StringUtils; | |
40 | 41 | |
41 | 42 | /** |
42 | 43 | * <p>Collects all failing test <i>cases</i> and creates a new JUnit test class containing |
96 | 97 | * Location and name of the generated JUnit class. |
97 | 98 | * Lazy instantiated via getLocationName(). |
98 | 99 | */ |
99 | private static String locationName; | |
100 | private String locationName; | |
100 | 101 | |
101 | 102 | /** |
102 | 103 | * Returns the (lazy evaluated) location for the collector class. |
259 | 260 | createClassFooter(); |
260 | 261 | |
261 | 262 | } catch (IOException e) { |
262 | e.printStackTrace(); | |
263 | log(StringUtils.getStackTrace(e)); | |
263 | 264 | } finally { |
264 | 265 | FileUtils.close(writer); |
265 | 266 | } |
20 | 20 | import java.io.BufferedReader; |
21 | 21 | import java.io.BufferedWriter; |
22 | 22 | import java.io.File; |
23 | import java.io.FilenameFilter; | |
23 | 24 | import java.io.FileOutputStream; |
24 | 25 | import java.io.FileReader; |
25 | 26 | import java.io.FileWriter; |
37 | 38 | import java.util.Hashtable; |
38 | 39 | import java.util.Iterator; |
39 | 40 | import java.util.List; |
41 | import java.util.Locale; | |
40 | 42 | import java.util.Map; |
41 | 43 | import java.util.Properties; |
42 | 44 | import java.util.Vector; |
60 | 62 | import org.apache.tools.ant.util.FileUtils; |
61 | 63 | import org.apache.tools.ant.util.LoaderUtils; |
62 | 64 | import org.apache.tools.ant.util.SplitClassLoader; |
65 | import org.apache.tools.ant.util.StringUtils; | |
63 | 66 | |
64 | 67 | /** |
65 | 68 | * Runs JUnit tests. |
510 | 513 | } |
511 | 514 | |
512 | 515 | /** |
516 | * Add a path to the modulepath. | |
517 | * | |
518 | * @return created modulepath. | |
519 | * @since 1.9.8 | |
520 | */ | |
521 | public Path createModulepath() { | |
522 | return getCommandline().createModulepath(getProject()).createPath(); | |
523 | } | |
524 | ||
525 | /** | |
526 | * Add a path to the upgrademodulepath. | |
527 | * | |
528 | * @return created upgrademodulepath. | |
529 | * @since 1.9.8 | |
530 | */ | |
531 | public Path createUpgrademodulepath() { | |
532 | return getCommandline().createUpgrademodulepath(getProject()).createPath(); | |
533 | } | |
534 | ||
535 | /** | |
513 | 536 | * Adds an environment variable; used when forking. |
514 | 537 | * |
515 | 538 | * <p>Will be ignored if we are not forking a new VM.</p> |
678 | 701 | /** |
679 | 702 | * Creates a new JUnitRunner and enables fork of a new Java VM. |
680 | 703 | * |
681 | * @throws Exception under ??? circumstances | |
704 | * @throws Exception never | |
682 | 705 | * @since Ant 1.2 |
683 | 706 | */ |
684 | public JUnitTask() throws Exception { | |
707 | public JUnitTask() throws Exception { //NOSONAR | |
685 | 708 | } |
686 | 709 | |
687 | 710 | /** |
748 | 771 | loader.loadClass("junit.framework.Test"); // sanity check |
749 | 772 | } catch (final ClassNotFoundException e) { |
750 | 773 | throw new BuildException( |
751 | "The <classpath> for <junit> must include junit.jar " | |
774 | "The <classpath> or <modulepath> for <junit> must include junit.jar " | |
752 | 775 | + "if not in Ant's own classpath", |
753 | 776 | e, task.getLocation()); |
754 | 777 | } |
776 | 799 | if (splitJUnit) { |
777 | 800 | final Path path = new Path(getProject()); |
778 | 801 | path.add(antRuntimeClasses); |
779 | final Path extra = getCommandline().getClasspath(); | |
802 | Path extra = getCommandline().getClasspath(); | |
780 | 803 | if (extra != null) { |
781 | 804 | path.add(extra); |
805 | } | |
806 | extra = getCommandline().getModulepath(); | |
807 | if (extra != null && !hasJunit(path)) { | |
808 | path.add(expandModulePath(extra)); | |
782 | 809 | } |
783 | 810 | mirrorLoader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { |
784 | 811 | public Object run() { |
817 | 844 | @Override |
818 | 845 | public void execute() throws BuildException { |
819 | 846 | checkMethodLists(); |
820 | ||
847 | checkModules(); | |
821 | 848 | setupJUnitDelegate(); |
822 | 849 | |
823 | 850 | final List<List> testLists = new ArrayList<List>(); |
1252 | 1279 | checkForkedPath(cmd); |
1253 | 1280 | |
1254 | 1281 | final TestResultHolder result = new TestResultHolder(); |
1282 | boolean success = false; | |
1255 | 1283 | try { |
1256 | 1284 | result.exitCode = execute.execute(); |
1285 | success = true; | |
1257 | 1286 | } catch (final IOException e) { |
1258 | 1287 | throw new BuildException("Process fork failed.", e, getLocation()); |
1259 | 1288 | } finally { |
1270 | 1299 | + " testcase not started or mixing ant versions?"; |
1271 | 1300 | } |
1272 | 1301 | } catch (final Exception e) { |
1273 | e.printStackTrace(); | |
1302 | log(StringUtils.getStackTrace(e), Project.MSG_INFO); | |
1274 | 1303 | // ignored. |
1275 | 1304 | } finally { |
1276 | 1305 | FileUtils.close(br); |
1295 | 1324 | } |
1296 | 1325 | |
1297 | 1326 | if (!FILE_UTILS.tryHardToDelete(propsFile)) { |
1298 | throw new BuildException("Could not delete temporary " | |
1299 | + "properties file '" | |
1300 | + propsFile.getAbsolutePath() + "'."); | |
1327 | String msg = "Could not delete temporary properties file '" | |
1328 | + propsFile.getAbsolutePath() + "'."; | |
1329 | if (success) { | |
1330 | throw new BuildException(msg); //NOSONAR | |
1331 | } else { // don't hide inner exception | |
1332 | log(msg, Project.MSG_ERR); | |
1333 | } | |
1301 | 1334 | } |
1302 | 1335 | } |
1303 | 1336 | |
1697 | 1730 | } |
1698 | 1731 | |
1699 | 1732 | /** |
1733 | * Checks a validity of module specific options. | |
1734 | * @since 1.9.8 | |
1735 | */ | |
1736 | private void checkModules() { | |
1737 | if (hasPath(getCommandline().getModulepath()) || | |
1738 | hasPath(getCommandline().getUpgrademodulepath())) { | |
1739 | for (int i = 0, count = batchTests.size(); i < count; i++) { | |
1740 | if(!batchTests.elementAt(i).getFork()) { | |
1741 | throw new BuildException("The module path requires fork attribute to be set to true."); | |
1742 | } | |
1743 | } | |
1744 | for (int i = 0, count = tests.size(); i < count; i++) { | |
1745 | if (!tests.elementAt(i).getFork()) { | |
1746 | throw new BuildException("The module path requires fork attribute to be set to true."); | |
1747 | } | |
1748 | } | |
1749 | } | |
1750 | } | |
1751 | ||
1752 | /** | |
1753 | * Checks is a junit is on given path. | |
1754 | * @param path the {@link Path} to check | |
1755 | * @return true when given {@link Path} contains junit | |
1756 | * @since 1.9.8 | |
1757 | */ | |
1758 | private boolean hasJunit(final Path path) { | |
1759 | AntClassLoader loader = null; | |
1760 | try { | |
1761 | loader = AntClassLoader.newAntClassLoader( | |
1762 | null, | |
1763 | getProject(), | |
1764 | path, | |
1765 | true); | |
1766 | try { | |
1767 | loader.loadClass("junit.framework.Test"); | |
1768 | return true; | |
1769 | } catch (final Exception ex) { | |
1770 | return false; | |
1771 | } | |
1772 | } finally { | |
1773 | if (loader != null) { | |
1774 | loader.close(); | |
1775 | } | |
1776 | } | |
1777 | } | |
1778 | ||
1779 | /** | |
1780 | * Expands a module path to flat path of jars and root folders usable by classloader. | |
1781 | * @param modulePath to be expanded | |
1782 | * @return the expanded path | |
1783 | * @since 1.9.8 | |
1784 | */ | |
1785 | private Path expandModulePath(Path modulePath) { | |
1786 | final Path expanded = new Path(getProject()); | |
1787 | for (String path : modulePath.list()) { | |
1788 | final File modulePathEntry = getProject().resolveFile(path); | |
1789 | if (modulePathEntry.isDirectory() && !hasModuleInfo(modulePathEntry)) { | |
1790 | final File[] modules = modulePathEntry.listFiles(new FilenameFilter() { | |
1791 | public boolean accept(File dir, String name) { | |
1792 | return name.toLowerCase(Locale.ENGLISH).endsWith(".jar"); | |
1793 | } | |
1794 | }); | |
1795 | if (modules != null) { | |
1796 | for (File module : modules) { | |
1797 | expanded.add(new Path(getProject(), String.format( | |
1798 | "%s%s%s", //NOI18N | |
1799 | path, | |
1800 | File.separator, | |
1801 | module.getName()))); | |
1802 | } | |
1803 | } | |
1804 | } else { | |
1805 | expanded.add(new Path(getProject(), path)); | |
1806 | } | |
1807 | } | |
1808 | return expanded; | |
1809 | } | |
1810 | ||
1811 | /** | |
1700 | 1812 | * return an enumeration listing each test, then each batchtest |
1701 | 1813 | * @return enumeration |
1702 | 1814 | * @since Ant 1.3 |
1891 | 2003 | */ |
1892 | 2004 | private void createClassLoader() { |
1893 | 2005 | final Path userClasspath = getCommandline().getClasspath(); |
1894 | if (userClasspath != null) { | |
2006 | final Path userModulepath = getCommandline().getModulepath(); | |
2007 | if (userClasspath != null || userModulepath != null) { | |
1895 | 2008 | if (reloading || classLoader == null) { |
1896 | 2009 | deleteClassLoader(); |
1897 | final Path classpath = (Path) userClasspath.clone(); | |
2010 | final Path path = new Path(getProject()); | |
2011 | if (userClasspath != null) { | |
2012 | path.add((Path) userClasspath.clone()); | |
2013 | } | |
2014 | if (userModulepath != null && !hasJunit(path)) { | |
2015 | path.add(expandModulePath(userModulepath)); | |
2016 | } | |
1898 | 2017 | if (includeAntRuntime) { |
1899 | 2018 | log("Implicitly adding " + antRuntimeClasses |
1900 | 2019 | + " to CLASSPATH", Project.MSG_VERBOSE); |
1901 | classpath.append(antRuntimeClasses); | |
2020 | path.append(antRuntimeClasses); | |
1902 | 2021 | } |
1903 | classLoader = getProject().createClassLoader(classpath); | |
2022 | classLoader = getProject().createClassLoader(path); | |
1904 | 2023 | if (getClass().getClassLoader() != null |
1905 | 2024 | && getClass().getClassLoader() != Project.class.getClassLoader()) { |
1906 | 2025 | classLoader.setParent(getClass().getClassLoader()); |
2279 | 2398 | w.newLine(); |
2280 | 2399 | s.println(text); |
2281 | 2400 | } |
2401 | ||
2402 | /** | |
2403 | * Checks if a path exists and is non empty. | |
2404 | * @param path to be checked | |
2405 | * @return true if the path is non <code>null</code> and non empty. | |
2406 | * @since 1.9.8 | |
2407 | */ | |
2408 | private static boolean hasPath(final Path path) { | |
2409 | return path != null && path.size() > 0; | |
2410 | } | |
2411 | ||
2412 | /** | |
2413 | * Checks if a given folder is an unpacked module. | |
2414 | * @param root the fodler to be checked | |
2415 | * @return true if the root is an unpacked module | |
2416 | * @since 1.9.8 | |
2417 | */ | |
2418 | private static boolean hasModuleInfo(final File root) { | |
2419 | return new File(root, "module-info.class").exists(); //NOI18N | |
2420 | } | |
2282 | 2421 | } |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | 1024 | } catch (final IOException e) { |
1025 | e.printStackTrace(); | |
1025 | e.printStackTrace(); //NOSONAR | |
1026 | 1026 | } |
1027 | 1027 | } else { |
1028 | 1028 | final JUnitTest t = new JUnitTest(args[0]); |
1239 | 1239 | final String msg = t.getMessage(); |
1240 | 1240 | final AssertionFailedError failure = msg != null |
1241 | 1241 | ? new AssertionFailedError(msg) : new AssertionFailedError(); |
1242 | failure.initCause(t.getCause()); | |
1242 | 1243 | failure.setStackTrace(t.getStackTrace()); |
1243 | 1244 | testListener.addFailure(test, failure); |
1244 | 1245 | } else { |
+5
-1
116 | 116 | * @throws BuildException if unable to write the output |
117 | 117 | */ |
118 | 118 | public void endTestSuite(JUnitTest suite) throws BuildException { |
119 | boolean success = false; | |
119 | 120 | try { |
120 | 121 | StringBuffer sb = new StringBuffer("Tests run: "); |
121 | 122 | sb.append(suite.runCount()); |
157 | 158 | throw new BuildException("Unable to write output", ioex); |
158 | 159 | } |
159 | 160 | } |
161 | success = true; | |
160 | 162 | } finally { |
161 | 163 | if (out != null) { |
162 | 164 | try { |
163 | 165 | wri.close(); |
164 | 166 | } catch (IOException ioex) { |
165 | throw new BuildException("Unable to flush output", ioex); | |
167 | if (success) { | |
168 | throw new BuildException("Unable to flush output", ioex); //NOSONAR | |
169 | } | |
166 | 170 | } finally { |
167 | 171 | if (out != System.out && out != System.err) { |
168 | 172 | FileUtils.close(out); |
+104
-0
0 | /* | |
1 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
2 | * contributor license agreements. See the NOTICE file distributed with | |
3 | * this work for additional information regarding copyright ownership. | |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | * (the "License"); you may not use this file except in compliance with | |
6 | * the License. You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | */ | |
17 | package org.apache.tools.ant.taskdefs.optional.native2ascii; | |
18 | ||
19 | import java.io.BufferedReader; | |
20 | import java.io.BufferedWriter; | |
21 | import java.io.File; | |
22 | import java.io.FileInputStream; | |
23 | import java.io.FileOutputStream; | |
24 | import java.io.FileReader; | |
25 | import java.io.FileWriter; | |
26 | import java.io.IOException; | |
27 | import java.io.InputStreamReader; | |
28 | import java.io.OutputStreamWriter; | |
29 | import java.io.Writer; | |
30 | ||
31 | import org.apache.tools.ant.BuildException; | |
32 | import org.apache.tools.ant.taskdefs.optional.Native2Ascii; | |
33 | import org.apache.tools.ant.util.FileUtils; | |
34 | import org.apache.tools.ant.util.Native2AsciiUtils; | |
35 | import org.apache.tools.ant.util.StringUtils; | |
36 | ||
37 | /** | |
38 | * Encapsulates the built-in Native2Ascii implementation. | |
39 | * | |
40 | * @since Ant 1.9.8 | |
41 | */ | |
42 | public class BuiltinNative2Ascii implements Native2AsciiAdapter { | |
43 | ||
44 | static final String IMPLEMENTATION_NAME = "builtin"; | |
45 | ||
46 | public final boolean convert(Native2Ascii args, File srcFile, | |
47 | File destFile) throws BuildException { | |
48 | boolean reverse = args.getReverse(); | |
49 | String encoding = args.getEncoding(); | |
50 | BufferedReader input = null; | |
51 | try { | |
52 | input = getReader(srcFile, encoding, reverse); | |
53 | try { | |
54 | Writer output = getWriter(destFile, encoding, reverse); | |
55 | try { | |
56 | translate(input, output, reverse); | |
57 | } finally { | |
58 | FileUtils.close(output); | |
59 | } | |
60 | } finally { | |
61 | FileUtils.close(input); | |
62 | } | |
63 | return true; | |
64 | } catch (IOException ex) { | |
65 | throw new BuildException("Exception trying to translate data", ex); | |
66 | } | |
67 | } | |
68 | ||
69 | private BufferedReader getReader(File srcFile, String encoding, | |
70 | boolean reverse) throws IOException { | |
71 | if (!reverse && encoding != null) { | |
72 | return new BufferedReader(new InputStreamReader( | |
73 | new FileInputStream(srcFile), encoding)); | |
74 | } | |
75 | return new BufferedReader(new FileReader(srcFile)); | |
76 | } | |
77 | ||
78 | private Writer getWriter(File destFile, String encoding, | |
79 | boolean reverse) throws IOException { | |
80 | if (!reverse) { | |
81 | encoding = "ASCII"; | |
82 | } | |
83 | if (encoding != null) { | |
84 | return new BufferedWriter( | |
85 | new OutputStreamWriter(new FileOutputStream(destFile), | |
86 | encoding)); | |
87 | } | |
88 | return new BufferedWriter(new FileWriter(destFile)); | |
89 | } | |
90 | ||
91 | private void translate(BufferedReader input, Writer output, | |
92 | boolean reverse) throws IOException { | |
93 | String line = null; | |
94 | while ((line = input.readLine()) != null) { | |
95 | if (!reverse) { | |
96 | output.write(Native2AsciiUtils.native2ascii(line)); | |
97 | } else { | |
98 | output.write(Native2AsciiUtils.ascii2native(line)); | |
99 | } | |
100 | output.write(StringUtils.LINE_SEP); | |
101 | } | |
102 | } | |
103 | } |
+22
-7
39 | 39 | * vendor |
40 | 40 | */ |
41 | 41 | public static String getDefault() { |
42 | if (JavaEnvUtils.isKaffe() || JavaEnvUtils.isClasspathBased()) { | |
42 | if (shouldUseKaffee()) { | |
43 | 43 | return KaffeNative2Ascii.IMPLEMENTATION_NAME; |
44 | 44 | } |
45 | return SunNative2Ascii.IMPLEMENTATION_NAME; | |
45 | if (shouldUseSun()) { | |
46 | return SunNative2Ascii.IMPLEMENTATION_NAME; | |
47 | } | |
48 | return BuiltinNative2Ascii.IMPLEMENTATION_NAME; | |
46 | 49 | } |
47 | 50 | |
48 | 51 | /** |
78 | 81 | ProjectComponent log, |
79 | 82 | Path classpath) |
80 | 83 | throws BuildException { |
81 | if (((JavaEnvUtils.isKaffe() || JavaEnvUtils.isClasspathBased()) && choice == null) | |
84 | if ((shouldUseKaffee() && choice == null) | |
82 | 85 | || KaffeNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) { |
83 | 86 | return new KaffeNative2Ascii(); |
84 | } else if (SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) { | |
87 | } else if ((shouldUseSun() && choice == null) | |
88 | || SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) { | |
85 | 89 | return new SunNative2Ascii(); |
90 | } else if (BuiltinNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) { | |
91 | return new BuiltinNative2Ascii(); | |
86 | 92 | } else if (choice != null) { |
87 | 93 | return resolveClassName(choice, |
88 | 94 | // Memory leak in line below |
90 | 96 | .createClassLoader(classpath)); |
91 | 97 | } |
92 | 98 | |
93 | // This default has been good enough until Ant 1.6.3, so stick | |
94 | // with it | |
95 | return new SunNative2Ascii(); | |
99 | return new BuiltinNative2Ascii(); | |
96 | 100 | } |
97 | 101 | |
98 | 102 | /** |
112 | 116 | Native2AsciiAdapterFactory.class.getClassLoader(), |
113 | 117 | Native2AsciiAdapter.class); |
114 | 118 | } |
119 | ||
120 | private static final boolean shouldUseKaffee() { | |
121 | return JavaEnvUtils.isKaffe() || JavaEnvUtils.isClasspathBased(); | |
122 | } | |
123 | ||
124 | private static final boolean shouldUseSun() { | |
125 | return JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5) | |
126 | || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6) | |
127 | || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7) | |
128 | || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8); | |
129 | } | |
115 | 130 | } |
143 | 143 | private String initialSiteCommand = null; |
144 | 144 | private boolean enableRemoteVerification = true; |
145 | 145 | |
146 | protected static final String[] ACTION_STRS = { | |
146 | protected static final String[] ACTION_STRS = { //NOSONAR | |
147 | 147 | "sending", |
148 | 148 | "getting", |
149 | 149 | "deleting", |
154 | 154 | "site" |
155 | 155 | }; |
156 | 156 | |
157 | protected static final String[] COMPLETED_ACTION_STRS = { | |
157 | protected static final String[] COMPLETED_ACTION_STRS = { //NOSONAR | |
158 | 158 | "sent", |
159 | 159 | "retrieved", |
160 | 160 | "deleted", |
165 | 165 | "site command executed" |
166 | 166 | }; |
167 | 167 | |
168 | protected static final String[] ACTION_TARGET_STRS = { | |
168 | protected static final String[] ACTION_TARGET_STRS = { //NOSONAR | |
169 | 169 | "files", |
170 | 170 | "files", |
171 | 171 | "files", |
746 | 746 | try { |
747 | 747 | ftp.changeWorkingDirectory(directory); |
748 | 748 | } catch (IOException ioe) { |
749 | throw new BuildException(ioe, getLocation()); | |
749 | throw new BuildException(ioe, getLocation()); //NOSONAR | |
750 | 750 | } |
751 | 751 | } |
752 | 752 | getProject().log("remote system is case sensitive : " + remoteSystemCaseSensitive, |
1154 | 1154 | Project.MSG_ERR); |
1155 | 1155 | } finally { |
1156 | 1156 | if (!comeback) { |
1157 | throw new BuildException("could not cd back to " + dir | |
1157 | throw new BuildException("could not cd back to " + dir //NOSONAR | |
1158 | 1158 | + " while checking a symlink"); |
1159 | 1159 | } |
1160 | 1160 | } |
107 | 107 | private ClassLoader mirrorLoader; |
108 | 108 | private FTPTaskMirror delegate = null; |
109 | 109 | |
110 | public static final String[] ACTION_STRS = { | |
110 | public static final String[] ACTION_STRS = { //NOSONAR | |
111 | 111 | "sending", |
112 | 112 | "getting", |
113 | 113 | "deleting", |
118 | 118 | "site" |
119 | 119 | }; |
120 | 120 | |
121 | public static final String[] COMPLETED_ACTION_STRS = { | |
121 | public static final String[] COMPLETED_ACTION_STRS = { //NOSONAR | |
122 | 122 | "sent", |
123 | 123 | "retrieved", |
124 | 124 | "deleted", |
129 | 129 | "site command executed" |
130 | 130 | }; |
131 | 131 | |
132 | public static final String[] ACTION_TARGET_STRS = { | |
132 | public static final String[] ACTION_TARGET_STRS = { //NOSONAR | |
133 | 133 | "files", |
134 | 134 | "files", |
135 | 135 | "files", |
647 | 647 | try { |
648 | 648 | ftp.changeWorkingDirectory(directory); |
649 | 649 | } catch (IOException ioe) { |
650 | throw new BuildException(ioe, task.getLocation()); | |
650 | throw new BuildException(ioe, task.getLocation()); //NOSONAR | |
651 | 651 | } |
652 | 652 | } |
653 | 653 | task.log("remote system is case sensitive : " |
1060 | 1060 | Project.MSG_ERR); |
1061 | 1061 | } finally { |
1062 | 1062 | if (!comeback) { |
1063 | throw new BuildException("could not cd back to " + dir | |
1063 | throw new BuildException("could not cd back to " + dir //NOSONAR | |
1064 | 1064 | + " while checking a symlink"); |
1065 | 1065 | } |
1066 | 1066 | } |
353 | 353 | |
354 | 354 | /** Create the telnet client object */ |
355 | 355 | AntRExecClient rexec = null; |
356 | boolean success = false; | |
356 | 357 | try { |
357 | 358 | rexec = new AntRExecClient(); |
358 | 359 | try { |
360 | 361 | } catch (IOException e) { |
361 | 362 | throw new BuildException("Can't connect to " + server); |
362 | 363 | } |
363 | if (userid != null && password != null && command != null | |
364 | if (userid != null && password != null && command != null //NOSONAR | |
364 | 365 | && rexecTasks.size() == 0) { |
365 | 366 | // simple one-shot execution |
366 | 367 | rexec.rexec(userid, password, command); |
371 | 372 | |
372 | 373 | /** Keep reading input stream until end of it or time-out */ |
373 | 374 | rexec.waitForEOF(defaultTimeout); |
375 | success = true; | |
374 | 376 | } catch (IOException e) { |
375 | 377 | throw new BuildException("Error r-executing command", e); |
376 | 378 | } finally { |
378 | 380 | try { |
379 | 381 | rexec.disconnect(); |
380 | 382 | } catch (IOException e) { |
381 | throw new BuildException("Error disconnecting from " | |
382 | + server); | |
383 | String msg = "Error disconnecting from " + server; | |
384 | if (success) { | |
385 | throw new BuildException(msg); //NOSONAR | |
386 | } else { // don't hide inner exception | |
387 | log(msg, Project.MSG_ERR); | |
388 | } | |
383 | 389 | } |
384 | 390 | } |
385 | 391 | } |
97 | 97 | |
98 | 98 | /** Create the telnet client object */ |
99 | 99 | AntTelnetClient telnet = null; |
100 | boolean success = false; | |
100 | 101 | try { |
101 | 102 | telnet = new AntTelnetClient(); |
102 | 103 | try { |
105 | 106 | throw new BuildException("Can't connect to " + server); |
106 | 107 | } |
107 | 108 | /** Login if userid and password were specified */ |
108 | if (userid != null && password != null) { | |
109 | if (userid != null && password != null) { //NOSONAR | |
109 | 110 | login(telnet); |
110 | 111 | } |
111 | 112 | /** Process each sub command */ |
117 | 118 | } |
118 | 119 | task.execute(telnet); |
119 | 120 | } |
121 | success = true; | |
120 | 122 | } finally { |
121 | 123 | if (telnet != null && telnet.isConnected()) { |
122 | 124 | try { |
123 | 125 | telnet.disconnect(); |
124 | 126 | } catch (IOException e) { |
125 | throw new BuildException("Error disconnecting from " | |
126 | + server); | |
127 | String msg = "Error disconnecting from " + server; | |
128 | if (success) { | |
129 | throw new BuildException(msg); //NOSONAR | |
130 | } else { // don't hide inner exception | |
131 | log(msg, Project.MSG_ERR); | |
132 | } | |
127 | 133 | } |
128 | 134 | } |
129 | 135 | } |
40 | 40 | |
41 | 41 | private String sosCmdDir = null; |
42 | 42 | private String sosUsername = null; |
43 | private String sosPassword = ""; | |
43 | private String sosPassword = null; | |
44 | 44 | private String projectPath = null; |
45 | 45 | private String vssServerPath = null; |
46 | 46 | private String sosServerPath = null; |
268 | 268 | * @return empty string if it wasn't set. |
269 | 269 | */ |
270 | 270 | protected String getPassword() { |
271 | return sosPassword; | |
271 | return sosPassword == null ? "" : sosPassword; | |
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
52 | 52 | /** The username option */ |
53 | 53 | String FLAG_USERNAME = "-name"; |
54 | 54 | /** The password option */ |
55 | String FLAG_PASSWORD = "-password"; | |
55 | String FLAG_PASSWORD = "-password"; //NOSONAR | |
56 | 56 | /** The log option */ |
57 | 57 | String FLAG_COMMENT = "-log"; |
58 | 58 | /** The workdir option */ |
108 | 108 | project.log("Audio format is not yet supported: " |
109 | 109 | + uafe.getMessage()); |
110 | 110 | } catch (IOException ioe) { |
111 | ioe.printStackTrace(); | |
111 | ioe.printStackTrace(); //NOSONAR | |
112 | 112 | } |
113 | 113 | |
114 | 114 | if (audioInputStream != null) { |
116 | 116 | DataLine.Info info = new DataLine.Info(Clip.class, format, |
117 | 117 | AudioSystem.NOT_SPECIFIED); |
118 | 118 | try { |
119 | audioClip = (Clip) AudioSystem.getLine(info); | |
120 | audioClip.addLineListener(this); | |
121 | audioClip.open(audioInputStream); | |
122 | } catch (LineUnavailableException e) { | |
123 | project.log("The sound device is currently unavailable"); | |
124 | return; | |
125 | } catch (IOException e) { | |
126 | e.printStackTrace(); | |
119 | try { | |
120 | audioClip = (Clip) AudioSystem.getLine(info); | |
121 | audioClip.addLineListener(this); | |
122 | audioClip.open(audioInputStream); | |
123 | } catch (LineUnavailableException e) { | |
124 | project.log("The sound device is currently unavailable"); | |
125 | return; | |
126 | } catch (IOException e) { | |
127 | e.printStackTrace(); //NOSONAR | |
128 | } | |
129 | ||
130 | if (duration != null) { | |
131 | playClip(audioClip, duration.longValue()); | |
132 | } else { | |
133 | playClip(audioClip, loops); | |
134 | } | |
135 | if (audioClip != null) { | |
136 | audioClip.drain(); | |
137 | } | |
138 | } finally { | |
139 | if (audioClip != null) { | |
140 | audioClip.close(); | |
141 | } | |
127 | 142 | } |
128 | ||
129 | if (duration != null) { | |
130 | playClip(audioClip, duration.longValue()); | |
131 | } else { | |
132 | playClip(audioClip, loops); | |
133 | } | |
134 | audioClip.drain(); | |
135 | audioClip.close(); | |
136 | 143 | } else { |
137 | 144 | project.log("Can't get data from file " + file.getName()); |
138 | 145 | } |
52 | 52 | private String progressRegExp = null; |
53 | 53 | private String displayText = null; |
54 | 54 | |
55 | // class instance so we'll never show two splash screens at the same time | |
55 | 56 | private static SplashScreen splash = null; |
56 | 57 | |
57 | 58 | /** |
162 | 163 | splash.setVisible(false); |
163 | 164 | getProject().removeBuildListener(splash); |
164 | 165 | splash.dispose(); |
165 | splash = null; | |
166 | splash = null; //NOSONAR | |
166 | 167 | } |
167 | 168 | |
168 | 169 | log("Creating new SplashScreen", Project.MSG_VERBOSE); |
247 | 248 | |
248 | 249 | try { |
249 | 250 | ImageIcon img = new ImageIcon(bout.toByteArray()); |
250 | splash = new SplashScreen(img, progressRegExp, displayText); | |
251 | splash = new SplashScreen(img, progressRegExp, displayText); //NOSONAR | |
251 | 252 | success = true; |
252 | 253 | } catch (Throwable e) { |
253 | 254 | logHeadless(e); |
261 | 262 | // swallow if there was an error before so that |
262 | 263 | // original error will be passed up |
263 | 264 | if (success) { |
264 | throw new BuildException(ioe); | |
265 | throw new BuildException(ioe); //NOSONAR | |
265 | 266 | } |
266 | 267 | } |
267 | 268 | } |
268 | 269 | } else { |
269 | 270 | try { |
270 | splash = new SplashScreen("Image Unavailable.", progressRegExp, | |
271 | splash = new SplashScreen("Image Unavailable.", progressRegExp, //NOSONAR | |
271 | 272 | displayText); |
272 | 273 | success = true; |
273 | 274 | } catch (Throwable e) { |
39 | 39 | |
40 | 40 | private final Session session; |
41 | 41 | private final boolean verbose; |
42 | private final boolean compressed; | |
42 | 43 | private LogListener listener = new LogListener() { |
43 | 44 | public void log(final String message) { |
44 | 45 | // do nothing; |
60 | 61 | * @since Ant 1.6.2 |
61 | 62 | */ |
62 | 63 | public AbstractSshMessage(final boolean verbose, final Session session) { |
64 | this(verbose, false, session); | |
65 | } | |
66 | ||
67 | /** | |
68 | * Constructor for AbstractSshMessage | |
69 | * @param verbose if true do verbose logging | |
70 | * @param compression if true use compression | |
71 | * @param session the ssh session to use | |
72 | * @since Ant 1.9.8 | |
73 | */ | |
74 | public AbstractSshMessage(boolean verbose, boolean compressed, Session session) { | |
63 | 75 | this.verbose = verbose; |
76 | this.compressed = compressed; | |
64 | 77 | this.session = session; |
65 | 78 | } |
66 | 79 | |
188 | 201 | */ |
189 | 202 | protected final boolean getVerbose() { |
190 | 203 | return verbose; |
204 | } | |
205 | ||
206 | /** | |
207 | * Is the compressed attribute set. | |
208 | * @return true if the compressed attribute is set | |
209 | * @since Ant 1.9.8 | |
210 | */ | |
211 | protected final boolean getCompressed() { | |
212 | return compressed; | |
191 | 213 | } |
192 | 214 | |
193 | 215 | /** |
53 | 53 | private String fromUri; |
54 | 54 | private String toUri; |
55 | 55 | private boolean preserveLastModified = false; |
56 | private boolean compressed = false; | |
56 | 57 | private List<ResourceCollection> rcs = null; |
57 | 58 | private boolean isFromRemote, isToRemote; |
58 | 59 | private boolean isSftp = false; |
109 | 110 | setFromUri(aFromUri); |
110 | 111 | this.isFromRemote = true; |
111 | 112 | } |
113 | ||
114 | /** | |
115 | * Sets flag to determine if compression should | |
116 | * be used for the copy. | |
117 | * @since Ant 1.9.8 | |
118 | */ | |
119 | public void setCompressed(boolean compressed) { | |
120 | this.compressed = compressed; | |
121 | } | |
112 | 122 | |
113 | 123 | /** |
114 | 124 | * Similar to {@link #setTodir setTodir} but explicitly states |
256 | 266 | } else { |
257 | 267 | upload(fromUri, toUri); |
258 | 268 | } |
259 | } else if (isFromRemote && isToRemote) { | |
269 | } else if (isFromRemote && isToRemote) { //NOSONAR | |
260 | 270 | throw new BuildException( |
261 | 271 | "Copying from a remote server to a remote server is not supported."); |
262 | 272 | } else { |
294 | 304 | new ScpFromMessage(getVerbose(), session, file, |
295 | 305 | getProject().resolveFile(toPath), |
296 | 306 | fromSshUri.endsWith("*"), |
297 | preserveLastModified); | |
307 | preserveLastModified, | |
308 | compressed); | |
298 | 309 | } else { |
299 | 310 | message = |
300 | 311 | new ScpFromMessageBySftp(getVerbose(), session, file, |
338 | 349 | session = openSession(); |
339 | 350 | ScpToMessage message = null; |
340 | 351 | if (!isSftp) { |
341 | message = new ScpToMessage(getVerbose(), session, | |
352 | message = new ScpToMessage(getVerbose(), compressed, session, | |
342 | 353 | list, file, preserveLastModified); |
343 | 354 | } else { |
344 | 355 | message = new ScpToMessageBySftp(getVerbose(), session, |
370 | 381 | ScpToMessage message = null; |
371 | 382 | if (!isSftp) { |
372 | 383 | message = |
373 | new ScpToMessage(getVerbose(), session, | |
384 | new ScpToMessage(getVerbose(), compressed, session, | |
374 | 385 | getProject().resolveFile(fromPath), file, |
375 | 386 | preserveLastModified); |
376 | 387 | } else { |
114 | 114 | final File aLocalFile, |
115 | 115 | final boolean recursive, |
116 | 116 | final boolean preserveLastModified) { |
117 | super(verbose, session); | |
117 | this(verbose, session, aRemoteFile, aLocalFile, recursive, preserveLastModified, false); | |
118 | } | |
119 | ||
120 | /** | |
121 | * Constructor for ScpFromMessage. | |
122 | * @param verbose if true log extra information | |
123 | * @param session the Scp session to use | |
124 | * @param aRemoteFile the remote file name | |
125 | * @param aLocalFile the local file | |
126 | * @param recursive if true use recursion (-r option to scp) | |
127 | * @param preserveLastModified whether to preserve file | |
128 | * @param compressed if true use compression (-C option to scp) | |
129 | * modification times | |
130 | * @since Ant 1.9.8 | |
131 | */ | |
132 | public ScpFromMessage(boolean verbose, | |
133 | Session session, | |
134 | String aRemoteFile, | |
135 | File aLocalFile, | |
136 | boolean recursive, | |
137 | boolean preserveLastModified, | |
138 | boolean compressed) { | |
139 | super(verbose, compressed, session); | |
118 | 140 | this.remoteFile = aRemoteFile; |
119 | 141 | this.localFile = aLocalFile; |
120 | 142 | this.isRecursive = recursive; |
130 | 152 | String command = "scp -f "; |
131 | 153 | if (isRecursive) { |
132 | 154 | command += "-r "; |
155 | } | |
156 | if (getCompressed()) { | |
157 | command += "-C "; | |
133 | 158 | } |
134 | 159 | command += remoteFile; |
135 | 160 | final Channel channel = openExecChannel(command); |
60 | 60 | * @since Ant 1.7 |
61 | 61 | */ |
62 | 62 | public ScpToMessage(final boolean verbose, final Session session) { |
63 | super(verbose, session); | |
63 | this(verbose, false, session); | |
64 | } | |
65 | ||
66 | /** | |
67 | * Constructor for ScpToMessage | |
68 | * @param verbose if true do verbose logging | |
69 | * @param compressed if true use compression | |
70 | * @param session the ssh session to use | |
71 | * @since Ant 1.9.8 | |
72 | */ | |
73 | public ScpToMessage(final boolean verbose, boolean compressed, final Session session) { | |
74 | super(verbose, compressed, session); | |
64 | 75 | } |
65 | 76 | |
66 | 77 | /** |
77 | 88 | final File aLocalFile, |
78 | 89 | final String aRemotePath, |
79 | 90 | final boolean preserveLastModified) { |
80 | this(verbose, session, aRemotePath); | |
91 | this(verbose, false, session, aLocalFile, aRemotePath, preserveLastModified); | |
92 | } | |
93 | ||
94 | /** | |
95 | * Constructor for a local file to remote. | |
96 | * @param verbose if true do verbose logging | |
97 | * @param compressed if true use compression | |
98 | * @param session the scp session to use | |
99 | * @param aLocalFile the local file | |
100 | * @param aRemotePath the remote path | |
101 | * @param preserveLastModified whether to preserve the last modified timestamps | |
102 | * @since Ant 1.9.8 | |
103 | */ | |
104 | public ScpToMessage(final boolean verbose, | |
105 | final boolean compressed, | |
106 | final Session session, | |
107 | final File aLocalFile, | |
108 | final String aRemotePath, | |
109 | final boolean preserveLastModified) { | |
110 | this(verbose, compressed, session, aRemotePath); | |
81 | 111 | this.localFile = aLocalFile; |
82 | 112 | this.preserveLastModified = preserveLastModified; |
83 | 113 | } |
96 | 126 | final List aDirectoryList, |
97 | 127 | final String aRemotePath, |
98 | 128 | final boolean preserveLastModified) { |
99 | this(verbose, session, aRemotePath); | |
129 | this(verbose, false, session, aDirectoryList, aRemotePath, preserveLastModified); | |
130 | } | |
131 | ||
132 | /** | |
133 | * Constructor for a local directories to remote. | |
134 | * @param verbose if true do verbose logging | |
135 | * @param compressed whether to use compression | |
136 | * @param session the scp session to use | |
137 | * @param aDirectoryList a list of directories | |
138 | * @param aRemotePath the remote path | |
139 | * @param preserveLastModified whether to preserve the last modified timestamps | |
140 | * @since Ant 1.9.8 | |
141 | */ | |
142 | public ScpToMessage(final boolean verbose, | |
143 | final boolean compressed, | |
144 | final Session session, | |
145 | final List aDirectoryList, | |
146 | final String aRemotePath, | |
147 | final boolean preserveLastModified) { | |
148 | this(verbose, compressed, session, aRemotePath); | |
100 | 149 | this.directoryList = aDirectoryList; |
101 | 150 | this.preserveLastModified = preserveLastModified; |
102 | 151 | } |
141 | 190 | private ScpToMessage(final boolean verbose, |
142 | 191 | final Session session, |
143 | 192 | final String aRemotePath) { |
144 | super(verbose, session); | |
193 | this(verbose, false, session, aRemotePath); | |
194 | } | |
195 | ||
196 | /** | |
197 | * Constructor for ScpToMessage. | |
198 | * @param verbose if true do verbose logging | |
199 | * @param compressed if true use compression | |
200 | * @param session the scp session to use | |
201 | * @param aRemotePath the remote path | |
202 | * @since Ant 1.9.8 | |
203 | */ | |
204 | private ScpToMessage(final boolean verbose, | |
205 | final boolean compressed, | |
206 | final Session session, | |
207 | final String aRemotePath) { | |
208 | super(verbose, compressed, session); | |
145 | 209 | this.remotePath = aRemotePath; |
146 | 210 | } |
147 | 211 | |
186 | 250 | } |
187 | 251 | |
188 | 252 | private void doSingleTransfer() throws IOException, JSchException { |
189 | final String cmd = "scp -t " + (getPreserveLastModified() ? "-p " : "") + remotePath; | |
253 | StringBuilder sb = new StringBuilder("scp -t "); | |
254 | if (getPreserveLastModified()) { | |
255 | sb.append("-p "); | |
256 | } | |
257 | if (getCompressed()) { | |
258 | sb.append("-C "); | |
259 | } | |
260 | sb.append(remotePath); | |
261 | final String cmd = sb.toString(); | |
190 | 262 | final Channel channel = openExecChannel(cmd); |
191 | 263 | try { |
192 | 264 | |
205 | 277 | } |
206 | 278 | |
207 | 279 | private void doMultipleTransfer() throws IOException, JSchException { |
208 | final Channel channel = | |
209 | openExecChannel("scp -r -d -t " | |
210 | + (getPreserveLastModified() ? "-p " : "") | |
211 | + remotePath); | |
280 | StringBuilder sb = new StringBuilder("scp -r -d -t "); | |
281 | if (getPreserveLastModified()) { | |
282 | sb.append("-p "); | |
283 | } | |
284 | if (getCompressed()) { | |
285 | sb.append("-C "); | |
286 | } | |
287 | sb.append(remotePath); | |
288 | final Channel channel = openExecChannel(sb.toString()); | |
212 | 289 | try { |
213 | 290 | final OutputStream out = channel.getOutputStream(); |
214 | 291 | final InputStream in = channel.getInputStream(); |
377 | 377 | * |
378 | 378 | * @param path A string containing the path of the symlink to delete. |
379 | 379 | * |
380 | * @throws FileNotFoundException When the path results in a | |
381 | * <code>File</code> that doesn't exist. | |
382 | 380 | * @throws IOException If calls to <code>File.rename</code> |
383 | 381 | * or <code>File.delete</code> fail. |
384 | 382 | * @deprecated use |
387 | 385 | */ |
388 | 386 | @Deprecated |
389 | 387 | public static void deleteSymlink(String path) |
390 | throws IOException, FileNotFoundException { | |
388 | throws IOException { | |
391 | 389 | SYMLINK_UTILS.deleteSymbolicLink(new File(path), null); |
392 | 390 | } |
393 | 391 |
486 | 486 | //make sure m_LocalDir exists, create it if it doesn't |
487 | 487 | File dir = getProject().resolveFile(localPath); |
488 | 488 | if (!dir.exists()) { |
489 | boolean done = dir.mkdirs(); | |
489 | boolean done = dir.mkdirs() || dir.exists(); | |
490 | 490 | if (!done) { |
491 | 491 | String msg = "Directory " + localPath + " creation was not " |
492 | 492 | + "successful for an unknown reason"; |
23 | 23 | import java.util.Random; |
24 | 24 | import java.util.Vector; |
25 | 25 | |
26 | import org.apache.tools.ant.BuildException; | |
26 | 27 | import org.apache.tools.ant.Project; |
27 | 28 | import org.apache.tools.ant.taskdefs.Rmic; |
28 | 29 | import org.apache.tools.ant.types.Commandline; |
29 | 30 | import org.apache.tools.ant.types.Path; |
30 | 31 | import org.apache.tools.ant.util.FileNameMapper; |
32 | import org.apache.tools.ant.util.JavaEnvUtils; | |
31 | 33 | import org.apache.tools.ant.util.StringUtils; |
32 | 34 | |
33 | 35 | /** |
246 | 248 | String[] compilerArgs = attributes.getCurrentCompilerArgs(); |
247 | 249 | compilerArgs = preprocessCompilerArgs(compilerArgs); |
248 | 250 | cmd.addArguments(compilerArgs); |
251 | ||
252 | verifyArguments(cmd); | |
249 | 253 | |
250 | 254 | logAndAddFilesToCompile(cmd); |
251 | 255 | return cmd; |
346 | 350 | } |
347 | 351 | |
348 | 352 | attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE); |
353 | } | |
354 | ||
355 | private void verifyArguments(Commandline cmd) { | |
356 | if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | |
357 | for (String arg : cmd.getArguments()) { | |
358 | if ("-Xnew".equals(arg)) { | |
359 | throw new BuildException("JDK9 has removed support for -Xnew"); | |
360 | } | |
361 | } | |
362 | } | |
349 | 363 | } |
350 | 364 | |
351 | 365 | /** |
66 | 66 | } |
67 | 67 | |
68 | 68 | cmd.setExecutable(c.getName()); |
69 | if (!c.getName().equals(RMIC_CLASSNAMES[RMIC_CLASSNAMES.length - 1])) { | |
69 | if (!c.getName().equals(RMIC_CLASSNAMES[RMIC_CLASSNAMES.length - 1])) { //NOSONAR | |
70 | 70 | // only supported since Kaffe 1.1.2 |
71 | 71 | cmd.createArgument().setValue("-verbose"); |
72 | 72 | getRmic().log(Commandline.describeCommand(cmd)); |
21 | 21 | import org.apache.tools.ant.Task; |
22 | 22 | import org.apache.tools.ant.types.Path; |
23 | 23 | import org.apache.tools.ant.util.ClasspathUtils; |
24 | import org.apache.tools.ant.util.JavaEnvUtils; | |
24 | 25 | |
25 | 26 | /** |
26 | 27 | * Creates the necessary rmic adapter, given basic criteria. |
94 | 95 | throws BuildException { |
95 | 96 | //handle default specially by choosing the sun or kaffe compiler |
96 | 97 | if (DEFAULT_COMPILER.equalsIgnoreCase(rmicType) || rmicType.length() == 0) { |
97 | rmicType = KaffeRmic.isAvailable() | |
98 | ? KaffeRmic.COMPILER_NAME | |
99 | : SunRmic.COMPILER_NAME; | |
98 | if (KaffeRmic.isAvailable()) { | |
99 | rmicType = KaffeRmic.COMPILER_NAME; | |
100 | } else if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | |
101 | rmicType = ForkingSunRmic.COMPILER_NAME; | |
102 | } else { | |
103 | rmicType = SunRmic.COMPILER_NAME; | |
104 | } | |
100 | 105 | } |
101 | 106 | if (SunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { |
102 | 107 | return new SunRmic(); |
26 | 26 | import org.apache.tools.ant.Project; |
27 | 27 | import org.apache.tools.ant.taskdefs.LogOutputStream; |
28 | 28 | import org.apache.tools.ant.types.Commandline; |
29 | import org.apache.tools.ant.util.JavaEnvUtils; | |
29 | 30 | |
30 | 31 | /** |
31 | 32 | * The implementation of the rmic for SUN's JDK. |
53 | 54 | + "available. A common solution is to " |
54 | 55 | + "set the environment variable " |
55 | 56 | + "JAVA_HOME"; |
57 | public static final String ERROR_NO_RMIC_ON_CLASSPATH_JAVA_9 = "Cannot use SUN rmic, as it is not " | |
58 | + "available. The class we try to use is part of the jdk.rmic module which may not be. " | |
59 | + "Please use the 'forking' compiler for JDK 9+"; | |
56 | 60 | /** Error message to use when there is an error starting the sun rmic compiler */ |
57 | 61 | public static final String ERROR_RMIC_FAILED = "Error starting SUN rmic: "; |
58 | 62 | |
70 | 74 | LogOutputStream logstr = new LogOutputStream(getRmic(), |
71 | 75 | Project.MSG_WARN); |
72 | 76 | |
77 | boolean success = false; | |
73 | 78 | try { |
74 | 79 | Class c = Class.forName(RMIC_CLASSNAME); |
75 | 80 | Constructor cons |
81 | 86 | Boolean ok = |
82 | 87 | (Boolean) doRmic.invoke(rmic, |
83 | 88 | (new Object[] {cmd.getArguments()})); |
89 | success = true; | |
84 | 90 | return ok.booleanValue(); |
85 | 91 | } catch (ClassNotFoundException ex) { |
92 | if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | |
93 | throw new BuildException(ERROR_NO_RMIC_ON_CLASSPATH_JAVA_9, | |
94 | getRmic().getLocation()); | |
95 | } | |
86 | 96 | throw new BuildException(ERROR_NO_RMIC_ON_CLASSPATH, |
87 | 97 | getRmic().getLocation()); |
88 | 98 | } catch (Exception ex) { |
96 | 106 | try { |
97 | 107 | logstr.close(); |
98 | 108 | } catch (IOException e) { |
99 | throw new BuildException(e); | |
109 | // swallow if there was an error before so that | |
110 | // original error will be passed up | |
111 | if (success) { | |
112 | throw new BuildException(e); //NOSONAR | |
113 | } | |
100 | 114 | } |
101 | 115 | } |
102 | 116 | } |
66 | 66 | private List<FileSelector> selectors = new ArrayList<FileSelector>(); |
67 | 67 | |
68 | 68 | private File dir; |
69 | private boolean fileAttributeUsed; | |
69 | 70 | private boolean useDefaultExcludes = true; |
70 | 71 | private boolean caseSensitive = true; |
71 | 72 | private boolean followSymlinks = true; |
130 | 131 | if (isReference()) { |
131 | 132 | throw tooManyAttributes(); |
132 | 133 | } |
134 | if (fileAttributeUsed && !getDir().equals(dir)) { | |
135 | throw dirAndFileAreMutuallyExclusive(); | |
136 | } | |
133 | 137 | this.dir = dir; |
134 | 138 | directoryScanner = null; |
135 | 139 | } |
227 | 231 | if (isReference()) { |
228 | 232 | throw tooManyAttributes(); |
229 | 233 | } |
234 | if (getDir() != null) { | |
235 | throw dirAndFileAreMutuallyExclusive(); | |
236 | } | |
230 | 237 | setDir(file.getParentFile()); |
238 | fileAttributeUsed = true; | |
231 | 239 | createInclude().setName(file.getName()); |
232 | 240 | } |
233 | 241 | |
918 | 926 | setChecked(true); |
919 | 927 | } |
920 | 928 | } |
929 | ||
930 | private BuildException dirAndFileAreMutuallyExclusive() { | |
931 | return new BuildException("you can only specify one of the dir and file attributes"); | |
932 | } | |
921 | 933 | } |
26 | 26 | * An AntFilterReader is a wrapper class that encloses the classname |
27 | 27 | * and configuration of a Configurable FilterReader. |
28 | 28 | */ |
29 | public final class AntFilterReader | |
30 | extends DataType implements Cloneable { | |
29 | public final class AntFilterReader extends DataType { | |
31 | 30 | |
32 | 31 | private String className; |
33 | 32 |
519 | 519 | } |
520 | 520 | //module path |
521 | 521 | if (haveModulepath()) { |
522 | listIterator.add("-modulepath"); | |
522 | listIterator.add("--module-path"); | |
523 | 523 | listIterator.add( |
524 | 524 | modulepath.concatSystemClasspath("ignore").toString()); |
525 | 525 | } |
526 | 526 | //upgrade module path |
527 | 527 | if (haveUpgrademodulepath()) { |
528 | listIterator.add("-upgrademodulepath"); | |
528 | listIterator.add("--upgrade-module-path"); | |
529 | 529 | listIterator.add( |
530 | 530 | upgrademodulepath.concatSystemClasspath("ignore").toString()); |
531 | 531 | } |
44 | 44 | * FilterChain may contain a chained set of filter readers. |
45 | 45 | * |
46 | 46 | */ |
47 | public class FilterChain extends DataType | |
48 | implements Cloneable { | |
47 | public class FilterChain extends DataType { | |
49 | 48 | |
50 | 49 | private Vector<Object> filterReaders = new Vector<Object>(); |
51 | 50 |
29 | 29 | * Element to define a FileNameMapper. |
30 | 30 | * |
31 | 31 | */ |
32 | public class Mapper extends DataType implements Cloneable { | |
32 | public class Mapper extends DataType { | |
33 | 33 | // CheckStyle:VisibilityModifier OFF - bc |
34 | 34 | |
35 | 35 | protected MapperType type = null; |
66 | 66 | // CheckStyle:VisibilityModifier OFF - bc |
67 | 67 | |
68 | 68 | /** The system classpath as a Path object */ |
69 | public static Path systemClasspath = | |
69 | public static final Path systemClasspath = | |
70 | 70 | new Path(null, System.getProperty("java.class.path")); |
71 | 71 | |
72 | 72 | |
75 | 75 | * |
76 | 76 | * @since Ant 1.6.2 |
77 | 77 | */ |
78 | public static Path systemBootClasspath = | |
78 | public static final Path systemBootClasspath = | |
79 | 79 | new Path(null, System.getProperty("sun.boot.class.path")); |
80 | 80 | |
81 | 81 | // CheckStyle:VisibilityModifier OFF - bc |
301 | 301 | * @param perm The permission to check against. |
302 | 302 | */ |
303 | 303 | boolean matches(final java.security.Permission perm) { |
304 | if (!className.equals(perm.getClass().getName())) { | |
304 | if (!className.equals(perm.getClass().getName())) { //NOSONAR | |
305 | 305 | return false; |
306 | 306 | } |
307 | 307 | if (name != null) { |
118 | 118 | * |
119 | 119 | */ |
120 | 120 | public class XMLCatalog extends DataType |
121 | implements Cloneable, EntityResolver, URIResolver { | |
121 | implements EntityResolver, URIResolver { | |
122 | 122 | |
123 | 123 | /** helper for some File.toURL connversions */ |
124 | 124 | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); |
215 | 215 | if (isReference()) { |
216 | 216 | return getCheckedRef().equals(another); |
217 | 217 | } |
218 | if (another == null || !(another.getClass().equals(getClass()))) { | |
218 | if (another == null || another.getClass() != getClass()) { | |
219 | 219 | return false; |
220 | 220 | } |
221 | 221 | ArchiveResource r = (ArchiveResource) another; |
94 | 94 | */ |
95 | 95 | @Override |
96 | 96 | public boolean equals(Object other) { |
97 | if (other == null || !other.getClass().equals(getClass())) { | |
97 | if (other == null || other.getClass() != getClass()) { | |
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | MappedResource m = (MappedResource) other; |
73 | 73 | * Get the name of the resource. |
74 | 74 | * @return the name of the wrapped resource. |
75 | 75 | */ |
76 | @Override | |
76 | 77 | public String getName() { |
77 | 78 | return getResource().getName(); |
78 | 79 | } |
81 | 82 | * The exists attribute tells whether a file exists. |
82 | 83 | * @return true if this resource exists. |
83 | 84 | */ |
85 | @Override | |
84 | 86 | public boolean isExists() { |
85 | 87 | return getResource().isExists(); |
86 | 88 | } |
91 | 93 | * @return 0 if the resource does not exist to mirror the behavior |
92 | 94 | * of {@link java.io.File File}. |
93 | 95 | */ |
96 | @Override | |
94 | 97 | public long getLastModified() { |
95 | 98 | return getResource().getLastModified(); |
96 | 99 | } |
99 | 102 | * Tells if the resource is a directory. |
100 | 103 | * @return boolean flag indicating if the resource is a directory. |
101 | 104 | */ |
105 | @Override | |
102 | 106 | public boolean isDirectory() { |
103 | 107 | return getResource().isDirectory(); |
104 | 108 | } |
108 | 112 | * @return the size, as a long, 0 if the Resource does not exist (for |
109 | 113 | * compatibility with java.io.File), or UNKNOWN_SIZE if not known. |
110 | 114 | */ |
115 | @Override | |
111 | 116 | public long getSize() { |
112 | 117 | return getResource().getSize(); |
113 | 118 | } |
120 | 125 | * @throws UnsupportedOperationException if InputStreams are not |
121 | 126 | * supported for this Resource type. |
122 | 127 | */ |
128 | @Override | |
123 | 129 | public InputStream getInputStream() throws IOException { |
124 | 130 | return getResource().getInputStream(); |
125 | 131 | } |
132 | 138 | * @throws UnsupportedOperationException if OutputStreams are not |
133 | 139 | * supported for this Resource type. |
134 | 140 | */ |
141 | @Override | |
135 | 142 | public OutputStream getOutputStream() throws IOException { |
136 | 143 | return getResource().getOutputStream(); |
137 | 144 | } |
140 | 147 | * Fulfill the ResourceCollection contract. |
141 | 148 | * @return whether this Resource is a FileProvider. |
142 | 149 | */ |
150 | @Override | |
143 | 151 | public boolean isFilesystemOnly() { |
144 | 152 | return as(FileProvider.class) != null; |
145 | 153 | } |
148 | 156 | * Overrides the base version. |
149 | 157 | * @param r the Reference to set. |
150 | 158 | */ |
159 | @Override | |
151 | 160 | public void setRefid(Reference r) { |
152 | 161 | if (resource != null) { |
153 | 162 | throw noChildrenAllowed(); |
158 | 167 | /** |
159 | 168 | * {@inheritDoc} |
160 | 169 | */ |
170 | @Override | |
161 | 171 | public <T> T as(Class<T> clazz) { |
162 | 172 | return getResource().as(clazz); |
163 | 173 | } |
165 | 175 | /** |
166 | 176 | * {@inheritDoc} |
167 | 177 | */ |
178 | @Override | |
168 | 179 | public int compareTo(Resource other) { |
169 | 180 | if (other == this) { |
170 | 181 | return 0; |
180 | 191 | * Get the hash code for this Resource. |
181 | 192 | * @return hash code as int. |
182 | 193 | */ |
183 | public int hashCode() { | |
194 | @Override | |
195 | public int hashCode() { // NOSONAR | |
196 | // super.equals + compareTo are consistent with this implementation | |
184 | 197 | return (getClass().hashCode() << 4) | getResource().hashCode(); |
185 | 198 | } |
186 | 199 | |
266 | 279 | throw new BuildException("you can't change the size of a " |
267 | 280 | + getDataTypeName()); |
268 | 281 | } |
282 | ||
269 | 283 | } |
194 | 194 | crh.setPrimaryReader(input); |
195 | 195 | crh.setFilterChains(filterChains); |
196 | 196 | crh.setProject(getProject()); |
197 | Union streamResources = new Union(); | |
197 | 198 | BufferedReader reader = new BufferedReader(crh.getAssembledReader()); |
198 | ||
199 | Union streamResources = new Union(); | |
200 | streamResources.setCache(true); | |
201 | ||
202 | String line = null; | |
203 | while ((line = reader.readLine()) != null) { | |
204 | streamResources.add(parse(line)); | |
199 | try { | |
200 | streamResources.setCache(true); | |
201 | ||
202 | String line = null; | |
203 | while ((line = reader.readLine()) != null) { | |
204 | streamResources.add(parse(line)); | |
205 | } | |
206 | } finally { | |
207 | reader.close(); | |
205 | 208 | } |
206 | 209 | |
207 | 210 | return streamResources; |
70 | 70 | * Enforce String immutability. |
71 | 71 | * @param s the new name/value for this StringResource. |
72 | 72 | */ |
73 | @Override | |
73 | 74 | public synchronized void setName(String s) { |
74 | 75 | if (getName() != null) { |
75 | 76 | throw new BuildException(new ImmutableResourceException()); |
89 | 90 | * Synchronize access. |
90 | 91 | * @return the name/value of this StringResource. |
91 | 92 | */ |
93 | @Override | |
92 | 94 | public synchronized String getName() { |
93 | 95 | return super.getName(); |
94 | 96 | } |
106 | 108 | * |
107 | 109 | * @return true if this resource exists. |
108 | 110 | */ |
111 | @Override | |
109 | 112 | public boolean isExists() { |
110 | 113 | return getValue() != null; |
111 | 114 | } |
143 | 146 | * @return the size, as a long, 0 if the Resource does not exist (for |
144 | 147 | * compatibility with java.io.File), or UNKNOWN_SIZE if not known. |
145 | 148 | */ |
149 | @Override | |
146 | 150 | public synchronized long getSize() { |
147 | 151 | return isReference() ? ((Resource) getCheckedRef()).getSize() |
148 | 152 | : getContent().length(); |
152 | 156 | * Get the hash code for this Resource. |
153 | 157 | * @return hash code as int. |
154 | 158 | */ |
155 | public synchronized int hashCode() { | |
159 | @Override | |
160 | public synchronized int hashCode() { //NOSONAR | |
161 | // super.equals + super.compareTo are consistent with this implementation | |
156 | 162 | if (isReference()) { |
157 | 163 | return getCheckedRef().hashCode(); |
158 | 164 | } |
165 | 171 | * @return the string contents of the resource. |
166 | 172 | * @since Ant 1.7 |
167 | 173 | */ |
174 | @Override | |
168 | 175 | public String toString() { |
169 | 176 | return String.valueOf(getContent()); |
170 | 177 | } |
177 | 184 | * @throws UnsupportedOperationException if InputStreams are not |
178 | 185 | * supported for this Resource type. |
179 | 186 | */ |
187 | @Override | |
180 | 188 | public synchronized InputStream getInputStream() throws IOException { |
181 | 189 | if (isReference()) { |
182 | 190 | return ((Resource) getCheckedRef()).getInputStream(); |
197 | 205 | * @throws UnsupportedOperationException if OutputStreams are not |
198 | 206 | * supported for this Resource type. |
199 | 207 | */ |
208 | @Override | |
200 | 209 | public synchronized OutputStream getOutputStream() throws IOException { |
201 | 210 | if (isReference()) { |
202 | 211 | return ((Resource) getCheckedRef()).getOutputStream(); |
211 | 220 | * Overrides the super version. |
212 | 221 | * @param r the Reference to set. |
213 | 222 | */ |
223 | @Override | |
214 | 224 | public void setRefid(Reference r) { |
215 | 225 | if (encoding != DEFAULT_ENCODING) { |
216 | 226 | throw tooManyAttributes(); |
249 | 259 | baos = (ByteArrayOutputStream) out; |
250 | 260 | } |
251 | 261 | |
262 | @Override | |
252 | 263 | public void close() throws IOException { |
253 | 264 | super.close(); |
254 | 265 | String result = encoding == null |
59 | 59 | ConcatResourceInputStream cat = new ConcatResourceInputStream(rc); |
60 | 60 | cat.setManagingComponent(this); |
61 | 61 | |
62 | InputStreamReader rdr = null; | |
62 | 63 | try { |
63 | InputStreamReader rdr = null; | |
64 | 64 | if (encoding == null) { |
65 | 65 | rdr = new InputStreamReader(cat); |
66 | 66 | } else { |
80 | 80 | } catch (IOException e) { |
81 | 81 | throw new BuildException("Error reading tokens", e); |
82 | 82 | } finally { |
83 | FileUtils.close(rdr); | |
83 | 84 | FileUtils.close(cat); |
84 | 85 | } |
85 | 86 | } |
312 | 312 | if (isReference()) { |
313 | 313 | return getCheckedRef().equals(another); |
314 | 314 | } |
315 | if (another == null || !(another.getClass().equals(getClass()))) { | |
315 | if (another == null || another.getClass() != getClass()) { | |
316 | 316 | return false; |
317 | 317 | } |
318 | 318 | URLResource otheru = (URLResource) another; |
136 | 136 | throw new BuildException(MILLIS_OR_DATETIME); |
137 | 137 | } |
138 | 138 | if (millis == null) { |
139 | DateFormat df = ((pattern == null) | |
140 | ? DateFormat.getDateTimeInstance( | |
141 | DateFormat.SHORT, DateFormat.SHORT, Locale.US) | |
142 | : new SimpleDateFormat(pattern)); | |
139 | String p = pattern == null ? "MM/dd/yyyy hh:mm a" : pattern; | |
140 | DateFormat df = pattern == null | |
141 | ? new SimpleDateFormat(p, Locale.US) | |
142 | : new SimpleDateFormat(p); | |
143 | 143 | try { |
144 | 144 | long m = df.parse(dateTime).getTime(); |
145 | 145 | if (m < 0) { |
150 | 150 | setMillis(m); |
151 | 151 | } catch (ParseException pe) { |
152 | 152 | throw new BuildException("Date of " + dateTime |
153 | + " Cannot be parsed correctly. It should be in" | |
154 | + (pattern == null | |
155 | ? " MM/DD/YYYY HH:MM AM_PM" : pattern) + " format."); | |
153 | + " Cannot be parsed correctly. It should be in '" | |
154 | + p + "' format."); | |
156 | 155 | } |
157 | 156 | } |
158 | 157 | return when.evaluate(r.getLastModified(), millis.longValue(), granularity); |
33 | 33 | public abstract class BaseSelector extends DataType implements FileSelector { |
34 | 34 | |
35 | 35 | private String errmsg = null; |
36 | ||
36 | private Throwable cause; | |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Do nothing constructor. |
50 | 50 | public void setError(String msg) { |
51 | 51 | if (errmsg == null) { |
52 | 52 | errmsg = msg; |
53 | } | |
54 | } | |
55 | ||
56 | /** | |
57 | * Allows all selectors to indicate a setup error. Note that only | |
58 | * the first error message is recorded. | |
59 | * | |
60 | * @param msg The error message any BuildException should throw. | |
61 | */ | |
62 | public void setError(String msg, Throwable cause) { | |
63 | if (errmsg == null) { | |
64 | errmsg = msg; | |
65 | this.cause = cause; | |
53 | 66 | } |
54 | 67 | } |
55 | 68 | |
86 | 99 | verifySettings(); |
87 | 100 | } |
88 | 101 | if (getError() != null) { |
89 | throw new BuildException(errmsg); | |
102 | throw new BuildException(errmsg, cause); | |
90 | 103 | } |
91 | 104 | if (!isReference()) { |
92 | 105 | dieOnCircularReference(); |
183 | 183 | } |
184 | 184 | |
185 | 185 | try { |
186 | in = new BufferedReader(new InputStreamReader(r.getInputStream())); | |
186 | in = new BufferedReader(new InputStreamReader(r.getInputStream())); //NOSONAR | |
187 | 187 | } catch (Exception e) { |
188 | 188 | throw new BuildException("Could not get InputStream from " |
189 | 189 | + r.toLongString(), e); |
190 | 190 | } |
191 | boolean success = false; | |
191 | 192 | try { |
192 | 193 | teststr = in.readLine(); |
193 | 194 | |
201 | 202 | } |
202 | 203 | teststr = in.readLine(); |
203 | 204 | } |
204 | ||
205 | success = true; | |
205 | 206 | return false; |
206 | 207 | } catch (IOException ioe) { |
207 | 208 | throw new BuildException("Could not read " + r.toLongString()); |
209 | 210 | try { |
210 | 211 | in.close(); |
211 | 212 | } catch (Exception e) { |
212 | throw new BuildException("Could not close " | |
213 | + r.toLongString()); | |
213 | if (success) { | |
214 | throw new BuildException("Could not close " //NOSONAR | |
215 | + r.toLongString()); | |
216 | } | |
214 | 217 | } |
215 | 218 | } |
216 | 219 | } |
186 | 186 | BufferedReader in = null; |
187 | 187 | try { |
188 | 188 | if (encoding != null) { |
189 | in = new BufferedReader(new InputStreamReader(r.getInputStream(), encoding)); | |
189 | in = new BufferedReader(new InputStreamReader(r.getInputStream(), encoding)); //NOSONAR | |
190 | 190 | } else { |
191 | in = new BufferedReader(new InputStreamReader(r.getInputStream())); | |
191 | in = new BufferedReader(new InputStreamReader(r.getInputStream())); //NOSONAR | |
192 | 192 | } |
193 | 193 | } catch (Exception e) { |
194 | 194 | throw new BuildException("Could not get InputStream from " |
208 | 208 | setError("You must provide a datetime or the number of " |
209 | 209 | + "milliseconds."); |
210 | 210 | } else if (millis < 0 && dateTime != null) { |
211 | // check millis and only set it once. | |
212 | DateFormat df = ((pattern == null) | |
213 | ? DateFormat.getDateTimeInstance( | |
214 | DateFormat.SHORT, DateFormat.SHORT, Locale.US) | |
215 | : new SimpleDateFormat(pattern)); | |
211 | String p = pattern == null ? "MM/dd/yyyy hh:mm a" : pattern; | |
212 | DateFormat df = pattern == null | |
213 | ? new SimpleDateFormat(p, Locale.US) | |
214 | : new SimpleDateFormat(p); | |
216 | 215 | |
217 | 216 | try { |
218 | 217 | setMillis(df.parse(dateTime).getTime()); |
223 | 222 | } |
224 | 223 | } catch (ParseException pe) { |
225 | 224 | setError("Date of " + dateTime |
226 | + " Cannot be parsed correctly. It should be in" | |
227 | + ((pattern == null) | |
228 | ? " MM/DD/YYYY HH:MM AM_PM" : pattern) + " format."); | |
225 | + " Cannot be parsed correctly. It should be in '" | |
226 | + p + "' format.", pe); | |
229 | 227 | } |
230 | 228 | } |
231 | 229 | } |
+2
-2
136 | 136 | cache.load(bis); |
137 | 137 | bis.close(); |
138 | 138 | } catch (Exception e) { |
139 | e.printStackTrace(); | |
139 | e.printStackTrace(); //NOSONAR | |
140 | 140 | } |
141 | 141 | } |
142 | 142 | // after loading the cache is up to date with the file |
163 | 163 | bos.flush(); |
164 | 164 | bos.close(); |
165 | 165 | } catch (Exception e) { |
166 | e.printStackTrace(); | |
166 | e.printStackTrace(); //NOSONAR | |
167 | 167 | } |
168 | 168 | } |
169 | 169 | cacheDirty = false; |
48 | 48 | |
49 | 49 | // CheckStyle:ConstantNameCheck OFF - bc |
50 | 50 | /** Provided for BC purposes */ |
51 | public static final char[] alphabet = ALPHABET; | |
51 | public static final char[] alphabet = ALPHABET; //NOSONAR | |
52 | 52 | // CheckStyle:ConstantNameCheck ON |
53 | 53 | |
54 | 54 |
35 | 35 | */ |
36 | 36 | public class CollectionUtils { |
37 | 37 | |
38 | /** | |
39 | * Collections.emptyList() is Java5+. | |
40 | */ | |
41 | 38 | @SuppressWarnings("rawtypes") |
42 | 39 | @Deprecated |
43 | public static final List EMPTY_LIST = Collections.EMPTY_LIST; | |
40 | public static final List EMPTY_LIST = Collections.EMPTY_LIST; //NOSONAR | |
44 | 41 | |
45 | 42 | /** |
46 | 43 | * Please use Vector.equals() or List.equals(). |
493 | 493 | try { |
494 | 494 | encodedata(out, value); |
495 | 495 | } catch (IOException ex) { |
496 | throw new RuntimeException(ex); | |
496 | throw new RuntimeException(ex); //NOSONAR | |
497 | 497 | } |
498 | 498 | return out.toString(); |
499 | 499 | } |
1602 | 1602 | * |
1603 | 1603 | * @since Ant 1.7 |
1604 | 1604 | */ |
1605 | public static String getRelativePath(File fromFile, File toFile) throws Exception { | |
1605 | public static String getRelativePath(File fromFile, File toFile) throws Exception { //NOSONAR | |
1606 | 1606 | String fromPath = fromFile.getCanonicalPath(); |
1607 | 1607 | String toPath = toFile.getCanonicalPath(); |
1608 | 1608 | |
1707 | 1707 | */ |
1708 | 1708 | public String getDefaultEncoding() { |
1709 | 1709 | InputStreamReader is = new InputStreamReader( |
1710 | new InputStream() { | |
1710 | new InputStream() { //NOSONAR | |
1711 | 1711 | public int read() { |
1712 | 1712 | return -1; |
1713 | 1713 | } |
54 | 54 | /** floating version of the JVM */ |
55 | 55 | private static int javaVersionNumber; |
56 | 56 | |
57 | /** Version of currently running VM. */ | |
58 | private static final DeweyDecimal parsedJavaVersion; | |
59 | ||
57 | 60 | /** Version constant for Java 1.0 */ |
58 | 61 | public static final String JAVA_1_0 = "1.0"; |
59 | 62 | /** Number Version constant for Java 1.0 */ |
99 | 102 | /** Number Version constant for Java 1.8 */ |
100 | 103 | public static final int VERSION_1_8 = 18; |
101 | 104 | |
102 | /** Version constant for Java 1.9 */ | |
105 | /** | |
106 | * Version constant for Java 1.9 | |
107 | * @deprecated use #JAVA_9 instead | |
108 | */ | |
103 | 109 | public static final String JAVA_1_9 = "1.9"; |
104 | /** Number Version constant for Java 1.9 */ | |
110 | /** | |
111 | * Number Version constant for Java 1.9 | |
112 | * @deprecated use #VERSION_9 instead | |
113 | */ | |
105 | 114 | public static final int VERSION_1_9 = 19; |
115 | ||
116 | /** | |
117 | * Version constant for Java 9 | |
118 | * @since Ant 1.9.8 | |
119 | */ | |
120 | public static final String JAVA_9 = "9"; | |
121 | /** | |
122 | * Number Version constant for Java 9 | |
123 | * @since Ant 1.9.8 | |
124 | */ | |
125 | public static final int VERSION_9 = 90; | |
106 | 126 | |
107 | 127 | /** Whether this is the Kaffe VM */ |
108 | 128 | private static boolean kaffeDetected; |
157 | 177 | Class.forName("java.lang.reflect.Executable"); |
158 | 178 | javaVersion = JAVA_1_8; |
159 | 179 | javaVersionNumber++; |
160 | checkForJava9(); | |
161 | javaVersion = JAVA_1_9; | |
162 | javaVersionNumber++; | |
180 | Class.forName("java.lang.module.ModuleDescriptor"); | |
181 | javaVersion = JAVA_9; | |
182 | javaVersionNumber = VERSION_9; | |
163 | 183 | } catch (Throwable t) { |
164 | 184 | // swallow as we've hit the max class version that |
165 | 185 | // we have |
166 | 186 | } |
187 | parsedJavaVersion = new DeweyDecimal(javaVersion); | |
167 | 188 | kaffeDetected = false; |
168 | 189 | try { |
169 | 190 | Class.forName("kaffe.util.NotImplemented"); |
196 | 217 | |
197 | 218 | /** |
198 | 219 | * Returns the version of Java this class is running under. |
199 | * @return the version of Java as a String, e.g. "1.6" | |
220 | * | |
221 | * <p>Up until Java 8 Java version numbers were 1.VERSION - | |
222 | * e.g. 1.8.x for Java 8, starting with Java 9 it became 9.x.</p> | |
223 | * | |
224 | * @return the version of Java as a String, e.g. "1.6" or "9" | |
200 | 225 | */ |
201 | 226 | public static String getJavaVersion() { |
202 | 227 | return javaVersion; |
204 | 229 | |
205 | 230 | |
206 | 231 | /** |
207 | * Checks for a give Java 9 runtime. | |
208 | * At the time of writing the actual version of the JDK was 1.9.0_b06. | |
209 | * Searching for new classes gave no hits, so we need another aproach. | |
210 | * Searching for changes (grep -r -i -n "@since 1.9" .) in the sources gave | |
211 | * only one hit: a new constant in the class SourceVersion. | |
212 | * So we have to check that ... | |
213 | * | |
214 | * @throws Exception if we can't load the class or don't find the new constant. | |
215 | * This is the behavior when searching for new features on older versions. | |
216 | * @since Ant 1.9.4 | |
217 | */ | |
218 | private static void checkForJava9() throws Exception { | |
219 | Class<?> clazz = Class.forName("javax.lang.model.SourceVersion"); | |
220 | clazz.getDeclaredField("RELEASE_9"); | |
221 | } | |
222 | ||
223 | ||
224 | /** | |
225 | 232 | * Returns the version of Java this class is running under. |
226 | * This number can be used for comparisons; it will always be | |
233 | * <p>This number can be used for comparisons.</p> | |
227 | 234 | * @return the version of Java as a number 10x the major/minor, |
228 | * e.g Java1.5 has a value of 15 | |
235 | * e.g Java1.5 has a value of 15 and Java9 the value 90 - major | |
236 | * will be 1 for all versions of Java prior to Java 9, minor will | |
237 | * be 0 for all versions of Java starting with Java 9. | |
238 | * @deprecated use #getParsedJavaVersion instead | |
229 | 239 | */ |
230 | 240 | public static int getJavaVersionNumber() { |
231 | 241 | return javaVersionNumber; |
242 | } | |
243 | ||
244 | /** | |
245 | * Returns the version of Java this class is running under. | |
246 | * <p>This number can be used for comparisons.</p> | |
247 | * @return the version of Java as major.minor, e.g Java1.5 has a | |
248 | * value of 1.5 and Java9 the value 9 - major will be 1 for all | |
249 | * versions of Java prior to Java 9, minor will be 0 for all | |
250 | * versions of Java starting with Java 9. | |
251 | */ | |
252 | public static DeweyDecimal getParsedJavaVersion() { | |
253 | return parsedJavaVersion; | |
232 | 254 | } |
233 | 255 | |
234 | 256 | /** |
242 | 264 | * @since Ant 1.5 |
243 | 265 | */ |
244 | 266 | public static boolean isJavaVersion(String version) { |
245 | return javaVersion.equals(version); | |
267 | return javaVersion.equals(version) | |
268 | || (javaVersion.equals(JAVA_9) && JAVA_1_9.equals(version)); | |
246 | 269 | } |
247 | 270 | |
248 | 271 | /** |
257 | 280 | * @since Ant 1.7 |
258 | 281 | */ |
259 | 282 | public static boolean isAtLeastJavaVersion(String version) { |
260 | return javaVersion.compareTo(version) >= 0; | |
283 | return parsedJavaVersion.compareTo(new DeweyDecimal(version)) >= 0; | |
261 | 284 | } |
262 | 285 | |
263 | 286 | /** |
384 | 407 | // fall back to JRE bin directory, also catches JDK 1.0 and 1.1 |
385 | 408 | // where java.home points to the root of the JDK and Mac OS X where |
386 | 409 | // the whole directory layout is different from Sun's |
387 | // and also catches JDK 1.9 (and probably later) which | |
410 | // and also catches JDK 9 (and probably later) which | |
388 | 411 | // merged JDK and JRE dirs |
389 | 412 | return getJreExecutable(command); |
390 | 413 | } |
426 | 449 | private static void buildJrePackages() { |
427 | 450 | jrePackages = new Vector<String>(); |
428 | 451 | switch(javaVersionNumber) { |
429 | case VERSION_1_9: | |
452 | case VERSION_9: | |
430 | 453 | case VERSION_1_8: |
431 | 454 | case VERSION_1_7: |
455 | jrePackages.addElement("jdk"); | |
456 | // fall through | |
432 | 457 | case VERSION_1_6: |
433 | 458 | case VERSION_1_5: |
434 | 459 | //In Java1.5, the apache stuff moved. |
479 | 504 | Vector<String> tests = new Vector<String>(); |
480 | 505 | tests.addElement("java.lang.Object"); |
481 | 506 | switch(javaVersionNumber) { |
482 | case VERSION_1_9: | |
507 | case VERSION_9: | |
483 | 508 | case VERSION_1_8: |
484 | 509 | case VERSION_1_7: |
510 | tests.addElement("jdk.net.Sockets"); | |
511 | // fall through | |
485 | 512 | case VERSION_1_6: |
486 | 513 | case VERSION_1_5: |
487 | 514 | tests.addElement( |
699 | 699 | dolly = super.clone(); |
700 | 700 | } catch (final CloneNotSupportedException e) { |
701 | 701 | // should be fine |
702 | e.printStackTrace(); | |
702 | e.printStackTrace(); //NOSONAR | |
703 | 703 | } |
704 | 704 | return dolly; |
705 | 705 | } |
0 | /* | |
1 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
2 | * contributor license agreements. See the NOTICE file distributed with | |
3 | * this work for additional information regarding copyright ownership. | |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | * (the "License"); you may not use this file except in compliance with | |
6 | * the License. You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | */ | |
17 | package org.apache.tools.ant.util; | |
18 | ||
19 | /** | |
20 | * Contains helper methods for Ant's built-in implementation of native2ascii. | |
21 | * | |
22 | * @since Ant 1.9.8 | |
23 | */ | |
24 | public class Native2AsciiUtils { | |
25 | ||
26 | private static final int MAX_ASCII = 127; | |
27 | ||
28 | /** | |
29 | * Replaces non-ASCII characters with their Unicode-Escapes. | |
30 | * <p>Expects to be called once per line if applied to a file.</p> | |
31 | * @param line the input line | |
32 | * @return the translated line | |
33 | */ | |
34 | public static String native2ascii(String line) { | |
35 | StringBuilder sb = new StringBuilder(); | |
36 | for (char c : line.toCharArray()) { | |
37 | if (c <= MAX_ASCII) { | |
38 | sb.append(c); | |
39 | } else { | |
40 | sb.append("\\u"); | |
41 | String encoded = Integer.toHexString(c); | |
42 | for (int i = encoded.length(); i < 4; i++) { | |
43 | sb.append("0"); | |
44 | } | |
45 | sb.append(encoded); | |
46 | } | |
47 | } | |
48 | return sb.toString(); | |
49 | } | |
50 | ||
51 | /** | |
52 | * Replaces Unicode-Escapes. | |
53 | * <p>Expects to be called once per line if applied to a file.</p> | |
54 | * @param line the input line | |
55 | * @return the translated line | |
56 | */ | |
57 | public static String ascii2native(String line) { | |
58 | StringBuilder sb = new StringBuilder(); | |
59 | int inputLen = line.length(); | |
60 | for (int i = 0; i < inputLen; i++) { | |
61 | char c = line.charAt(i); | |
62 | if (c != '\\' || i >= inputLen - 5) { | |
63 | sb.append(c); | |
64 | } else { // backslash with enough remaining characters | |
65 | char u = line.charAt(++i); | |
66 | if (u == 'u') { | |
67 | int unescaped = tryParse(line, i + 1); | |
68 | if (unescaped >= 0) { | |
69 | sb.append((char) unescaped); | |
70 | i += 4; | |
71 | continue; | |
72 | } | |
73 | } | |
74 | // not a unicode escape | |
75 | sb.append(c).append(u); | |
76 | } | |
77 | } | |
78 | return sb.toString(); | |
79 | } | |
80 | ||
81 | private static int tryParse(String line, int startIdx) { | |
82 | try { | |
83 | return Integer.parseInt(line.substring(startIdx, startIdx + 4), 16); | |
84 | } catch (NumberFormatException ex) { | |
85 | return -1; | |
86 | } | |
87 | } | |
88 | } |
142 | 142 | if (!funnel.closed) { |
143 | 143 | try { |
144 | 144 | if (timeoutMillis > 0) { |
145 | final long start = System.currentTimeMillis(); | |
146 | final long end = start + timeoutMillis; | |
147 | long now = System.currentTimeMillis(); | |
145 | 148 | try { |
146 | wait(timeoutMillis); | |
149 | while (now < end) { | |
150 | wait(end - now); | |
151 | now = System.currentTimeMillis(); | |
152 | } | |
147 | 153 | } catch (InterruptedException eyeEx) { |
148 | 154 | //ignore |
149 | 155 | } |
56 | 56 | /** the http proxy username property */ |
57 | 57 | public static final String HTTP_PROXY_USERNAME = "http.proxyUser"; |
58 | 58 | /** the http proxy password property */ |
59 | public static final String HTTP_PROXY_PASSWORD = "http.proxyPassword"; | |
59 | public static final String HTTP_PROXY_PASSWORD = "http.proxyPassword"; //NOSONAR | |
60 | 60 | /** the socks proxy host property */ |
61 | 61 | public static final String SOCKS_PROXY_HOST = "socksProxyHost"; |
62 | 62 | /** the socks proxy port property */ |
64 | 64 | /** the socks proxy username property */ |
65 | 65 | public static final String SOCKS_PROXY_USERNAME = "java.net.socks.username"; |
66 | 66 | /** the socks proxy password property */ |
67 | public static final String SOCKS_PROXY_PASSWORD = "java.net.socks.password"; | |
67 | public static final String SOCKS_PROXY_PASSWORD = "java.net.socks.password"; //NOSONAR | |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * create a proxy setup class bound to this project |
147 | 147 | try { |
148 | 148 | in.mark(limit); |
149 | 149 | } catch (IOException ioe) { |
150 | throw new RuntimeException(ioe.getMessage()); | |
150 | throw new RuntimeException(ioe.getMessage()); //NOSONAR | |
151 | 151 | } |
152 | 152 | } |
153 | 153 |
71 | 71 | */ |
72 | 72 | public static final String ISO_8859_1 = "ISO-8859-1"; |
73 | 73 | |
74 | private static final long MAX_IO_CHUNK_SIZE = 16*1024*1024; // 16 MB | |
74 | private static final long MAX_IO_CHUNK_SIZE = 16*1024*1024l; // 16 MB | |
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Tells which source files should be reprocessed based on the |
629 | 629 | } |
630 | 630 | expected = in1.readLine(); |
631 | 631 | } |
632 | return in2.readLine() == null ? 0 : -1; | |
632 | return in2.readLine() == null ? 0 : -1; //NOSONAR | |
633 | 633 | } finally { |
634 | 634 | FileUtils.close(in1); |
635 | 635 | FileUtils.close(in2); |
92 | 92 | public static String getStackTrace(Throwable t) { |
93 | 93 | StringWriter sw = new StringWriter(); |
94 | 94 | PrintWriter pw = new PrintWriter(sw, true); |
95 | t.printStackTrace(pw); | |
95 | t.printStackTrace(pw); //NOSONAR | |
96 | 96 | pw.flush(); |
97 | 97 | pw.close(); |
98 | 98 | return sw.toString(); |
194 | 194 | * @throws Exception if there is a problem. |
195 | 195 | * @since Ant 1.7 |
196 | 196 | */ |
197 | public static long parseHumanSizes(String humanSize) throws Exception { | |
197 | public static long parseHumanSizes(String humanSize) throws Exception { //NOSONAR | |
198 | 198 | long factor = 1L; |
199 | 199 | char s = humanSize.charAt(0); |
200 | 200 | switch (s) { |
253 | 253 | } |
254 | 254 | |
255 | 255 | boolean renamedTarget = false; |
256 | boolean success = false; | |
256 | 257 | try { |
257 | 258 | try { |
258 | 259 | FILE_UTILS.rename(target, temp); |
269 | 270 | + " (was it a real file? is this " |
270 | 271 | + "not a UNIX system?)"); |
271 | 272 | } |
273 | success = true; | |
272 | 274 | } finally { |
273 | 275 | if (renamedTarget) { |
274 | 276 | // return the resource to its original name: |
275 | 277 | try { |
276 | 278 | FILE_UTILS.rename(temp, target); |
277 | 279 | } catch (final IOException e) { |
278 | throw new IOException("Couldn't return resource " | |
279 | + temp | |
280 | + " to its original name: " | |
281 | + target.getAbsolutePath() | |
282 | + ". Reason: " + e.getMessage() | |
283 | + "\n THE RESOURCE'S NAME ON DISK" | |
284 | + " HAS BEEN CHANGED BY THIS" | |
285 | + " ERROR!\n"); | |
280 | String msg = "Couldn't return resource " | |
281 | + temp | |
282 | + " to its original name: " | |
283 | + target.getAbsolutePath() | |
284 | + ". Reason: " + e.getMessage() | |
285 | + "\n THE RESOURCE'S NAME ON DISK" | |
286 | + " HAS BEEN CHANGED BY THIS" | |
287 | + " ERROR!\n"; | |
288 | if (success) { | |
289 | throw new IOException(msg); //NOSONAR | |
290 | } else { | |
291 | System.err.println(msg); | |
292 | } | |
286 | 293 | } |
287 | 294 | } |
288 | 295 | } |
80 | 80 | /** |
81 | 81 | * Encode a string to the output. |
82 | 82 | */ |
83 | private void encodeString(String n) throws IOException { | |
83 | private void encodeString(String n) { | |
84 | 84 | PrintStream writer = new PrintStream(out); |
85 | 85 | writer.print(n); |
86 | 86 | writer.flush(); |
116 | 116 | * @throws InterruptedException if the execution was interrupted |
117 | 117 | */ |
118 | 118 | public void waitUntilFinished(long timeout) throws InterruptedException { |
119 | final long start = System.currentTimeMillis(); | |
120 | final long end = start + timeout; | |
119 | 121 | synchronized (notify) { |
120 | if (!finished) { | |
121 | notify.wait(timeout); | |
122 | long now = System.currentTimeMillis(); | |
123 | while (!finished && now < end) { | |
124 | notify.wait(end - now); | |
125 | now = System.currentTimeMillis(); | |
122 | 126 | } |
123 | 127 | } |
124 | 128 | } |
21 | 21 | import java.util.Vector; |
22 | 22 | import java.util.zip.ZipFile; |
23 | 23 | |
24 | import org.apache.tools.ant.BuildException; | |
24 | 25 | import org.apache.tools.ant.types.Path; |
25 | 26 | import org.apache.tools.ant.util.VectorSet; |
26 | 27 | |
79 | 80 | */ |
80 | 81 | public Enumeration<File> getFileDependencies() { |
81 | 82 | if (!supportsFileDependencies()) { |
82 | throw new RuntimeException("File dependencies are not supported " | |
83 | throw new BuildException("File dependencies are not supported " | |
83 | 84 | + "by this analyzer"); |
84 | 85 | } |
85 | 86 | if (!determined) { |
41 | 41 | public AncestorAnalyzer() { |
42 | 42 | // force BCEL classes to load now |
43 | 43 | try { |
44 | new ClassParser("force"); | |
44 | new ClassParser("force"); //NOSONAR | |
45 | 45 | } catch (Exception e) { |
46 | 46 | // all released versions of BCEL may throw an IOException |
47 | 47 | // here, but BCEL's trunk does no longer declare to do so |
40 | 40 | public FullAnalyzer() { |
41 | 41 | // force BCEL classes to load now |
42 | 42 | try { |
43 | new ClassParser("force"); | |
43 | new ClassParser("force"); //NOSONAR | |
44 | 44 | } catch (Exception e) { |
45 | 45 | // all released versions of BCEL may throw an IOException |
46 | 46 | // here, but BCEL's trunk does no longer declare to do so |
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | private ReflectWrapper createEngine() throws Exception { | |
128 | private ReflectWrapper createEngine() { | |
129 | 129 | if (engine != null) { |
130 | 130 | return engine; |
131 | 131 | } |
51 | 51 | * <p>FIXME: This array should be in a private or package private |
52 | 52 | * location, since it could be modified by malicious code.</p> |
53 | 53 | */ |
54 | int[] rNums = { | |
54 | int[] rNums = { //NOSONAR | |
55 | 55 | 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, |
56 | 56 | 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, |
57 | 57 | 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, |
444 | 444 | private int[] eclass; |
445 | 445 | |
446 | 446 | private int[] getEclass() { |
447 | return eclass == null | |
448 | ? (eclass = new int[quadrant.length / 2]) : eclass; | |
447 | if (eclass == null) { | |
448 | eclass = new int[quadrant.length / 2]; | |
449 | } | |
450 | return eclass; | |
449 | 451 | } |
450 | 452 | |
451 | 453 | /* |
641 | 643 | HAMMER: while (true) { |
642 | 644 | if (onceRunned) { |
643 | 645 | fmap[j] = a; |
644 | if ((j -= h) <= mj) { | |
646 | if ((j -= h) <= mj) { //NOSONAR | |
645 | 647 | break HAMMER; |
646 | 648 | } |
647 | 649 | } else { |
659 | 661 | if (block[i1 + 3] == block[i2 + 3]) { |
660 | 662 | if (block[i1 + 4] == block[i2 + 4]) { |
661 | 663 | if (block[i1 + 5] == block[i2 + 5]) { |
662 | if (block[(i1 += 6)] == block[(i2 += 6)]) { | |
664 | if (block[(i1 += 6)] == block[(i2 += 6)]) { //NOSONAR | |
663 | 665 | int x = lastShadow; |
664 | 666 | X: while (x > 0) { |
665 | 667 | x -= 4; |
672 | 674 | if (quadrant[i1 + 2] == quadrant[i2 + 2]) { |
673 | 675 | if (block[i1 + 4] == block[i2 + 4]) { |
674 | 676 | if (quadrant[i1 + 3] == quadrant[i2 + 3]) { |
675 | if ((i1 += 4) >= lastPlus1) { | |
677 | if ((i1 += 4) >= lastPlus1) { //NOSONAR | |
676 | 678 | i1 -= lastPlus1; |
677 | 679 | } |
678 | if ((i2 += 4) >= lastPlus1) { | |
680 | if ((i2 += 4) >= lastPlus1) { //NOSONAR | |
679 | 681 | i2 -= lastPlus1; |
680 | 682 | } |
681 | 683 | workDoneShadow++; |
972 | 974 | runningOrder[i] = i; |
973 | 975 | } |
974 | 976 | |
975 | for (int h = 364; h != 1;) { | |
977 | for (int h = 364; h != 1;) { //NOSONAR | |
976 | 978 | h /= 3; |
977 | 979 | for (int i = h; i <= 255; i++) { |
978 | 980 | final int vv = runningOrder[i]; |
29 | 29 | * |
30 | 30 | */ |
31 | 31 | final class CRC { |
32 | static final int crc32Table[] = { | |
32 | static final int crc32Table[] = { //NOSONAR | |
33 | 33 | 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, |
34 | 34 | 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, |
35 | 35 | 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, |
332 | 332 | * @return True if the entries are equal. |
333 | 333 | */ |
334 | 334 | public boolean equals(TarEntry it) { |
335 | return getName().equals(it.getName()); | |
335 | return it != null && getName().equals(it.getName()); | |
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
845 | 845 | writeEntryHeader(outbuf, TarUtils.FALLBACK_ENCODING, false); |
846 | 846 | } catch (IOException ex2) { |
847 | 847 | // impossible |
848 | throw new RuntimeException(ex2); | |
848 | throw new RuntimeException(ex2); //NOSONAR | |
849 | 849 | } |
850 | 850 | } |
851 | 851 | } |
931 | 931 | parseTarHeader(header, TarUtils.DEFAULT_ENCODING, true); |
932 | 932 | } catch (IOException ex2) { |
933 | 933 | // not really possible |
934 | throw new RuntimeException(ex2); | |
934 | throw new RuntimeException(ex2); //NOSONAR | |
935 | 935 | } |
936 | 936 | } |
937 | 937 | } |
1094 | 1094 | try { |
1095 | 1095 | buffer1 = expected.getBytes("ASCII"); |
1096 | 1096 | } catch (UnsupportedEncodingException e) { |
1097 | throw new RuntimeException(e); // Should not happen | |
1097 | // Should not happen | |
1098 | throw new RuntimeException(e); //NOSONAR | |
1098 | 1099 | } |
1099 | 1100 | return isEqual(buffer1, 0, buffer1.length, buffer, offset, length, |
1100 | 1101 | false); |
275 | 275 | while (numToSkip > 0) { |
276 | 276 | long skipped = skip(numToSkip); |
277 | 277 | if (skipped <= 0) { |
278 | throw new RuntimeException("failed to skip current tar" | |
278 | throw new IOException("failed to skip current tar" | |
279 | 279 | + " entry"); |
280 | 280 | } |
281 | 281 | numToSkip -= skipped; |
585 | 585 | |
586 | 586 | private void failForBigNumber(String field, long value, long maxValue, String additionalMsg) { |
587 | 587 | if (value < 0 || value > maxValue) { |
588 | throw new RuntimeException(field + " '" + value | |
588 | throw new RuntimeException(field + " '" + value //NOSONAR | |
589 | 589 | + "' is too big ( > " |
590 | 590 | + maxValue + " )"); |
591 | 591 | } |
637 | 637 | write(0); // NUL terminator |
638 | 638 | closeEntry(); |
639 | 639 | } else if (longFileMode != LONGFILE_TRUNCATE) { |
640 | throw new RuntimeException(fieldName + " '" + name | |
640 | throw new RuntimeException(fieldName + " '" + name //NOSONAR | |
641 | 641 | + "' is too long ( > " |
642 | 642 | + TarConstants.NAMELEN + " bytes)"); |
643 | 643 | } |
190 | 190 | if (negative) { |
191 | 191 | // 2's complement |
192 | 192 | val--; |
193 | val ^= (long) Math.pow(2, (length - 1) * 8) - 1; | |
193 | val ^= (long) Math.pow(2, (length - 1) * 8.0) - 1; | |
194 | 194 | } |
195 | 195 | return negative ? -val : val; |
196 | 196 | } |
264 | 264 | return parseName(buffer, offset, length, FALLBACK_ENCODING); |
265 | 265 | } catch (final IOException ex2) { |
266 | 266 | // impossible |
267 | throw new RuntimeException(ex2); | |
267 | throw new RuntimeException(ex2); //NOSONAR | |
268 | 268 | } |
269 | 269 | } |
270 | 270 | } |
323 | 323 | FALLBACK_ENCODING); |
324 | 324 | } catch (final IOException ex2) { |
325 | 325 | // impossible |
326 | throw new RuntimeException(ex2); | |
326 | throw new RuntimeException(ex2); //NOSONAR | |
327 | 327 | } |
328 | 328 | } |
329 | 329 | } |
53 | 53 | try { |
54 | 54 | unicodeName = text.getBytes("UTF-8"); |
55 | 55 | } catch (final UnsupportedEncodingException e) { |
56 | throw new RuntimeException("FATAL: UTF-8 encoding not supported.", | |
56 | throw new RuntimeException("FATAL: UTF-8 encoding not supported.", //NOSONAR | |
57 | 57 | e); |
58 | 58 | } |
59 | 59 | } |
345 | 345 | return cloned; |
346 | 346 | } catch (CloneNotSupportedException cnfe) { |
347 | 347 | // impossible |
348 | throw new RuntimeException(cnfe); | |
348 | throw new RuntimeException(cnfe); //NOSONAR | |
349 | 349 | } |
350 | 350 | } |
351 | 351 | } |
62 | 62 | ZipExtraField ze = (ZipExtraField) c.newInstance(); |
63 | 63 | implementations.put(ze.getHeaderId(), c); |
64 | 64 | } catch (ClassCastException cc) { |
65 | throw new RuntimeException(c + " doesn\'t implement ZipExtraField"); | |
65 | throw new RuntimeException(c + " doesn\'t implement ZipExtraField"); //NOSONAR | |
66 | 66 | } catch (InstantiationException ie) { |
67 | throw new RuntimeException(c + " is not a concrete class"); | |
67 | throw new RuntimeException(c + " is not a concrete class"); //NOSONAR | |
68 | 68 | } catch (IllegalAccessException ie) { |
69 | throw new RuntimeException(c + "\'s no-arg constructor is not public"); | |
69 | throw new RuntimeException(c + "\'s no-arg constructor is not public"); //NOSONAR | |
70 | 70 | } |
71 | 71 | } |
72 | 72 |
187 | 187 | return super.clone(); |
188 | 188 | } catch (CloneNotSupportedException ex) { |
189 | 189 | // impossible |
190 | throw new RuntimeException("GeneralPurposeBit is not Cloneable?", ex); | |
190 | throw new RuntimeException("GeneralPurposeBit is not Cloneable?", ex); //NOSONAR | |
191 | 191 | } |
192 | 192 | } |
193 | 193 | } |
27 | 27 | public class UnsupportedZipFeatureException extends ZipException { |
28 | 28 | |
29 | 29 | private final Feature reason; |
30 | private final ZipEntry entry; | |
31 | private static final long serialVersionUID = 4430521921766595597L; | |
30 | private transient final ZipEntry entry; | |
31 | private static final long serialVersionUID = 20161221L; | |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Creates an exception. |
60 | 60 | /** |
61 | 61 | * ZIP Features that may or may not be supported. |
62 | 62 | */ |
63 | public static class Feature { | |
63 | public static class Feature implements java.io.Serializable { | |
64 | 64 | /** |
65 | 65 | * The entry is encrypted. |
66 | 66 | */ |
516 | 516 | mergeExtraFields(local, true); |
517 | 517 | } catch (final ZipException e) { |
518 | 518 | // actually this is not be possible as of Ant 1.8.1 |
519 | throw new RuntimeException("Error parsing extra fields for entry: " | |
519 | throw new RuntimeException("Error parsing extra fields for entry: " //NOSONAR | |
520 | 520 | + getName() + " - " + e.getMessage(), e); |
521 | 521 | } |
522 | 522 | } |
543 | 543 | ExtraFieldUtils.UnparseableExtraField.READ); |
544 | 544 | mergeExtraFields(central, false); |
545 | 545 | } catch (final ZipException e) { |
546 | throw new RuntimeException(e.getMessage(), e); | |
546 | throw new RuntimeException(e.getMessage(), e); //NOSONAR | |
547 | 547 | } |
548 | 548 | } |
549 | 549 |
369 | 369 | final OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry(); |
370 | 370 | ZipUtil.checkRequestedFeatures(ze); |
371 | 371 | final long start = offsetEntry.dataOffset; |
372 | // doesn't get closed if the method is not supported, but | |
373 | // doesn't hold any resources either | |
372 | 374 | final BoundedInputStream bis = |
373 | new BoundedInputStream(start, ze.getCompressedSize()); | |
375 | new BoundedInputStream(start, ze.getCompressedSize()); //NOSONAR | |
374 | 376 | switch (ze.getMethod()) { |
375 | 377 | case ZipEntry.STORED: |
376 | 378 | return bis; |
1035 | 1037 | @Override |
1036 | 1038 | public boolean equals(final Object other) { |
1037 | 1039 | if (super.equals(other)) { |
1038 | // super.equals would return false if other were not an Entry | |
1040 | // super.equals would return false if other were null or not an Entry | |
1039 | 1041 | final Entry otherEntry = (Entry) other; |
1040 | 1042 | return offsetEntry.headerOffset |
1041 | == otherEntry.offsetEntry.headerOffset | |
1043 | == otherEntry.offsetEntry.headerOffset //NOSONAR | |
1042 | 1044 | && offsetEntry.dataOffset |
1043 | == otherEntry.offsetEntry.dataOffset; | |
1045 | == otherEntry.offsetEntry.dataOffset; //NOSONAR | |
1044 | 1046 | } |
1045 | 1047 | return false; |
1046 | 1048 | } |
189 | 189 | return super.clone(); |
190 | 190 | } catch (CloneNotSupportedException cnfe) { |
191 | 191 | // impossible |
192 | throw new RuntimeException(cnfe); | |
192 | throw new RuntimeException(cnfe); //NOSONAR | |
193 | 193 | } |
194 | 194 | } |
195 | 195 |
962 | 962 | * |
963 | 963 | * @since 1.1 |
964 | 964 | */ |
965 | protected static final byte[] LFH_SIG = ZipLong.LFH_SIG.getBytes(); | |
965 | protected static final byte[] LFH_SIG = ZipLong.LFH_SIG.getBytes(); //NOSONAR | |
966 | 966 | /** |
967 | 967 | * data descriptor signature |
968 | 968 | * |
969 | 969 | * @since 1.1 |
970 | 970 | */ |
971 | protected static final byte[] DD_SIG = ZipLong.DD_SIG.getBytes(); | |
971 | protected static final byte[] DD_SIG = ZipLong.DD_SIG.getBytes(); //NOSONAR | |
972 | 972 | /** |
973 | 973 | * central file header signature |
974 | 974 | * |
975 | 975 | * @since 1.1 |
976 | 976 | */ |
977 | protected static final byte[] CFH_SIG = ZipLong.CFH_SIG.getBytes(); | |
977 | protected static final byte[] CFH_SIG = ZipLong.CFH_SIG.getBytes(); //NOSONAR | |
978 | 978 | /** |
979 | 979 | * end of central dir signature |
980 | 980 | * |
981 | 981 | * @since 1.1 |
982 | 982 | */ |
983 | protected static final byte[] EOCD_SIG = ZipLong.getBytes(0X06054B50L); | |
983 | protected static final byte[] EOCD_SIG = ZipLong.getBytes(0X06054B50L); //NOSONAR | |
984 | 984 | /** |
985 | 985 | * ZIP64 end of central dir signature |
986 | 986 | */ |
987 | static final byte[] ZIP64_EOCD_SIG = ZipLong.getBytes(0X06064B50L); | |
987 | static final byte[] ZIP64_EOCD_SIG = ZipLong.getBytes(0X06064B50L); //NOSONAR | |
988 | 988 | /** |
989 | 989 | * ZIP64 end of central dir locator signature |
990 | 990 | */ |
991 | static final byte[] ZIP64_EOCD_LOC_SIG = ZipLong.getBytes(0X07064B50L); | |
991 | static final byte[] ZIP64_EOCD_LOC_SIG = ZipLong.getBytes(0X07064B50L); //NOSONAR | |
992 | 992 | |
993 | 993 | /** |
994 | 994 | * Writes next block of compressed data to the output stream. |
154 | 154 | return super.clone(); |
155 | 155 | } catch (CloneNotSupportedException cnfe) { |
156 | 156 | // impossible |
157 | throw new RuntimeException(cnfe); | |
157 | throw new RuntimeException(cnfe); //NOSONAR | |
158 | 158 | } |
159 | 159 | } |
160 | 160 |
20 | 20 | use_jikes_default=false |
21 | 21 | ant_exec_debug=false |
22 | 22 | show_help=false |
23 | ||
24 | esc_tool=sed | |
25 | ||
26 | # if awk esc_tool is chosen, use nawk when available | |
27 | if [ "$esc_tool" = "awk" ] | |
28 | then | |
29 | awk_exec=awk | |
30 | # Solaris_awk does not support gsub, but Solaris_nawk does | |
31 | # `command -v` behavior is part of posix spec | |
32 | command -v nawk >/dev/null && awk_exec=nawk | |
33 | fi | |
34 | ||
23 | 35 | for arg in "$@" ; do |
24 | 36 | if [ "$arg" = "--noconfig" ] ; then |
25 | 37 | no_config=true |
34 | 46 | if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then |
35 | 47 | show_help=true |
36 | 48 | fi |
37 | # wrap all arguments as "" strings, escape any internal back-slash or double-quote characters | |
38 | ant_exec_args="$ant_exec_args \"$(printf '%s' "$arg" | sed -e 's@"\|\\@\\\0@g' )\"" | |
49 | ||
50 | # wrap all arguments as "" strings, escape any internal back-slash, double-quote, $, or back-tick characters | |
51 | # use printf to avoid echo interpretation behaviors such as escapes and line continuation | |
52 | # pad the value with X to protect leading/trailing whitespace from subshell output trimming | |
53 | esc_arg="X${arg}X" | |
54 | case "$esc_tool" in | |
55 | 'sed') | |
56 | # Mac bsd_sed does not support group-0, so pattern uses group-1 | |
57 | # Solaris sed only proceses lines with trailing newline, passing in an extra newline | |
58 | # subshell assignment will trim the added trailing newline | |
59 | esc_arg="$(printf '%s\n' "$esc_arg" | sed -e 's@\([$"\\`]\)@\\\1@g')" | |
60 | ;; | |
61 | 'awk') | |
62 | esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub(/\\/, "\\\\"); print }' )" | |
63 | esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub(/\$/, "\\$"); print }' )" | |
64 | esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub(/\"/, "\\\""); print }' )" | |
65 | esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub(/`/, "\\`"); print }' )" | |
66 | ;; | |
67 | # 'bash') | |
68 | # # does not depend upon `sed` or `echo` quirks | |
69 | # # tested with bash `[ -n "${BASH_VERSION}" ]` | |
70 | # # tested with zsh `[ -n "${ZSH_NAME}" ]` | |
71 | # # tested with ksh93+ `ksh_ver="$(echo "$KSH_VERSION" | grep -m 1 -o '[0-9]\+' | head -n 1)"; [ "$ksh_ver" -gt 88 ]` | |
72 | # # fails in ksh88, dash, ash | |
73 | # esc_arg="${esc_arg//\\/\\\\}" # must be first since later patterns introduce backslash chars | |
74 | # esc_arg="${esc_arg//\$/\\\$}" | |
75 | # esc_arg="${esc_arg//\"/\\\"}" | |
76 | # esc_arg="${esc_arg//\`/\\\`}" | |
77 | # ;; | |
78 | '*') | |
79 | echo "could not determine escaping tool" | |
80 | exit 1 | |
81 | ;; | |
82 | esac | |
83 | # remove the padding Xs added above | |
84 | esc_arg="${esc_arg#X}" | |
85 | esc_arg="${esc_arg%X}" | |
86 | quoted_arg="\"$esc_arg\"" | |
87 | ||
88 | if $ant_exec_debug | |
89 | then | |
90 | # using printf to avoid echo line continuation and escape interpretation | |
91 | printf "arg : %s\n" "$arg" | |
92 | printf "quoted_arg: %s\n" "$quoted_arg" | |
93 | fi | |
94 | ant_exec_args="$ant_exec_args $quoted_arg" | |
39 | 95 | fi |
40 | 96 | done |
41 | 97 | |
331 | 387 | fi |
332 | 388 | ant_exec_command="exec \"\$JAVACMD\" $ANT_OPTS -classpath \"\$LOCALCLASSPATH\" -Dant.home=\"\$ANT_HOME\" -Dant.library.dir=\"\$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"\$CLASSPATH\"" |
333 | 389 | if $ant_exec_debug ; then |
334 | echo $ant_exec_command $ant_exec_args | |
335 | fi | |
336 | ||
337 | eval $ant_exec_command $ant_exec_args | |
390 | echo "$ant_exec_command $ant_exec_args" | |
391 | fi | |
392 | ||
393 | eval "$ant_exec_command $ant_exec_args" |
26 | 26 | <property name="test3.jar" location="${antunit.tmpdir}/test3.jar"/> |
27 | 27 | <property name="test4.jar" location="${antunit.tmpdir}/test4.jar"/> |
28 | 28 | <property name="test5.jar" location="${antunit.tmpdir}/test5.jar"/> |
29 | <condition property="jdk1.9+"> | |
30 | <contains string="${java.version}" substring="1.9."/> | |
31 | </condition> | |
29 | <available property="jdk9+" classname="java.lang.module.ModuleDescriptor"/> | |
32 | 30 | <available property="jdk1.8+" classname="java.lang.reflect.Executable"/> |
33 | 31 | <available property="jdk1.7+" classname="java.nio.file.FileSystem"/> |
34 | 32 | <available property="jdk1.6+" classname="java.net.CookieStore"/> |
0 | <?xml version="1.0"?> | |
1 | <!-- | |
2 | Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | contributor license agreements. See the NOTICE file distributed with | |
4 | this work for additional information regarding copyright ownership. | |
5 | The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | (the "License"); you may not use this file except in compliance with | |
7 | the License. You may obtain a copy of the License at | |
8 | ||
9 | http://www.apache.org/licenses/LICENSE-2.0 | |
10 | ||
11 | Unless required by applicable law or agreed to in writing, software | |
12 | distributed under the License is distributed on an "AS IS" BASIS, | |
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | See the License for the specific language governing permissions and | |
15 | limitations under the License. | |
16 | --> | |
17 | <project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> | |
18 | <import file="../antunit-base.xml" /> | |
19 | ||
20 | <target name="testForward"> | |
21 | <au:assertTrue> | |
22 | <resourcesmatch> | |
23 | <string value="\u00e4\u00f6\u00fc=\u00c4\u00d6\u00dc | |
24 | \u00df=\u20ac"/> | |
25 | <concat encoding="UTF-8" outputencoding="UTF-8"> | |
26 | <string value="äöü=ÄÖÜ | |
27 | ß=€"/> | |
28 | <filterchain> | |
29 | <native2asciifilter/> | |
30 | </filterchain> | |
31 | </concat> | |
32 | </resourcesmatch> | |
33 | </au:assertTrue> | |
34 | </target> | |
35 | ||
36 | <target name="testReverse"> | |
37 | <au:assertTrue> | |
38 | <resourcesmatch> | |
39 | <string value="äöü=ÄÖÜ | |
40 | ß=€"/> | |
41 | <concat encoding="UTF-8" outputencoding="UTF-8"> | |
42 | <string value="\u00e4\u00f6\u00fc=\u00c4\u00d6\u00dc | |
43 | \u00df=\u20ac"/> | |
44 | <filterchain> | |
45 | <native2asciifilter reverse="true"/> | |
46 | </filterchain> | |
47 | </concat> | |
48 | </resourcesmatch> | |
49 | </au:assertTrue> | |
50 | </target> | |
51 | ||
52 | </project> |
17 | 17 | <project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> |
18 | 18 | <import file="../antunit-base.xml" /> |
19 | 19 | |
20 | <property name="javac-dir" location="${output}/javac-dir" /> | |
21 | <property name="build-dir" location="${javac-dir}/build" /> | |
22 | ||
23 | <target name="test-includeDestClasses"> | |
20 | <target name="setup"> | |
21 | <property name="javac-dir" location="${output}/javac-dir" /> | |
22 | <property name="build-dir" location="${javac-dir}/build" /> | |
23 | <presetdef name="testJavac"> | |
24 | <javac srcdir="${javac-dir}/src" destdir="${javac-dir}/classes" | |
25 | includeantruntime="false"/> | |
26 | </presetdef> | |
27 | </target> | |
28 | ||
29 | <target name="test-includeDestClasses" depends="setup"> | |
24 | 30 | <property name="DATE" value="09/10/1999 4:30 pm" /> |
25 | 31 | <delete dir="${javac-dir}/src" /> |
26 | 32 | <mkdir dir="${javac-dir}/src" /> |
53 | 59 | </au:assertFalse> |
54 | 60 | </target> |
55 | 61 | |
56 | <target name="test-updated-property"> | |
62 | <target name="test-updated-property" depends="setup"> | |
57 | 63 | <delete quiet="yes" dir="${build-dir}" /> |
58 | 64 | <mkdir dir="${build-dir}" /> |
59 | 65 | <javac srcdir="javac-dir/good-src" destdir="${build-dir}" updatedProperty="classes-updated" /> |
66 | 72 | </au:assertFalse> |
67 | 73 | </target> |
68 | 74 | |
69 | <target name="test-error-property"> | |
75 | <target name="test-error-property" depends="setup"> | |
70 | 76 | <delete quiet="yes" dir="${build-dir}" /> |
71 | 77 | <mkdir dir="${build-dir}" /> |
72 | 78 | <javac srcdir="javac-dir/good-src" destdir="${build-dir}" failOnError="false" errorProperty="compile-failed" /> |
79 | 85 | </au:assertTrue> |
80 | 86 | </target> |
81 | 87 | |
82 | <target name="setUpForPackageInfoJava"> | |
88 | <target name="setUpForPackageInfoJava" depends="setup"> | |
83 | 89 | <mkdir dir="${javac-dir}/src/a" /> |
84 | 90 | <mkdir dir="${build-dir}" /> |
85 | 91 | <echo file="${javac-dir}/src/a/package-info.java"> |
150 | 156 | <au:assertFileDoesntExist file="${build-dir}/a/package-info.class"/> |
151 | 157 | </target> |
152 | 158 | |
153 | <target name="-create-javac-adapter"> | |
159 | <target name="-create-javac-adapter" depends="setup"> | |
154 | 160 | <property name="adapter.dir" location="${output}/adapter" /> |
155 | 161 | <mkdir dir="${input}/org/example" /> |
156 | 162 | <echo file="${input}/org/example/Adapter.java"> |
197 | 203 | <au:assertLogContains text="adapter called" /> |
198 | 204 | </target> |
199 | 205 | |
200 | <target name="testSourceAttributes" xmlns:if="ant:if" xmlns:unless="ant:unless"> | |
206 | <target name="testSourceAttributes" depends="setup" | |
207 | xmlns:if="ant:if" xmlns:unless="ant:unless"> | |
201 | 208 | <delete dir="${javac-dir}/src" /> |
202 | 209 | <mkdir dir="${javac-dir}/src" /> |
203 | 210 | <mkdir dir="${javac-dir}/classes" /> |
204 | 211 | <echo file="${javac-dir}/src/A.java"> |
205 | 212 | public class A { } |
206 | 213 | </echo> |
207 | <presetdef name="testJavac"> | |
208 | <javac srcdir="${javac-dir}/src" destdir="${javac-dir}/classes" includeantruntime="false"/> | |
209 | </presetdef> | |
210 | 214 | |
211 | 215 | <au:expectfailure> |
212 | 216 | <testJavac source="notValid"/> |
213 | 217 | </au:expectfailure> |
214 | 218 | |
215 | <sequential unless:set="jdk1.9+"> | |
219 | <sequential unless:set="jdk9+"> | |
216 | 220 | <echo>JDK 1.4+</echo> |
217 | 221 | <testJavac source="1.4"/> |
218 | 222 | <delete dir="${javac-dir}/classes"/> |
219 | 223 | <mkdir dir="${javac-dir}/classes"/> |
220 | 224 | </sequential> |
221 | 225 | |
222 | <sequential unless:set="jdk1.9+"> | |
226 | <sequential unless:set="jdk9+"> | |
223 | 227 | <echo>JDK 1.5+</echo> |
224 | 228 | <testJavac source="1.5"/> |
225 | 229 | <delete dir="${javac-dir}/classes"/> |
247 | 251 | <mkdir dir="${javac-dir}/classes"/> |
248 | 252 | </sequential> |
249 | 253 | |
250 | <sequential if:set="jdk1.9+"> | |
251 | <echo>JDK 1.9+</echo> | |
252 | <testJavac source="1.9"/> | |
254 | <sequential if:set="jdk9+"> | |
255 | <echo>JDK 9+</echo> | |
256 | <testJavac source="9"/> | |
253 | 257 | <delete dir="${javac-dir}/classes"/> |
254 | 258 | <mkdir dir="${javac-dir}/classes"/> |
255 | 259 | </sequential> |
256 | 260 | </target> |
257 | 261 | |
258 | <target name="testTargetAttributes" xmlns:if="ant:if" xmlns:unless="ant:unless"> | |
262 | <target name="testTargetAttributes" depends="setup" | |
263 | xmlns:if="ant:if" xmlns:unless="ant:unless"> | |
259 | 264 | <delete dir="${javac-dir}/src" /> |
260 | 265 | <mkdir dir="${javac-dir}/src" /> |
261 | 266 | <mkdir dir="${javac-dir}/classes" /> |
262 | 267 | <echo file="${javac-dir}/src/A.java"> |
263 | 268 | public class A { } |
264 | 269 | </echo> |
265 | <presetdef name="testJavac"> | |
266 | <javac srcdir="${javac-dir}/src" destdir="${javac-dir}/classes" includeantruntime="false"/> | |
267 | </presetdef> | |
268 | 270 | |
269 | 271 | <au:expectfailure> |
270 | 272 | <testJavac target="notValid"/> |
271 | 273 | </au:expectfailure> |
272 | 274 | |
273 | <sequential unless:set="jdk1.9+"> | |
275 | <sequential unless:set="jdk9+"> | |
274 | 276 | <echo>JDK 1.4+</echo> |
275 | 277 | <testJavac source="1.4" target="1.4"/> |
276 | 278 | <delete dir="${javac-dir}/classes"/> |
277 | 279 | <mkdir dir="${javac-dir}/classes"/> |
278 | 280 | </sequential> |
279 | 281 | |
280 | <sequential unless:set="jdk1.9+"> | |
282 | <sequential unless:set="jdk9+"> | |
281 | 283 | <echo>JDK 1.5+</echo> |
282 | 284 | <testJavac source="1.5" target="1.5"/> |
283 | 285 | <delete dir="${javac-dir}/classes"/> |
305 | 307 | <mkdir dir="${javac-dir}/classes"/> |
306 | 308 | </sequential> |
307 | 309 | |
308 | <sequential if:set="jdk1.9+"> | |
309 | <echo>JDK 1.9+</echo> | |
310 | <testJavac source="1.9" target="1.9"/> | |
310 | <sequential if:set="jdk9+"> | |
311 | <echo>JDK 9+</echo> | |
312 | <testJavac source="9" target="9"/> | |
311 | 313 | <delete dir="${javac-dir}/classes"/> |
312 | 314 | <mkdir dir="${javac-dir}/classes"/> |
313 | 315 | </sequential> |
314 | 316 | </target> |
317 | ||
318 | <target name="testJavacWithNativeHeaderGeneration" if="jdk1.8+" depends="setup"> | |
319 | <mkdir dir="${javac-dir}/src/org/example" /> | |
320 | <mkdir dir="${javac-dir}/classes"/> | |
321 | <mkdir dir="${javac-dir}/headers"/> | |
322 | <echo file="${javac-dir}/src/org/example/Foo.java"> | |
323 | <![CDATA[ | |
324 | package org.example; | |
325 | public class Foo { | |
326 | public Foo() {} | |
327 | public native String bar(Object baz); | |
328 | } | |
329 | ]]></echo> | |
330 | <echo file="${javac-dir}/src/org/example/Bar.java"> | |
331 | <![CDATA[ | |
332 | package org.example; | |
333 | public class Bar { | |
334 | public Bar() {} | |
335 | public String xyzzy(Object baz) { | |
336 | return new Foo().bar(baz); | |
337 | } | |
338 | } | |
339 | ]]></echo> | |
340 | <testJavac nativeheaderdir="${javac-dir}/headers"/> | |
341 | <au:assertFileExists file="${javac-dir}/headers/org_example_Foo.h"/> | |
342 | <au:assertFileDoesntExist file="${javac-dir}/headers/org_example_Bar.h"/> | |
343 | </target> | |
315 | 344 | </project> |
61 | 61 | </javah> |
62 | 62 | <au:assertLogContains text="adapter called" /> |
63 | 63 | </target> |
64 | ||
65 | <target name="-setupForRealJavahTests"> | |
66 | <condition property="sunjavah.present"> | |
67 | <or> | |
68 | <available classname="com.sun.tools.javah.oldjavah.Main"/> | |
69 | <available classname="com.sun.tools.javah.Main"/> | |
70 | </or> | |
71 | </condition> | |
72 | <mkdir dir="${input}/org/example"/> | |
73 | <mkdir dir="${output}/org/example"/> | |
74 | <echo file="${input}/org/example/Foo.java"> | |
75 | <![CDATA[ | |
76 | package org.example; | |
77 | public class Foo { | |
78 | public Foo() {} | |
79 | public native String bar(Object baz); | |
80 | } | |
81 | ]]></echo> | |
82 | <javac srcdir="${input}" destdir="${output}"/> | |
83 | <presetdef name="javah-single"> | |
84 | <javah destdir="${output}"> | |
85 | <class name="org.example.Foo"/> | |
86 | <classpath> | |
87 | <pathelement location="${output}"/> | |
88 | </classpath> | |
89 | </javah> | |
90 | </presetdef> | |
91 | <presetdef name="javah-fileset"> | |
92 | <javah destdir="${output}"> | |
93 | <fileset dir="${output}"> | |
94 | <include name="**/*.class"/> | |
95 | </fileset> | |
96 | <classpath> | |
97 | <pathelement location="${output}"/> | |
98 | </classpath> | |
99 | </javah> | |
100 | </presetdef> | |
101 | </target> | |
102 | ||
103 | <target name="testSimpleCompile" depends="-setupForRealJavahTests"> | |
104 | <javah-single/> | |
105 | <au:assertFileExists file="${output}/org_example_Foo.h"/> | |
106 | </target> | |
107 | ||
108 | <target name="testCompileUsingFileset" depends="-setupForRealJavahTests"> | |
109 | <javah-fileset/> | |
110 | <au:assertFileExists file="${output}/org_example_Foo.h"/> | |
111 | </target> | |
112 | ||
113 | <target name="testSimpleCompileSun" depends="-setupForRealJavahTests" | |
114 | if="sunjavah.present"> | |
115 | <javah-single implementation="sun"/> | |
116 | <au:assertFileExists file="${output}/org_example_Foo.h"/> | |
117 | </target> | |
118 | ||
119 | <target name="testCompileUsingFilesetSun" depends="-setupForRealJavahTests" | |
120 | if="sunjavah.present"> | |
121 | <javah-fileset implementation="sun"/> | |
122 | <au:assertFileExists file="${output}/org_example_Foo.h"/> | |
123 | </target> | |
124 | ||
125 | <target name="testSimpleCompileForking" depends="-setupForRealJavahTests"> | |
126 | <javah-single implementation="forking"/> | |
127 | <au:assertFileExists file="${output}/org_example_Foo.h"/> | |
128 | </target> | |
129 | ||
130 | <target name="testCompileUsingFilesetForking" depends="-setupForRealJavahTests"> | |
131 | <javah-fileset implementation="forking"/> | |
132 | <au:assertFileExists file="${output}/org_example_Foo.h"/> | |
133 | </target> | |
64 | 134 | </project> |
64 | 64 | </native2ascii> |
65 | 65 | <au:assertLogContains text="adapter called"/> |
66 | 66 | </target> |
67 | ||
68 | <target name="-real-test-macros"> | |
69 | <macrodef name="assertTranslatedOutput"> | |
70 | <attribute name="file"/> | |
71 | <attribute name="expected"/> | |
72 | <attribute name="encoding"/> | |
73 | <sequential> | |
74 | <loadfile srcFile="${output}/@{file}" encoding="@{encoding}" | |
75 | property="@{file}.actual"> | |
76 | <filterchain> | |
77 | <striplinebreaks/> | |
78 | </filterchain> | |
79 | </loadfile> | |
80 | <au:assertEquals expected="@{expected}" actual="${@{file}.actual}"/> | |
81 | </sequential> | |
82 | </macrodef> | |
83 | <presetdef name="native2ascii-def"> | |
84 | <native2ascii src="${input}" dest="${output}" encoding="UTF-8" | |
85 | includes="**/*.properties"/> | |
86 | </presetdef> | |
87 | </target> | |
88 | ||
89 | <target name="-setup-UTF8-To-ASCII" depends="-real-test-macros"> | |
90 | <mkdir dir="${input}"/> | |
91 | <mkdir dir="${output}"/> | |
92 | <echo file="${input}/umlauts.properties" encoding="UTF-8">äöü=ÄÖÜ</echo> | |
93 | <property name="umlauts.expected" | |
94 | value="\u00e4\u00f6\u00fc=\u00c4\u00d6\u00dc"/> | |
95 | </target> | |
96 | ||
97 | <target name="testUTF8-To-ASCII-sun" depends="-setup-UTF8-To-ASCII" | |
98 | description="https://bz.apache.org/bugzilla/show_bug.cgi?id=59855" | |
99 | unless="jdk9+"> | |
100 | <native2ascii-def implementation="sun"/> | |
101 | <assertTranslatedOutput file="umlauts.properties" encoding="ASCII" | |
102 | expected="${umlauts.expected}"/> | |
103 | </target> | |
104 | ||
105 | <target name="testUTF8-To-ASCII-builtin" depends="-setup-UTF8-To-ASCII" | |
106 | description="https://bz.apache.org/bugzilla/show_bug.cgi?id=59855"> | |
107 | <native2ascii-def implementation="builtin"/> | |
108 | <assertTranslatedOutput file="umlauts.properties" encoding="ASCII" | |
109 | expected="${umlauts.expected}"/> | |
110 | </target> | |
111 | ||
112 | <target name="-setup-ASCII-To-UTF8" depends="-real-test-macros"> | |
113 | <mkdir dir="${input}"/> | |
114 | <mkdir dir="${output}"/> | |
115 | <echo file="${input}/umlauts.properties" encoding="ASCII">\u00e4\u00f6\u00fc=\u00c4\u00d6\u00dc</echo> | |
116 | <property name="umlauts.expected" value="äöü=ÄÖÜ"/> | |
117 | </target> | |
118 | ||
119 | <target name="testASCII-To-UTF8-sun" depends="-setup-ASCII-To-UTF8" | |
120 | description="https://bz.apache.org/bugzilla/show_bug.cgi?id=59855" | |
121 | unless="jdk9+"> | |
122 | <native2ascii-def implementation="sun" reverse="true"/> | |
123 | <assertTranslatedOutput file="umlauts.properties" encoding="UTF-8" | |
124 | expected="${umlauts.expected}"/> | |
125 | </target> | |
126 | ||
127 | <target name="testASCII-To-UTF8-builtin" depends="-setup-ASCII-To-UTF8" | |
128 | description="https://bz.apache.org/bugzilla/show_bug.cgi?id=59855"> | |
129 | <native2ascii-def implementation="builtin" reverse="true"/> | |
130 | <assertTranslatedOutput file="umlauts.properties" encoding="UTF-8" | |
131 | expected="${umlauts.expected}"/> | |
132 | </target> | |
133 | ||
67 | 134 | </project> |
63 | 63 | <au:assertLogContains text="fileset-test.xml"/> |
64 | 64 | </target> |
65 | 65 | |
66 | <target name="test-fileset-dir-and-file-exception"> | |
67 | <mkdir dir="${output}"/> | |
68 | <au:expectfailure expectedmessage="you can only specify one of the dir and file attributes"> | |
69 | <copy todir="${output}"> | |
70 | <fileset dir="foo" file="bar" /> | |
71 | </copy> | |
72 | </au:expectfailure> | |
73 | </target> | |
74 | ||
75 | <target name="test-fileset-file-and-dir-exception"> | |
76 | <mkdir dir="${output}"/> | |
77 | <au:expectfailure expectedmessage="you can only specify one of the dir and file attributes"> | |
78 | <copy todir="${output}"> | |
79 | <fileset file="bar" dir="foo"/> | |
80 | </copy> | |
81 | </au:expectfailure> | |
82 | </target> | |
83 | ||
66 | 84 | </project> |
194 | 194 | int startMessage = log.indexOf("CLASSPATH element "); |
195 | 195 | assertTrue(startMessage >= 0); |
196 | 196 | assertTrue(log.indexOf("foo.jar is not a JAR", startMessage) > 0); |
197 | log = errBuffer.toString(); | |
198 | startMessage = log.indexOf("CLASSPATH element "); | |
199 | assertTrue(startMessage >= 0); | |
200 | assertTrue(log.indexOf("foo.jar is not a JAR", startMessage) > 0); | |
201 | 197 | } finally { |
202 | 198 | System.setErr(sysErr); |
203 | 199 | } |
23 | 23 | import org.apache.tools.ant.BuildException; |
24 | 24 | import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory; |
25 | 25 | import org.apache.tools.ant.taskdefs.rmic.DefaultRmicAdapter; |
26 | import org.apache.tools.ant.util.JavaEnvUtils; | |
26 | 27 | import org.junit.Before; |
27 | 28 | import org.junit.Ignore; |
28 | 29 | import org.junit.Rule; |
29 | 30 | import org.junit.Test; |
30 | 31 | |
32 | import static org.junit.Assert.assertEquals; | |
31 | 33 | import static org.junit.Assert.fail; |
32 | 34 | |
33 | 35 | /** |
136 | 138 | * test weblogic |
137 | 139 | */ |
138 | 140 | @Test |
139 | @Ignore("WLRmin tests don't work") | |
141 | @Ignore("WLRmic tests don't work") | |
140 | 142 | public void XtestWlrmic() throws Exception { |
141 | 143 | buildRule.executeTarget("testWlrmic"); |
142 | 144 | } |
145 | 147 | * test weblogic's stripping of -J args |
146 | 148 | */ |
147 | 149 | @Test |
148 | @Ignore("WLRmin tests don't work") | |
150 | @Ignore("WLRmic tests don't work") | |
149 | 151 | public void XtestWlrmicJArg() throws Exception { |
150 | 152 | buildRule.executeTarget("testWlrmicJArg"); |
151 | 153 | } |
154 | 156 | * test the forking compiler |
155 | 157 | */ |
156 | 158 | @Test |
157 | @Ignore("WLRmin tests don't work") | |
158 | public void NotestForking() throws Exception { | |
159 | public void testForking() throws Exception { | |
159 | 160 | buildRule.executeTarget("testForking"); |
160 | 161 | } |
161 | 162 | |
352 | 353 | */ |
353 | 354 | @Test |
354 | 355 | public void testXnew() throws Exception { |
356 | // skipped via unless attribute for JDK > 6 | |
355 | 357 | buildRule.executeTarget("testXnew"); |
356 | 358 | } |
357 | 359 | |
362 | 364 | */ |
363 | 365 | @Test |
364 | 366 | public void testXnewDest() throws Exception { |
367 | // skipped via unless attribute for JDK > 6 | |
365 | 368 | buildRule.executeTarget("testXnewDest"); |
366 | 369 | } |
367 | 370 | |
372 | 375 | */ |
373 | 376 | @Test |
374 | 377 | public void testXnewForked() throws Exception { |
375 | buildRule.executeTarget("testXnewForked"); | |
378 | xnewTest("testXnewForked"); | |
376 | 379 | } |
377 | 380 | |
378 | 381 | /** |
382 | 385 | */ |
383 | 386 | @Test |
384 | 387 | public void testXnewForkedDest() throws Exception { |
385 | buildRule.executeTarget("testXnewForkedDest"); | |
388 | xnewTest("testXnewForkedDest"); | |
386 | 389 | } |
387 | 390 | |
388 | 391 | /** |
392 | 395 | */ |
393 | 396 | @Test |
394 | 397 | public void testXnewCompiler() throws Exception { |
395 | buildRule.executeTarget("testXnewCompiler"); | |
398 | xnewTest("testXnewCompiler"); | |
396 | 399 | } |
397 | 400 | |
398 | 401 | /** |
402 | 405 | */ |
403 | 406 | @Test |
404 | 407 | public void testXnewCompilerDest() throws Exception { |
405 | buildRule.executeTarget("testXnewCompilerDest"); | |
408 | xnewTest("testXnewCompilerDest"); | |
406 | 409 | } |
407 | 410 | |
408 | 411 | /** |
443 | 446 | @Test |
444 | 447 | public void testIIOPDest() throws Exception { |
445 | 448 | buildRule.executeTarget("testIIOPDest"); |
449 | } | |
450 | ||
451 | private void xnewTest(String target) { | |
452 | if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | |
453 | buildRule.executeTarget(target); | |
454 | } else { | |
455 | try { | |
456 | buildRule.executeTarget(target); | |
457 | fail("Target should have thrown a BuildException"); | |
458 | } catch (BuildException ex) { | |
459 | assertEquals("JDK9 has removed support for -Xnew", ex.getMessage()); | |
460 | } | |
461 | } | |
446 | 462 | } |
447 | 463 | |
448 | 464 | /** |
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
299 | @Test | |
300 | public void testRegexpMapper() throws IOException { | |
301 | buildRule.executeTarget("testRegexpMapper1"); | |
302 | File testFile = new File(buildRule.getOutputDir(), "regexp.zip"); | |
303 | long l = testFile.lastModified(); | |
304 | buildRule.executeTarget("testRegexpMapper2"); | |
305 | assertEquals(l, testFile.lastModified()); | |
306 | } | |
299 | 307 | } |
+100
-7
56 | 56 | boolean debug) { |
57 | 57 | return cmd; |
58 | 58 | } |
59 | ||
60 | public boolean execute() { return false; } | |
61 | ||
62 | /** | |
63 | * public to avoid classloader issues. | |
64 | */ | |
65 | public Commandline setupModernJavacCommandlineSwitches(Commandline cmd) { | |
66 | return super.setupModernJavacCommandlineSwitches(cmd); | |
67 | } | |
68 | } | |
69 | ||
70 | private static class SourceTargetHelperNoOverride extends DefaultCompilerAdapter { | |
59 | 71 | |
60 | 72 | public boolean execute() { return false; } |
61 | 73 | |
182 | 194 | + " -source 8", "8"); |
183 | 195 | testSource(null, "javac1.9", "", "1.9"); |
184 | 196 | testSource(null, "javac1.9", "", "9"); |
197 | } | |
198 | ||
199 | @Test | |
200 | public void testImplicitSourceForJava9() { | |
201 | commonSourceDowngrades("javac9"); | |
202 | testSource("1.5", "javac9", | |
203 | "If you specify -target 1.5 you now must also specify" | |
204 | + " -source 1.5", "1.5"); | |
205 | testSource("1.6", "javac1.9", | |
206 | "If you specify -target 1.6 you now must also specify" | |
207 | + " -source 1.6", "1.6"); | |
208 | testSource("1.7", "javac9", | |
209 | "If you specify -target 1.7 you now must also specify" | |
210 | + " -source 1.7", "1.7"); | |
211 | testSource("1.8", "javac9", | |
212 | "If you specify -target 1.8 you now must also specify" | |
213 | + " -source 1.8", "1.8"); | |
214 | testSource("5", "javac9", | |
215 | "If you specify -target 5 you now must also specify" | |
216 | + " -source 5", "5"); | |
217 | testSource("6", "javac9", | |
218 | "If you specify -target 6 you now must also specify" | |
219 | + " -source 6", "6"); | |
220 | testSource("7", "javac9", | |
221 | "If you specify -target 7 you now must also specify" | |
222 | + " -source 7", "7"); | |
223 | testSource("8", "javac9", | |
224 | "If you specify -target 8 you now must also specify" | |
225 | + " -source 8", "8"); | |
226 | testSource(null, "javac9", "", "1.9"); | |
227 | testSource(null, "javac9", "", "9"); | |
185 | 228 | } |
186 | 229 | |
187 | 230 | @Test |
217 | 260 | Assert.assertNotNull(cmd[0]); |
218 | 261 | final List<String> cmdLine = Arrays.asList(cmd[0].getCommandline()); |
219 | 262 | //No modulesourcepath |
220 | assertEquals(-1, cmdLine.indexOf("-modulesourcepath")); | |
263 | assertEquals(-1, cmdLine.indexOf("--module-source-path")); | |
221 | 264 | //The -sourcepath has to be followed by src |
222 | 265 | int index = cmdLine.indexOf("-sourcepath"); |
223 | 266 | Assert.assertTrue(index != -1 && index < cmdLine.size() - 1); |
224 | 267 | assertEquals(src.getAbsolutePath(), cmdLine.get(index + 1)); |
225 | //The -modulepath has to be followed by modules | |
226 | index = cmdLine.indexOf("-modulepath"); | |
268 | //The --module-path has to be followed by modules | |
269 | index = cmdLine.indexOf("--module-path"); | |
227 | 270 | Assert.assertTrue(index != -1 && index < cmdLine.size() - 1); |
228 | 271 | assertEquals(modules.getAbsolutePath(), cmdLine.get(index + 1)); |
229 | 272 | //J1.java & J2.java has to be in files list |
276 | 319 | final List<String> cmdLine = Arrays.asList(cmd[0].getCommandline()); |
277 | 320 | //No sourcepath |
278 | 321 | assertEquals(-1, cmdLine.indexOf("-sourcepath")); |
279 | //The -modulesourcepath has to be followed by the pattern | |
280 | int index = cmdLine.indexOf("-modulesourcepath"); | |
322 | //The --module-source-path has to be followed by the pattern | |
323 | int index = cmdLine.indexOf("--module-source-path"); | |
281 | 324 | Assert.assertTrue(index != -1 && index < cmdLine.size() - 1); |
282 | 325 | String expectedModSrcPath = String.format("%s/%s", |
283 | 326 | workDir.getAbsolutePath(), |
285 | 328 | .replace('/', File.separatorChar) |
286 | 329 | .replace('\\', File.separatorChar); |
287 | 330 | assertEquals(expectedModSrcPath, cmdLine.get(index + 1)); |
288 | //The -modulepath has to be followed by modules | |
289 | index = cmdLine.indexOf("-modulepath"); | |
331 | //The --module-path has to be followed by modules | |
332 | index = cmdLine.indexOf("--module-path"); | |
290 | 333 | Assert.assertTrue(index != -1 && index < cmdLine.size() - 1); |
291 | 334 | assertEquals(modules.getAbsolutePath(), cmdLine.get(index + 1)); |
292 | 335 | //J1.java, J2.java & J3.java has to be in files list |
352 | 395 | } |
353 | 396 | } |
354 | 397 | |
398 | @Test | |
399 | public void releaseIsIgnoredForJava8() { | |
400 | LogCapturingJavac javac = new LogCapturingJavac(); | |
401 | Project p = new Project(); | |
402 | javac.setProject(p); | |
403 | javac.setCompiler("javac8"); | |
404 | javac.setSource("6"); | |
405 | javac.setTarget("6"); | |
406 | javac.setRelease("6"); | |
407 | javac.setSourcepath(new Path(p)); | |
408 | SourceTargetHelperNoOverride sth = new SourceTargetHelperNoOverride(); | |
409 | sth.setJavac(javac); | |
410 | Commandline cmd = new Commandline(); | |
411 | sth.setupModernJavacCommandlineSwitches(cmd); | |
412 | assertContains("Support for javac --release has been added in " | |
413 | + "Java9 ignoring it", javac.getLog()); | |
414 | String[] args = cmd.getCommandline(); | |
415 | assertEquals(7, args.length); | |
416 | assertEquals("-classpath", args[0]); | |
417 | assertEquals("-target", args[2]); | |
418 | assertEquals("6", args[3]); | |
419 | assertEquals("-g:none", args[4]); | |
420 | assertEquals("-source", args[5]); | |
421 | assertEquals("6", args[6]); | |
422 | } | |
423 | ||
424 | @Test | |
425 | public void releaseIsUsedForJava9() { | |
426 | LogCapturingJavac javac = new LogCapturingJavac(); | |
427 | Project p = new Project(); | |
428 | javac.setProject(p); | |
429 | javac.setCompiler("javac9"); | |
430 | javac.setSource("6"); | |
431 | javac.setTarget("6"); | |
432 | javac.setRelease("6"); | |
433 | javac.setSourcepath(new Path(p)); | |
434 | SourceTargetHelperNoOverride sth = new SourceTargetHelperNoOverride(); | |
435 | sth.setJavac(javac); | |
436 | Commandline cmd = new Commandline(); | |
437 | sth.setupModernJavacCommandlineSwitches(cmd); | |
438 | assertContains("Ignoring source, target and bootclasspath as " | |
439 | + "release has been set", javac.getLog()); | |
440 | String[] args = cmd.getCommandline(); | |
441 | assertEquals(5, args.length); | |
442 | assertEquals("-classpath", args[0]); | |
443 | assertEquals("-g:none", args[2]); | |
444 | assertEquals("--release", args[3]); | |
445 | assertEquals("6", args[4]); | |
446 | } | |
447 | ||
355 | 448 | private void commonSourceDowngrades(String javaVersion) { |
356 | 449 | testSource("1.3", javaVersion, |
357 | 450 | "If you specify -target 1.1 you now must also specify" |
0 | package org.apache.tools.ant.taskdefs.optional; | |
1 | ||
2 | import static org.junit.Assert.assertTrue; | |
3 | ||
4 | import java.io.ByteArrayInputStream; | |
5 | import java.io.File; | |
6 | import java.io.InputStream; | |
7 | import java.security.Permission; | |
8 | ||
9 | import junit.framework.AssertionFailedError; | |
10 | ||
11 | import org.apache.tools.ant.BuildException; | |
12 | import org.apache.tools.ant.taskdefs.XSLTLiaison; | |
13 | import org.apache.tools.ant.taskdefs.XSLTLogger; | |
14 | import org.apache.tools.ant.util.JAXPUtils; | |
15 | import org.junit.After; | |
16 | import org.junit.Assume; | |
17 | import org.junit.Test; | |
18 | ||
19 | 0 | /* |
20 | 1 | * Licensed to the Apache Software Foundation (ASF) under one or more |
21 | 2 | * contributor license agreements. See the NOTICE file distributed with |
34 | 15 | * |
35 | 16 | */ |
36 | 17 | |
18 | package org.apache.tools.ant.taskdefs.optional; | |
19 | ||
20 | import static org.junit.Assert.assertTrue; | |
21 | ||
22 | import java.io.ByteArrayInputStream; | |
23 | import java.io.File; | |
24 | import java.io.InputStream; | |
25 | import java.security.Permission; | |
26 | import javax.xml.transform.TransformerFactory; | |
27 | import javax.xml.transform.TransformerFactoryConfigurationError; | |
28 | ||
29 | import junit.framework.AssertionFailedError; | |
30 | ||
31 | import org.apache.tools.ant.BuildException; | |
32 | import org.apache.tools.ant.taskdefs.XSLTLiaison; | |
33 | import org.apache.tools.ant.taskdefs.XSLTLogger; | |
34 | import org.apache.tools.ant.util.JAXPUtils; | |
35 | import org.junit.After; | |
36 | import org.junit.Assume; | |
37 | import org.junit.Test; | |
38 | ||
37 | 39 | /** |
38 | 40 | * TraX XSLTLiaison testcase |
39 | 41 | */ |
41 | 43 | implements XSLTLogger { |
42 | 44 | |
43 | 45 | |
44 | @After | |
46 | @After | |
45 | 47 | public void tearDown() { |
46 | 48 | File f = new File("xalan2-redirect-out.tmp"); |
47 | 49 | if (f.exists()) { |
56 | 58 | } |
57 | 59 | |
58 | 60 | @Test |
59 | public void testXalan2Redirect() throws Exception { | |
60 | try { | |
61 | getClass().getClassLoader().loadClass("org.apache.xalan.lib.Redirect"); | |
62 | } catch (Exception exc) { | |
63 | Assume.assumeNoException("xalan redirect is not on the classpath", exc); | |
64 | } | |
61 | public void testXalan2RedirectViaJDKFactory() throws Exception { | |
62 | try { | |
63 | getClass().getClassLoader().loadClass("org.apache.xalan.lib.Redirect"); | |
64 | } catch (Exception exc) { | |
65 | Assume.assumeNoException("xalan redirect is not on the classpath", exc); | |
66 | } | |
67 | try { | |
68 | String factoryName = TransformerFactory.newInstance().getClass().getName(); | |
69 | Assume.assumeFalse("TraxFactory is Xalan", | |
70 | "org.apache.xalan.processor.TransformerFactoryImpl" | |
71 | .equals(factoryName)); | |
72 | } catch (TransformerFactoryConfigurationError exc) { | |
73 | throw new RuntimeException(exc); | |
74 | } | |
65 | 75 | File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl"); |
66 | 76 | liaison.setStylesheet(xsl); |
77 | ((TraXLiaison) liaison) | |
78 | .setFeature("http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions", true); | |
67 | 79 | File out = new File("xalan2-redirect-out-dummy.tmp"); |
68 | 80 | File in = getFile("/taskdefs/optional/xsltliaison-in.xsl"); |
69 | 81 | ClassLoader orig = Thread.currentThread().getContextClassLoader(); |
85 | 97 | } finally { |
86 | 98 | out.delete(); |
87 | 99 | Thread.currentThread().setContextClassLoader(orig); |
100 | System.setSecurityManager(null); | |
101 | } | |
102 | } | |
103 | ||
104 | @Test | |
105 | public void testXalan2RedirectViaXalan() throws Exception { | |
106 | try { | |
107 | getClass().getClassLoader().loadClass("org.apache.xalan.lib.Redirect"); | |
108 | } catch (Exception exc) { | |
109 | Assume.assumeNoException("xalan redirect is not on the classpath", exc); | |
110 | } | |
111 | try { | |
112 | String factoryName = TransformerFactory.newInstance().getClass().getName(); | |
113 | Assume.assumeTrue("TraxFactory is " + factoryName + " and not Xalan", | |
114 | "org.apache.xalan.processor.TransformerFactoryImpl" | |
115 | .equals(factoryName)); | |
116 | } catch (TransformerFactoryConfigurationError exc) { | |
117 | throw new RuntimeException(exc); | |
118 | } | |
119 | File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl"); | |
120 | liaison.setStylesheet(xsl); | |
121 | File out = new File("xalan2-redirect-out-dummy.tmp"); | |
122 | File in = getFile("/taskdefs/optional/xsltliaison-in.xsl"); | |
123 | try { | |
124 | liaison.addParam("xalan-version", "2"); | |
125 | System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}}); | |
126 | liaison.transform(in, out); | |
127 | } finally { | |
128 | out.delete(); | |
88 | 129 | System.setSecurityManager(null); |
89 | 130 | } |
90 | 131 | } |
+129
-113
22 | 22 | import static org.apache.tools.ant.AntAssert.assertContains; |
23 | 23 | import static org.junit.Assert.fail; |
24 | 24 | |
25 | import java.io.ByteArrayInputStream; | |
25 | 26 | import java.io.File; |
26 | 27 | import java.io.FileReader; |
27 | 28 | import java.io.InputStream; |
29 | import java.io.IOException; | |
28 | 30 | import java.net.URL; |
31 | import java.security.Permission; | |
32 | import javax.xml.transform.TransformerFactory; | |
33 | import javax.xml.transform.TransformerFactoryConfigurationError; | |
29 | 34 | |
30 | 35 | import org.apache.tools.ant.BuildFileRule; |
31 | 36 | import org.apache.tools.ant.util.FileUtils; |
37 | import org.junit.Assume; | |
32 | 38 | import org.junit.Before; |
33 | 39 | import org.junit.Rule; |
34 | 40 | import org.junit.Test; |
39 | 45 | * |
40 | 46 | */ |
41 | 47 | public class JUnitReportTest { |
42 | ||
43 | @Rule | |
44 | public BuildFileRule buildRule = new BuildFileRule(); | |
45 | ||
46 | @Before | |
48 | ||
49 | @Rule | |
50 | public BuildFileRule buildRule = new BuildFileRule(); | |
51 | ||
52 | @Before | |
47 | 53 | public void setUp() { |
48 | 54 | buildRule.configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml"); |
49 | 55 | } |
53 | 59 | * output is selected via the default. |
54 | 60 | * Needs reports1 task from junitreport.xml. |
55 | 61 | */ |
56 | @Test | |
62 | @Test | |
57 | 63 | public void testNoFileJUnitNoFrames() { |
58 | 64 | buildRule.executeTarget("reports1"); |
59 | 65 | assertFalse("No file junit-noframes.html expected", (new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists())); |
60 | ||
66 | ||
61 | 67 | } |
62 | 68 | |
63 | 69 | public void assertIndexCreated() { |
64 | if (!new File(buildRule.getProject().getProperty("output"), "html/index.html").exists()) { | |
65 | fail("No file index file found"); | |
66 | } | |
67 | ||
68 | } | |
69 | ||
70 | ||
71 | @Test | |
72 | public void testEmptyFile() throws Exception { | |
73 | buildRule.executeTarget("testEmptyFile"); | |
74 | assertIndexCreated(); | |
75 | assertContains("Required text not found in log", XMLResultAggregator.WARNING_EMPTY_FILE, buildRule.getLog()); | |
76 | } | |
77 | ||
78 | @Test | |
79 | public void testIncompleteFile() throws Exception { | |
80 | buildRule.executeTarget("testIncompleteFile"); | |
81 | assertIndexCreated(); | |
82 | assertContains("Required text not found in log", XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED, buildRule.getLog()); | |
83 | } | |
84 | ||
85 | @Test | |
86 | public void testWrongElement() throws Exception { | |
87 | buildRule.executeTarget("testWrongElement"); | |
88 | assertIndexCreated(); | |
89 | assertContains("Required text not found in log", XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT, buildRule.getLog()); | |
90 | } | |
91 | ||
92 | // Bugzilla Report 34963 | |
93 | @Test | |
94 | public void testStackTraceLineBreaks() throws Exception { | |
95 | buildRule.executeTarget("testStackTraceLineBreaks"); | |
96 | assertIndexCreated(); | |
97 | FileReader r = null; | |
98 | try { | |
99 | r = new FileReader(new File(buildRule.getOutputDir(), "html/sampleproject/coins/0_CoinTest.html")); | |
100 | String report = FileUtils.readFully(r); | |
101 | assertContains("output must contain <br>:\n" + report, "junit.framework.AssertionFailedError: DOEG<br>", report); | |
102 | assertContains("#51049: output must translate line breaks:\n" + report, "cur['line.separator'] = '\\r\\n';", report); | |
103 | } finally { | |
104 | FileUtils.close(r); | |
105 | } | |
106 | } | |
107 | ||
108 | ||
109 | // Bugzilla Report 38477 | |
110 | @Test | |
111 | public void testSpecialSignsInSrcPath() throws Exception { | |
112 | buildRule.executeTarget("testSpecialSignsInSrcPath"); | |
70 | try { | |
71 | commonIndexFileAssertions(); | |
72 | } catch (IOException ex) { | |
73 | throw new RuntimeException(ex); | |
74 | } | |
75 | } | |
76 | ||
77 | private File commonIndexFileAssertions() throws IOException { | |
113 | 78 | File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); |
79 | commonIndexFileAssertions(reportFile); | |
80 | return reportFile; | |
81 | } | |
82 | ||
83 | private void commonIndexFileAssertions(File reportFile) throws IOException { | |
114 | 84 | // tests one the file object |
115 | 85 | assertTrue("No index.html present. Not generated?", reportFile.exists() ); |
116 | 86 | assertTrue("Cant read the report file.", reportFile.canRead() ); |
118 | 88 | // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report |
119 | 89 | URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); |
120 | 90 | InputStream reportStream = reportUrl.openStream(); |
121 | assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); | |
91 | try { | |
92 | assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); | |
93 | } finally { | |
94 | FileUtils.getFileUtils().close(reportStream); | |
95 | } | |
96 | } | |
97 | ||
98 | @Test | |
99 | public void testEmptyFile() throws Exception { | |
100 | buildRule.executeTarget("testEmptyFile"); | |
101 | assertIndexCreated(); | |
102 | assertContains("Required text not found in log", XMLResultAggregator.WARNING_EMPTY_FILE, buildRule.getLog()); | |
103 | } | |
104 | ||
105 | @Test | |
106 | public void testIncompleteFile() throws Exception { | |
107 | buildRule.executeTarget("testIncompleteFile"); | |
108 | assertIndexCreated(); | |
109 | assertContains("Required text not found in log", XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED, buildRule.getLog()); | |
110 | } | |
111 | ||
112 | @Test | |
113 | public void testWrongElement() throws Exception { | |
114 | buildRule.executeTarget("testWrongElement"); | |
115 | assertIndexCreated(); | |
116 | assertContains("Required text not found in log", XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT, buildRule.getLog()); | |
117 | } | |
118 | ||
119 | // Bugzilla Report 34963 | |
120 | @Test | |
121 | public void testStackTraceLineBreaks() throws Exception { | |
122 | buildRule.executeTarget("testStackTraceLineBreaks"); | |
123 | assertIndexCreated(); | |
124 | FileReader r = null; | |
125 | try { | |
126 | r = new FileReader(new File(buildRule.getOutputDir(), "html/sampleproject/coins/0_CoinTest.html")); | |
127 | String report = FileUtils.readFully(r); | |
128 | assertContains("output must contain <br>:\n" + report, "junit.framework.AssertionFailedError: DOEG<br>", report); | |
129 | assertContains("#51049: output must translate line breaks:\n" + report, "cur['line.separator'] = '\\r\\n';", report); | |
130 | } finally { | |
131 | FileUtils.close(r); | |
132 | } | |
133 | } | |
134 | ||
135 | ||
136 | // Bugzilla Report 38477 | |
137 | @Test | |
138 | public void testSpecialSignsInSrcPath() throws Exception { | |
139 | buildRule.executeTarget("testSpecialSignsInSrcPath"); | |
140 | commonIndexFileAssertions(); | |
122 | 141 | } |
123 | 142 | |
124 | 143 | @Test |
125 | 144 | public void testSpecialSignsInHtmlPath() throws Exception { |
126 | 145 | buildRule.executeTarget("testSpecialSignsInHtmlPath"); |
127 | 146 | File reportFile = new File(buildRule.getOutputDir(), "html# $%\u00A7&-!report/index.html"); |
128 | // tests one the file object | |
129 | assertTrue("No index.html present. Not generated?", reportFile.exists() ); | |
130 | assertTrue("Cant read the report file.", reportFile.canRead() ); | |
131 | assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); | |
132 | // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report | |
133 | URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); | |
134 | InputStream reportStream = reportUrl.openStream(); | |
135 | assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); | |
147 | commonIndexFileAssertions(reportFile); | |
136 | 148 | } |
137 | 149 | |
138 | 150 | //Bugzilla Report 39708 |
139 | 151 | @Test |
140 | 152 | public void testWithStyleFromDir() throws Exception { |
141 | 153 | buildRule.executeTarget("testWithStyleFromDir"); |
142 | File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); | |
143 | // tests one the file object | |
144 | assertTrue("No index.html present. Not generated?", reportFile.exists() ); | |
145 | assertTrue("Cant read the report file.", reportFile.canRead() ); | |
146 | assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); | |
147 | // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report | |
148 | URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); | |
149 | InputStream reportStream = reportUrl.openStream(); | |
150 | assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); | |
154 | commonIndexFileAssertions(); | |
151 | 155 | } |
152 | 156 | |
153 | 157 | //Bugzilla Report 40021 |
155 | 159 | public void testNoFrames() throws Exception { |
156 | 160 | buildRule.executeTarget("testNoFrames"); |
157 | 161 | File reportFile = new File(buildRule.getOutputDir(), "html/junit-noframes.html"); |
158 | // tests one the file object | |
159 | assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() ); | |
160 | assertTrue("Cant read the report file.", reportFile.canRead() ); | |
161 | assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); | |
162 | // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report | |
163 | URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); | |
164 | InputStream reportStream = reportUrl.openStream(); | |
165 | assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); | |
166 | } | |
162 | commonIndexFileAssertions(reportFile); | |
163 | } | |
164 | ||
167 | 165 | //Bugzilla Report 39708 |
168 | 166 | @Test |
169 | 167 | public void testWithStyleFromDirAndXslImport() throws Exception { |
170 | 168 | buildRule.executeTarget("testWithStyleFromDirAndXslImport"); |
171 | File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); | |
172 | // tests one the file object | |
173 | assertTrue("No index.html present. Not generated?", reportFile.exists() ); | |
174 | assertTrue("Cant read the report file.", reportFile.canRead() ); | |
175 | assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); | |
176 | // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report | |
177 | URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); | |
178 | InputStream reportStream = reportUrl.openStream(); | |
179 | assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); | |
169 | commonIndexFileAssertions(); | |
180 | 170 | } |
181 | 171 | |
182 | 172 | @Test |
183 | 173 | public void testWithStyleFromClasspath() throws Exception { |
184 | 174 | buildRule.executeTarget("testWithStyleFromClasspath"); |
185 | File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); | |
186 | // tests one the file object | |
187 | assertTrue("No index.html present. Not generated?", reportFile.exists() ); | |
188 | assertTrue("Cant read the report file.", reportFile.canRead() ); | |
189 | assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); | |
190 | // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report | |
191 | URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); | |
192 | InputStream reportStream = reportUrl.openStream(); | |
193 | assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); | |
175 | commonIndexFileAssertions(); | |
194 | 176 | } |
195 | 177 | |
196 | 178 | @Test |
197 | 179 | public void testWithParams() throws Exception { |
198 | buildRule.executeTarget("testWithParams"); | |
199 | assertContains("key1=value1,key2=value2", buildRule.getLog()); | |
200 | File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); | |
201 | // tests one the file object | |
202 | assertTrue("No index.html present. Not generated?", reportFile.exists() ); | |
203 | assertTrue("Cant read the report file.", reportFile.canRead() ); | |
204 | assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); | |
205 | // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report | |
206 | URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); | |
207 | InputStream reportStream = reportUrl.openStream(); | |
208 | assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); | |
209 | } | |
180 | buildRule.executeTarget("testWithParams"); | |
181 | assertContains("key1=value1,key2=value2", buildRule.getLog()); | |
182 | commonIndexFileAssertions(); | |
183 | } | |
184 | ||
185 | @Test | |
186 | public void testWithSecurityManagerAndXalanFactory() throws Exception { | |
187 | try { | |
188 | String factoryName = TransformerFactory.newInstance().getClass().getName(); | |
189 | Assume.assumeTrue("TraxFactory is " + factoryName + " and not Xalan", | |
190 | "org.apache.xalan.processor.TransformerFactoryImpl" | |
191 | .equals(factoryName)); | |
192 | } catch (TransformerFactoryConfigurationError exc) { | |
193 | throw new RuntimeException(exc); | |
194 | } | |
195 | try { | |
196 | System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}}); | |
197 | buildRule.executeTarget("testWithStyleFromClasspath"); | |
198 | commonIndexFileAssertions(); | |
199 | } finally { | |
200 | System.setSecurityManager(null); | |
201 | } | |
202 | } | |
203 | ||
204 | @Test | |
205 | public void testWithSecurityManagerAndJDKFactory() throws Exception { | |
206 | ClassLoader orig = Thread.currentThread().getContextClassLoader(); | |
207 | try { | |
208 | Thread.currentThread().setContextClassLoader(new ClassLoader(ClassLoader.getSystemClassLoader().getParent()) { | |
209 | public InputStream getResourceAsStream(String name) { | |
210 | if (name.startsWith("META-INF/services/")) { | |
211 | // work around JAXP #6723276 in JDK 6 | |
212 | return new ByteArrayInputStream(new byte[0]); | |
213 | } | |
214 | return super.getResourceAsStream(name); | |
215 | } | |
216 | }); | |
217 | System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}}); | |
218 | buildRule.executeTarget("testWithStyleFromClasspath"); | |
219 | commonIndexFileAssertions(); | |
220 | } finally { | |
221 | System.setSecurityManager(null); | |
222 | Thread.currentThread().setContextClassLoader(orig); | |
223 | } | |
224 | } | |
225 | ||
210 | 226 | } |
26 | 26 | import static org.apache.tools.ant.AntAssert.assertContains; |
27 | 27 | |
28 | 28 | import java.io.BufferedReader; |
29 | import java.io.ByteArrayInputStream; | |
30 | import java.io.ByteArrayOutputStream; | |
29 | 31 | import java.io.File; |
30 | 32 | import java.io.FileReader; |
31 | 33 | import java.io.IOException; |
34 | import java.io.InputStream; | |
35 | import java.io.OutputStream; | |
36 | import java.util.Arrays; | |
37 | import java.util.Collections; | |
38 | import java.util.Set; | |
39 | import java.util.TreeSet; | |
32 | 40 | |
33 | 41 | import javax.xml.parsers.DocumentBuilder; |
34 | 42 | import javax.xml.parsers.DocumentBuilderFactory; |
35 | 43 | import javax.xml.xpath.XPath; |
36 | 44 | import javax.xml.xpath.XPathConstants; |
37 | 45 | import javax.xml.xpath.XPathFactory; |
46 | import org.apache.tools.ant.BuildException; | |
38 | 47 | |
39 | 48 | import org.apache.tools.ant.BuildFileRule; |
49 | import org.apache.tools.ant.MagicNames; | |
50 | import org.apache.tools.ant.Project; | |
51 | import org.apache.tools.ant.taskdefs.launcher.CommandLauncher; | |
52 | import org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.ForkMode; | |
53 | import org.apache.tools.ant.types.Path; | |
40 | 54 | import org.apache.tools.ant.util.JavaEnvUtils; |
55 | import org.apache.tools.ant.util.LoaderUtils; | |
41 | 56 | import org.junit.Assume; |
42 | 57 | import org.junit.Before; |
43 | 58 | import org.junit.Rule; |
394 | 409 | |
395 | 410 | } |
396 | 411 | |
412 | @Test(expected = BuildException.class) | |
413 | public void testModulePathNeedsFork() throws Exception { | |
414 | final Project project = new Project(); | |
415 | project.init(); | |
416 | JUnitTask task = new JUnitTask(); | |
417 | task.setProject(project); | |
418 | final Path p = new Path(project); | |
419 | p.setPath("modules"); | |
420 | task.createModulepath().add(p); | |
421 | task.addTest(new JUnitTest("org.apache.tools.ant.taskdefs.optional.junit.TestTest")); | |
422 | task.execute(); | |
423 | } | |
424 | ||
425 | @Test(expected = BuildException.class) | |
426 | public void testUpgradeModulePathNeedsFork() throws Exception { | |
427 | final Project project = new Project(); | |
428 | project.init(); | |
429 | JUnitTask task = new JUnitTask(); | |
430 | task.setProject(project); | |
431 | final Path p = new Path(project); | |
432 | p.setPath("modules"); | |
433 | task.createUpgrademodulepath().add(p); | |
434 | task.addTest(new JUnitTest("org.apache.tools.ant.taskdefs.optional.junit.TestTest")); | |
435 | task.execute(); | |
436 | } | |
437 | ||
438 | @Test | |
439 | public void testJunitOnCpArguments() throws Exception { | |
440 | final File tmp = new File(System.getProperty("java.io.tmpdir")); //NOI18N | |
441 | final File workDir = new File(tmp, String.format("%s_testJCP%d", //NOI18N | |
442 | getClass().getName(), | |
443 | System.currentTimeMillis()/1000)); | |
444 | workDir.mkdirs(); | |
445 | try { | |
446 | final File modulesDir = new File(workDir,"modules"); //NOI18N | |
447 | modulesDir.mkdirs(); | |
448 | ||
449 | final Project project = new Project(); | |
450 | project.init(); | |
451 | project.setBaseDir(workDir); | |
452 | final MockCommandLauncher mockProcLauncher = new MockCommandLauncher(); | |
453 | project.addReference( | |
454 | MagicNames.ANT_VM_LAUNCHER_REF_ID, | |
455 | mockProcLauncher); | |
456 | JUnitTask task = new JUnitTask(); | |
457 | task.setDir(workDir); | |
458 | task.setFork(true); | |
459 | task.setProject(project); | |
460 | final File junit = LoaderUtils.getResourceSource( | |
461 | JUnitTask.class.getClassLoader(), | |
462 | "junit/framework/Test.class"); //NOI18N | |
463 | final Path cp = new Path(project); | |
464 | cp.setPath(junit.getAbsolutePath()); | |
465 | task.createClasspath().add(cp); | |
466 | final Path mp = new Path(project); | |
467 | mp.setPath(modulesDir.getName()); | |
468 | task.createModulepath().add(mp); | |
469 | task.addTest(new JUnitTest("org.apache.tools.ant.taskdefs.optional.junit.TestTest")); | |
470 | task.execute(); | |
471 | assertNotNull(mockProcLauncher.cmd); | |
472 | String resCp = null; | |
473 | String resMp = null; | |
474 | Set<String> resExports = new TreeSet<String>(); | |
475 | for (int i = 1; i< mockProcLauncher.cmd.length; i++) { | |
476 | if ("-classpath".equals(mockProcLauncher.cmd[i])) { //NOI18N | |
477 | resCp = mockProcLauncher.cmd[++i]; | |
478 | } else if ("--module-path".equals(mockProcLauncher.cmd[i])) { //NOI18N | |
479 | resMp = mockProcLauncher.cmd[++i]; | |
480 | } else if (mockProcLauncher.cmd[i].equals("--add-exports")) { //NOI18N | |
481 | resExports.add(mockProcLauncher.cmd[++i]); | |
482 | } else if (JUnitTestRunner.class.getName().equals(mockProcLauncher.cmd[i])) { | |
483 | break; | |
484 | } | |
485 | } | |
486 | assertTrue("No exports", resExports.isEmpty()); | |
487 | if (project.getProperty(MagicNames.BUILD_SYSCLASSPATH) == null | |
488 | && System.getProperty(MagicNames.BUILD_SYSCLASSPATH) == null) { | |
489 | assertEquals("Expected classpath", cp.toString(), resCp); | |
490 | } | |
491 | assertEquals("Expected modulepath", mp.toString(), resMp); | |
492 | } finally { | |
493 | delete(workDir); | |
494 | } | |
495 | } | |
496 | ||
497 | @Test | |
498 | public void testJunitOnMpArguments() throws Exception { | |
499 | final File tmp = new File(System.getProperty("java.io.tmpdir")); //NOI18N | |
500 | final File workDir = new File(tmp, String.format("%s_testJMP%d", //NOI18N | |
501 | getClass().getName(), | |
502 | System.currentTimeMillis()/1000)); | |
503 | workDir.mkdirs(); | |
504 | try { | |
505 | final File modulesDir = new File(workDir,"modules"); //NOI18N | |
506 | modulesDir.mkdirs(); | |
507 | ||
508 | final Project project = new Project(); | |
509 | project.init(); | |
510 | project.setBaseDir(workDir); | |
511 | final MockCommandLauncher mockProcLauncher = new MockCommandLauncher(); | |
512 | project.addReference( | |
513 | MagicNames.ANT_VM_LAUNCHER_REF_ID, | |
514 | mockProcLauncher); | |
515 | JUnitTask task = new JUnitTask(); | |
516 | task.setDir(workDir); | |
517 | task.setFork(true); | |
518 | task.setProject(project); | |
519 | final File junit = LoaderUtils.getResourceSource( | |
520 | JUnitTask.class.getClassLoader(), | |
521 | "junit/framework/Test.class"); //NOI18N | |
522 | final Path mp = new Path(project); | |
523 | mp.add(new Path(project, junit.getAbsolutePath())); | |
524 | mp.add(new Path(project, modulesDir.getName())); | |
525 | task.createModulepath().add(mp); | |
526 | task.addTest(new JUnitTest("org.apache.tools.ant.taskdefs.optional.junit.TestTest")); //NOI18N | |
527 | task.execute(); | |
528 | assertNotNull(mockProcLauncher.cmd); | |
529 | String resCp = null; | |
530 | String resMp = null; | |
531 | Set<String> resExports = new TreeSet<String>(); | |
532 | for (int i = 1; i< mockProcLauncher.cmd.length; i++) { | |
533 | if ("-classpath".equals(mockProcLauncher.cmd[i])) { //NOI18N | |
534 | resCp = mockProcLauncher.cmd[++i]; | |
535 | } else if ("--module-path".equals(mockProcLauncher.cmd[i])) { //NOI18N | |
536 | resMp = mockProcLauncher.cmd[++i]; | |
537 | } else if (mockProcLauncher.cmd[i].equals("--add-exports")) { //NOI18N | |
538 | resExports.add(mockProcLauncher.cmd[++i]); | |
539 | } else if (JUnitTestRunner.class.getName().equals(mockProcLauncher.cmd[i])) { | |
540 | break; | |
541 | } | |
542 | } | |
543 | assertTrue("No exports", resExports.isEmpty()); | |
544 | if (project.getProperty(MagicNames.BUILD_SYSCLASSPATH) == null | |
545 | && System.getProperty(MagicNames.BUILD_SYSCLASSPATH) == null) { | |
546 | assertNull("No classpath", resCp); | |
547 | } | |
548 | assertEquals("Expected modulepath", mp.toString(), resMp); | |
549 | } finally { | |
550 | delete(workDir); | |
551 | } | |
552 | } | |
553 | ||
554 | private void delete(File f) { | |
555 | if (f.isDirectory()) { | |
556 | final File[] clds = f.listFiles(); | |
557 | if (clds != null) { | |
558 | for (File cld : clds) { | |
559 | delete(cld); | |
560 | } | |
561 | } | |
562 | } | |
563 | f.delete(); | |
564 | } | |
565 | ||
566 | private static final class MockCommandLauncher extends CommandLauncher { | |
567 | private String[] cmd; | |
568 | ||
569 | @Override | |
570 | public Process exec(Project project, String[] cmd, String[] env, File workingDir) throws IOException { | |
571 | this.cmd = new String[cmd.length]; | |
572 | System.arraycopy(cmd, 0, this.cmd, 0, cmd.length); | |
573 | return new MockProcess(); | |
574 | } | |
575 | ||
576 | private static class MockProcess extends Process { | |
577 | ||
578 | @Override | |
579 | public OutputStream getOutputStream() { | |
580 | return new ByteArrayOutputStream(); | |
581 | } | |
582 | ||
583 | @Override | |
584 | public InputStream getInputStream() { | |
585 | return new ByteArrayInputStream(new byte[0]); | |
586 | } | |
587 | ||
588 | @Override | |
589 | public InputStream getErrorStream() { | |
590 | return new ByteArrayInputStream(new byte[0]); | |
591 | } | |
592 | ||
593 | @Override | |
594 | public int waitFor() throws InterruptedException { | |
595 | return exitValue(); | |
596 | } | |
597 | ||
598 | @Override | |
599 | public int exitValue() { | |
600 | return 0; | |
601 | } | |
602 | ||
603 | @Override | |
604 | public void destroy() { | |
605 | } | |
606 | } | |
607 | } | |
397 | 608 | } |
+29
-1
113 | 113 | //assertEquals(error, JUnitTestRunner.FAILURES, runner.getRetCode()); |
114 | 114 | //@fixme as of now does not report the original stacktrace. |
115 | 115 | //assertTrue(error, error.indexOf("thrown on purpose") != -1); |
116 | } | |
117 | ||
118 | // check that JUnit 4 synthetic AssertionFailedError gets message and cause from AssertionError | |
119 | @Test | |
120 | public void testJUnit4AssertionError(){ | |
121 | TestRunner runner = createRunnerForTestMethod(AssertionErrorTest.class,"throwsAssertionError"); | |
122 | runner.run(); | |
123 | ||
124 | AssertionFailedError failure = runner.getFormatter().getFailure(); | |
125 | assertEquals("failure message", failure.getMessage()); | |
126 | ||
127 | Throwable cause = failure.getCause(); | |
128 | assertEquals(RuntimeException.class, cause.getClass()); | |
129 | assertEquals("cause message", cause.getMessage()); | |
116 | 130 | } |
117 | 131 | |
118 | 132 | protected TestRunner createRunner(Class<?> clazz){ |
144 | 158 | |
145 | 159 | // dummy formatter just to catch the error |
146 | 160 | private final static class ResultFormatter implements JUnitResultFormatter { |
161 | private AssertionFailedError failure; | |
147 | 162 | private Throwable error; |
148 | 163 | public void setSystemOutput(String output){} |
149 | 164 | public void setSystemError(String output){} |
152 | 167 | public void setOutput(java.io.OutputStream out){} |
153 | 168 | public void startTest(junit.framework.Test t) {} |
154 | 169 | public void endTest(junit.framework.Test test) {} |
155 | public void addFailure(junit.framework.Test test, AssertionFailedError t) { } | |
170 | public void addFailure(junit.framework.Test test, AssertionFailedError t) { | |
171 | failure = t; | |
172 | } | |
173 | AssertionFailedError getFailure() { | |
174 | return failure; | |
175 | } | |
156 | 176 | public void addError(junit.framework.Test test, Throwable t) { |
157 | 177 | error = t; |
158 | 178 | } |
212 | 232 | throw new NullPointerException("thrown on purpose"); |
213 | 233 | } |
214 | 234 | } |
235 | ||
236 | public static class AssertionErrorTest { | |
237 | @Test public void throwsAssertionError() { | |
238 | AssertionError assertionError = new AssertionError("failure message"); | |
239 | assertionError.initCause(new RuntimeException("cause message")); | |
240 | throw assertionError; | |
241 | } | |
242 | } | |
215 | 243 | } |
216 | 244 |
72 | 72 | } catch (BuildException be3) { |
73 | 73 | assertEquals("Date of this is not a date" |
74 | 74 | + " Cannot be parsed correctly. It should be in" |
75 | + " MM/DD/YYYY HH:MM AM_PM format.", be3.getMessage()); | |
75 | + " 'MM/dd/yyyy hh:mm a' format.", be3.getMessage()); | |
76 | 76 | } |
77 | 77 | |
78 | 78 | s = new DateSelector(); |
27 | 27 | import static org.junit.Assert.assertEquals; |
28 | 28 | import static org.junit.Assert.assertFalse; |
29 | 29 | import static org.junit.Assert.assertTrue; |
30 | import static org.junit.Assume.assumeTrue; | |
30 | 31 | |
31 | 32 | /** |
32 | 33 | * TestCase for JavaEnvUtils. |
115 | 116 | j.startsWith(javaHomeParent)); |
116 | 117 | |
117 | 118 | if ((Os.isFamily("mac") && JavaEnvUtils.getJavaVersionNumber() <= JavaEnvUtils.VERSION_1_6) |
118 | || JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_9)) { | |
119 | || JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | |
119 | 120 | assertTrue(j+" is normalized and in the JRE dir", |
120 | 121 | j.startsWith(javaHome)); |
121 | 122 | } else { |
135 | 136 | assertTrue( |
136 | 137 | "Current java version is not at least the current java version...", |
137 | 138 | JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.getJavaVersion())); |
138 | assertFalse( | |
139 | "In case the current java version is higher than 9.0 definitely a new algorithem will be needed", | |
140 | JavaEnvUtils.isAtLeastJavaVersion("9.0")); | |
141 | 139 | } |
142 | 140 | |
141 | @Test | |
142 | public void isJavaVersionSupportsBothVersionsOfJava9() { | |
143 | assumeTrue(JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_9)); | |
144 | assertTrue("JAVA_1_9 is not considered equal to JAVA_9", | |
145 | JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_9)); | |
146 | } | |
147 | ||
143 | 148 | } |
0 | /* | |
1 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
2 | * contributor license agreements. See the NOTICE file distributed with | |
3 | * this work for additional information regarding copyright ownership. | |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | * (the "License"); you may not use this file except in compliance with | |
6 | * the License. You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | */ | |
17 | package org.apache.tools.ant.util; | |
18 | ||
19 | import org.junit.Test; | |
20 | ||
21 | import static org.junit.Assert.assertEquals; | |
22 | ||
23 | public class Native2AsciiUtilsTest { | |
24 | ||
25 | @Test | |
26 | public void doesntTouchAscii() { | |
27 | StringBuilder sb = new StringBuilder(); | |
28 | for (char i = 0; i < 128; i++) { | |
29 | sb.append(i); | |
30 | } | |
31 | assertEquals(sb.toString(), Native2AsciiUtils.native2ascii(sb.toString())); | |
32 | } | |
33 | ||
34 | @Test | |
35 | public void escapes() { | |
36 | assertEquals("\\u00e4\\u00f6\\u00fc", | |
37 | Native2AsciiUtils.native2ascii("\u00e4\u00f6\u00fc")); | |
38 | } | |
39 | ||
40 | @Test | |
41 | public void pads() { | |
42 | assertEquals("\\u00e4\\u01f6\\u12fc", | |
43 | Native2AsciiUtils.native2ascii("\u00e4\u01f6\u12fc")); | |
44 | } | |
45 | ||
46 | @Test | |
47 | public void doesntTouchNonEscapes() { | |
48 | StringBuilder sb = new StringBuilder(); | |
49 | for (char i = 0; i < 128; i++) { | |
50 | sb.append(i); | |
51 | } | |
52 | assertEquals(sb.toString(), Native2AsciiUtils.ascii2native(sb.toString())); | |
53 | } | |
54 | ||
55 | @Test | |
56 | public void unescapes() { | |
57 | assertEquals("\u00e4\u00f6\u00fc", | |
58 | Native2AsciiUtils.ascii2native("\\u00e4\\u00f6\\u00fc")); | |
59 | } | |
60 | ||
61 | @Test | |
62 | public void leavesNonUnicodeBackslashesAlone() { | |
63 | assertEquals("\\abcdef", Native2AsciiUtils.ascii2native("\\abcdef")); | |
64 | assertEquals("\\u012j", Native2AsciiUtils.ascii2native("\\u012j")); | |
65 | } | |
66 | ||
67 | @Test | |
68 | public void dealsWithUnfinishedEscapes() { | |
69 | assertEquals("\u00e4", Native2AsciiUtils.ascii2native("\\u00e4")); | |
70 | assertEquals("\\u00e", Native2AsciiUtils.ascii2native("\\u00e")); | |
71 | assertEquals("\\u00", Native2AsciiUtils.ascii2native("\\u00")); | |
72 | assertEquals("\\u0", Native2AsciiUtils.ascii2native("\\u0")); | |
73 | } | |
74 | ||
75 | } |