git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1178820 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -91,6 +91,13 @@ Fixed bugs: | |||||
| given file is not a ZIP archive and it is smaller than the size of | given file is not a ZIP archive and it is smaller than the size of | ||||
| a ZIP "end of central directory record". | a ZIP "end of central directory record". | ||||
| * <javac> would create the empty package-info.class file in the wrong | |||||
| directory if no destdir was specified. Note it may still pick the | |||||
| wrong directory if you specify more than one source directory but | |||||
| no destDir. It is highly recommended that you always explicitly | |||||
| specify the destDir attribute. | |||||
| Bugzilla Report 51947. | |||||
| Other changes: | Other changes: | ||||
| -------------- | -------------- | ||||
| @@ -1134,7 +1134,10 @@ public class Javac extends MatchingTask { | |||||
| if (adapter.execute()) { | if (adapter.execute()) { | ||||
| // Success | // Success | ||||
| try { | try { | ||||
| generateMissingPackageInfoClasses(); | |||||
| generateMissingPackageInfoClasses(destDir != null | |||||
| ? destDir | |||||
| : getProject() | |||||
| .resolveFile(src.list()[0])); | |||||
| } catch (IOException x) { | } catch (IOException x) { | ||||
| // Should this be made a nonfatal warning? | // Should this be made a nonfatal warning? | ||||
| throw new BuildException(x, getLocation()); | throw new BuildException(x, getLocation()); | ||||
| @@ -1194,12 +1197,12 @@ public class Javac extends MatchingTask { | |||||
| * Otherwise this task's up-to-date tracking mechanisms do not work. | * Otherwise this task's up-to-date tracking mechanisms do not work. | ||||
| * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=43114">Bug #43114</a> | * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=43114">Bug #43114</a> | ||||
| */ | */ | ||||
| private void generateMissingPackageInfoClasses() throws IOException { | |||||
| private void generateMissingPackageInfoClasses(File dest) throws IOException { | |||||
| for (Iterator i = packageInfos.entrySet().iterator(); i.hasNext(); ) { | for (Iterator i = packageInfos.entrySet().iterator(); i.hasNext(); ) { | ||||
| Map.Entry entry = (Map.Entry) i.next(); | Map.Entry entry = (Map.Entry) i.next(); | ||||
| String pkg = (String) entry.getKey(); | String pkg = (String) entry.getKey(); | ||||
| Long sourceLastMod = (Long) entry.getValue(); | Long sourceLastMod = (Long) entry.getValue(); | ||||
| File pkgBinDir = new File(destDir, pkg.replace('/', File.separatorChar)); | |||||
| File pkgBinDir = new File(dest, pkg.replace('/', File.separatorChar)); | |||||
| pkgBinDir.mkdirs(); | pkgBinDir.mkdirs(); | ||||
| File pkgInfoClass = new File(pkgBinDir, "package-info.class"); | File pkgInfoClass = new File(pkgBinDir, "package-info.class"); | ||||
| if (pkgInfoClass.isFile() && pkgInfoClass.lastModified() >= sourceLastMod.longValue()) { | if (pkgInfoClass.isFile() && pkgInfoClass.lastModified() >= sourceLastMod.longValue()) { | ||||
| @@ -80,7 +80,7 @@ | |||||
| </au:assertTrue> | </au:assertTrue> | ||||
| </target> | </target> | ||||
| <target name="testPackageInfoJava" description="https://issues.apache.org/bugzilla/show_bug.cgi?id=43114"> | |||||
| <target name="setUpForPackageInfoJava"> | |||||
| <mkdir dir="${javac-dir}/src/a" /> | <mkdir dir="${javac-dir}/src/a" /> | ||||
| <mkdir dir="${build-dir}" /> | <mkdir dir="${build-dir}" /> | ||||
| <echo file="${javac-dir}/src/a/package-info.java"> | <echo file="${javac-dir}/src/a/package-info.java"> | ||||
| @@ -92,7 +92,11 @@ | |||||
| </echo> | </echo> | ||||
| <javac srcdir="${javac-dir}/src" destdir="${build-dir}" updatedProperty="first-pass" /> | <javac srcdir="${javac-dir}/src" destdir="${build-dir}" updatedProperty="first-pass" /> | ||||
| <au:assertPropertyEquals name="first-pass" value="true" /> | <au:assertPropertyEquals name="first-pass" value="true" /> | ||||
| </target> | |||||
| <target name="testPackageInfoJava" | |||||
| depends="setUpForPackageInfoJava" | |||||
| description="https://issues.apache.org/bugzilla/show_bug.cgi?id=43114"> | |||||
| <!-- no changes, shouldn't recompile, the initial bug --> | <!-- no changes, shouldn't recompile, the initial bug --> | ||||
| <javac srcdir="${javac-dir}/src" destdir="${build-dir}" updatedProperty="second-pass" /> | <javac srcdir="${javac-dir}/src" destdir="${build-dir}" updatedProperty="second-pass" /> | ||||
| <au:assertFalse> | <au:assertFalse> | ||||
| @@ -111,6 +115,30 @@ | |||||
| <au:assertPropertyEquals name="third-pass" value="true" /> | <au:assertPropertyEquals name="third-pass" value="true" /> | ||||
| </target> | </target> | ||||
| <target name="testPackageInfoJavaNoDest" | |||||
| depends="setUpForPackageInfoJava" | |||||
| description="https://issues.apache.org/bugzilla/show_bug.cgi?id=51947"> | |||||
| <javac srcdir="${javac-dir}/src" updatedProperty="first-pass" /> | |||||
| <au:assertPropertyEquals name="first-pass" value="true" /> | |||||
| <!-- no changes, shouldn't recompile, the initial bug --> | |||||
| <javac srcdir="${javac-dir}/src" updatedProperty="second-pass" /> | |||||
| <au:assertFalse> | |||||
| <isset property="second-pass" /> | |||||
| </au:assertFalse> | |||||
| <sleep seconds="2" /> | |||||
| <!-- change package-info.java but make containing target dir even | |||||
| more recent - the regression in Ant 1.7.1 --> | |||||
| <touch file="${javac-dir}/src/a/package-info.java" /> | |||||
| <sleep seconds="2" /> | |||||
| <touch> | |||||
| <file file="${javac-dir}/src/a" /> | |||||
| </touch> | |||||
| <javac srcdir="${javac-dir}/src" updatedProperty="third-pass" /> | |||||
| <au:assertPropertyEquals name="third-pass" value="true" /> | |||||
| </target> | |||||
| <target name="-create-javac-adapter"> | <target name="-create-javac-adapter"> | ||||
| <property name="adapter.dir" location="${output}/adapter" /> | <property name="adapter.dir" location="${output}/adapter" /> | ||||
| <mkdir dir="${input}/org/example" /> | <mkdir dir="${input}/org/example" /> | ||||