| @@ -64,6 +64,11 @@ Fixed bugs: | |||||
| streams of a process, could end up being truncated. | streams of a process, could end up being truncated. | ||||
| Bugzilla Report 58833, 58451 | Bugzilla Report 58833, 58451 | ||||
| * <fileset>/<zipfileset>/<tarfileset> will now throw an exception | |||||
| with a more useful error message when setFile is called twice on | |||||
| the same instance. | |||||
| Bugzilla Report 62071 | |||||
| Other changes: | Other changes: | ||||
| -------------- | -------------- | ||||
| @@ -238,7 +238,16 @@ public abstract class AbstractFileSet extends DataType | |||||
| if (isReference()) { | if (isReference()) { | ||||
| throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
| } | } | ||||
| if (getDir() != null) { | |||||
| if (fileAttributeUsed) { | |||||
| if (getDir().equals(file.getParentFile())) { | |||||
| String[] includes = defaultPatterns.getIncludePatterns(getProject()); | |||||
| if (includes.length == 1 && includes[0].equals(file.getName())) { | |||||
| // NOOP, setFile has been invoked twice with the same parameter | |||||
| return; | |||||
| } | |||||
| } | |||||
| throw new BuildException("setFile cannot be called twice with different arguments"); | |||||
| } else if (getDir() != null) { | |||||
| throw dirAndFileAreMutuallyExclusive(); | throw dirAndFileAreMutuallyExclusive(); | ||||
| } | } | ||||
| setDir(file.getParentFile()); | setDir(file.getParentFile()); | ||||
| @@ -298,7 +307,7 @@ public abstract class AbstractFileSet extends DataType | |||||
| } | } | ||||
| /** | /** | ||||
| * Appends <code>excludes</code> to the current list of include | |||||
| * Appends <code>excludes</code> to the current list of exclude | |||||
| * patterns. | * patterns. | ||||
| * | * | ||||
| * @param excludes array containing the exclude patterns. | * @param excludes array containing the exclude patterns. | ||||
| @@ -244,4 +244,24 @@ public abstract class AbstractFileSetTest { | |||||
| File dir = f1.getDir(project); | File dir = f1.getDir(project); | ||||
| assertEquals("Dir is basedir", dir, project.getBaseDir()); | assertEquals("Dir is basedir", dir, project.getBaseDir()); | ||||
| } | } | ||||
| @Test | |||||
| public void canCallSetFileTwiceWithSameArgument() { | |||||
| AbstractFileSet f = getInstance(); | |||||
| f.setFile(new File("/a")); | |||||
| f.setFile(new File("/a")); | |||||
| // really only asserts no exception is thrown | |||||
| } | |||||
| @Test | |||||
| public void cantCallSetFileTwiceWithDifferentArguments() { | |||||
| AbstractFileSet f = getInstance(); | |||||
| f.setFile(new File("/a")); | |||||
| try { | |||||
| f.setFile(new File("/b")); | |||||
| fail("expected an exception"); | |||||
| } catch (BuildException ex) { | |||||
| assertEquals("setFile cannot be called twice with different arguments", ex.getMessage()); | |||||
| } | |||||
| } | |||||
| } | } | ||||