You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Jesse McConnell (JIRA)" <ji...@codehaus.org> on 2006/03/21 16:39:11 UTC

[jira] Created: (MCLEAN-7) empty removes the directory of the fileset

empty <excludes/> removes the directory of the fileset
------------------------------------------------------

         Key: MCLEAN-7
         URL: http://jira.codehaus.org/browse/MCLEAN-7
     Project: Maven 2.x Clean Plugin
        Type: Bug

    Reporter: Jesse McConnell


I was shifting the unit tests over to use the plugin harness and noticed a test case failing.

if you look at the test case for the fileset test case, the second fileset test has an addFileset(dir, "**", "");

this unit test works fine, but when you try and actually do this behavior using the plugin configuration it brings up an error

            <fileset>
              <directory>${basedir}/target/test-classes/fileset-clean-test/buildOutputDirectory</directory>
              <includes>
                <include>**</include>
              </includes>
            </fileset>

that would be the plugin configuration of the same deal.  (<exclude></exclude> results in a stack trace)

In this case the directory is getting deleted when configured.  You can exhibit the same behavior with the existing test case if you try and pass null into the addFileset signature...


this would be the failing test case using the existing plugin, note the null in the second addFileset()
------

 public void testFilesets()
        throws Exception
    {
        String base = TARGET_TEST_DIR + "/target";

        CleanMojo mojo = new CleanMojo();

        mojo.addFileset( createFileset( base, "**/file.txt", "**/subdir/**" ) );

        String outputDirectory = TARGET_TEST_DIR + "/buildOutputDirectory";
        mojo.addFileset( createFileset( outputDirectory, "**", null ) );

        mojo.execute();

        // fileset 1
        assertTrue( checkExists( base ) );
        assertTrue( checkExists( base + "/classes" ) );
        assertFalse( checkExists( base + "/classes/file.txt" ) );
/* TODO: looks like a bug in the file-management library
        assertTrue( FileUtils.fileExists( base + "/subdir/file.txt" ) );
*/

        // fileset 2
        assertTrue( checkExists( outputDirectory ) );
        assertFalse( checkExists( outputDirectory + "/file.txt" ) );
	System.exit(-1);
    }



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MCLEAN-7) empty removes the directory of the fileset

Posted by "Jesse McConnell (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MCLEAN-7?page=comments#action_61804 ] 

Jesse McConnell commented on MCLEAN-7:
--------------------------------------

Not sure what to do here...

the original test case used the "**" includes and "" excludes which exhibited the desired behavior...

Now it would seem to me that 

<fileset>
  <includes>
    <include>**</include>
  </includes>
</fileset>

now to me that would be the same thing, but DirectoryScanner specificaly looks for "" in the exclude to decide if the directory should be deleted.

<fileset>
  <includes>
    <include>**</include>
  </includes>
  <excludes>
    <exclude></exclude>
  </excludes>
</fileset>

Now this builds an excludes arraylist of size 1 but null inside, which triggers a NPE in DirectoryScanner..

<fileset>
  <includes>
    <include>**</include>
  </includes>
  <excludes>
    <exclude>""</exclude>
  </excludes>
</fileset>

This certainly doesn't work since it translate to "\"\"" in the fileset

BUT!

<fileset>
  <includes>
    <include>**</include>
  </includes>
  <excludes>
    <exclude>**</exclude>
  </excludes>
</fileset>

does exhibit the correct behavior, since the includes ** matchs the files in the directory and the ** actually seems to protect the directory.  The files end up getting smoked but the base directory of the fileset is perserved.

This seems a bit off to me, but I am able to configure a fileset that exhibits the same end behavior of the test case...but this feels like another issue to me, that ** in includes means something other then ** in excludes.


> empty <excludes/> removes the directory of the fileset
> ------------------------------------------------------
>
>          Key: MCLEAN-7
>          URL: http://jira.codehaus.org/browse/MCLEAN-7
>      Project: Maven 2.x Clean Plugin
>         Type: Bug

>     Reporter: Jesse McConnell

>
>
> I was shifting the unit tests over to use the plugin harness and noticed a test case failing.
> if you look at the test case for the fileset test case, the second fileset test has an addFileset(dir, "**", "");
> this unit test works fine, but when you try and actually do this behavior using the plugin configuration it brings up an error
>             <fileset>
>               <directory>${basedir}/target/test-classes/fileset-clean-test/buildOutputDirectory</directory>
>               <includes>
>                 <include>**</include>
>               </includes>
>             </fileset>
> that would be the plugin configuration of the same deal.  (<exclude></exclude> results in a stack trace)
> In this case the directory is getting deleted when configured.  You can exhibit the same behavior with the existing test case if you try and pass null into the addFileset signature...
> this would be the failing test case using the existing plugin, note the null in the second addFileset()
> ------
>  public void testFilesets()
>         throws Exception
>     {
>         String base = TARGET_TEST_DIR + "/target";
>         CleanMojo mojo = new CleanMojo();
>         mojo.addFileset( createFileset( base, "**/file.txt", "**/subdir/**" ) );
>         String outputDirectory = TARGET_TEST_DIR + "/buildOutputDirectory";
>         mojo.addFileset( createFileset( outputDirectory, "**", null ) );
>         mojo.execute();
>         // fileset 1
>         assertTrue( checkExists( base ) );
>         assertTrue( checkExists( base + "/classes" ) );
>         assertFalse( checkExists( base + "/classes/file.txt" ) );
> /* TODO: looks like a bug in the file-management library
>         assertTrue( FileUtils.fileExists( base + "/subdir/file.txt" ) );
> */
>         // fileset 2
>         assertTrue( checkExists( outputDirectory ) );
>         assertFalse( checkExists( outputDirectory + "/file.txt" ) );
> 	System.exit(-1);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MCLEAN-7) empty removes the directory of the fileset

Posted by "Brett Porter (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MCLEAN-7?page=comments#action_61873 ] 

Brett Porter commented on MCLEAN-7:
-----------------------------------

I think we should scratch this issue. To me <excludes/> == <excludes></excludes> == null, that is, exclude nothing.

The bug should be filed against plexus-utils / file management API (if appropriate). Perhaps we should rebase DirectoryScanner against the latest from Ant to see if such bugs have been fixed. Anyway, not a big issue.

> empty <excludes/> removes the directory of the fileset
> ------------------------------------------------------
>
>          Key: MCLEAN-7
>          URL: http://jira.codehaus.org/browse/MCLEAN-7
>      Project: Maven 2.x Clean Plugin
>         Type: Bug

>     Reporter: Jesse McConnell

>
>
> I was shifting the unit tests over to use the plugin harness and noticed a test case failing.
> if you look at the test case for the fileset test case, the second fileset test has an addFileset(dir, "**", "");
> this unit test works fine, but when you try and actually do this behavior using the plugin configuration it brings up an error
>             <fileset>
>               <directory>${basedir}/target/test-classes/fileset-clean-test/buildOutputDirectory</directory>
>               <includes>
>                 <include>**</include>
>               </includes>
>             </fileset>
> that would be the plugin configuration of the same deal.  (<exclude></exclude> results in a stack trace)
> In this case the directory is getting deleted when configured.  You can exhibit the same behavior with the existing test case if you try and pass null into the addFileset signature...
> this would be the failing test case using the existing plugin, note the null in the second addFileset()
> ------
>  public void testFilesets()
>         throws Exception
>     {
>         String base = TARGET_TEST_DIR + "/target";
>         CleanMojo mojo = new CleanMojo();
>         mojo.addFileset( createFileset( base, "**/file.txt", "**/subdir/**" ) );
>         String outputDirectory = TARGET_TEST_DIR + "/buildOutputDirectory";
>         mojo.addFileset( createFileset( outputDirectory, "**", null ) );
>         mojo.execute();
>         // fileset 1
>         assertTrue( checkExists( base ) );
>         assertTrue( checkExists( base + "/classes" ) );
>         assertFalse( checkExists( base + "/classes/file.txt" ) );
> /* TODO: looks like a bug in the file-management library
>         assertTrue( FileUtils.fileExists( base + "/subdir/file.txt" ) );
> */
>         // fileset 2
>         assertTrue( checkExists( outputDirectory ) );
>         assertFalse( checkExists( outputDirectory + "/file.txt" ) );
> 	System.exit(-1);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MCLEAN-7) empty removes the directory of the fileset

Posted by "Jesse McConnell (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MCLEAN-7?page=comments#action_61731 ] 

Jesse McConnell commented on MCLEAN-7:
--------------------------------------

the jist of the problem is that when the excludes is set to "" then that is translating to 'don't remove the directory' of the fileset

perhaps the thing to do is add the "" to the default excludes?

> empty <excludes/> removes the directory of the fileset
> ------------------------------------------------------
>
>          Key: MCLEAN-7
>          URL: http://jira.codehaus.org/browse/MCLEAN-7
>      Project: Maven 2.x Clean Plugin
>         Type: Bug

>     Reporter: Jesse McConnell

>
>
> I was shifting the unit tests over to use the plugin harness and noticed a test case failing.
> if you look at the test case for the fileset test case, the second fileset test has an addFileset(dir, "**", "");
> this unit test works fine, but when you try and actually do this behavior using the plugin configuration it brings up an error
>             <fileset>
>               <directory>${basedir}/target/test-classes/fileset-clean-test/buildOutputDirectory</directory>
>               <includes>
>                 <include>**</include>
>               </includes>
>             </fileset>
> that would be the plugin configuration of the same deal.  (<exclude></exclude> results in a stack trace)
> In this case the directory is getting deleted when configured.  You can exhibit the same behavior with the existing test case if you try and pass null into the addFileset signature...
> this would be the failing test case using the existing plugin, note the null in the second addFileset()
> ------
>  public void testFilesets()
>         throws Exception
>     {
>         String base = TARGET_TEST_DIR + "/target";
>         CleanMojo mojo = new CleanMojo();
>         mojo.addFileset( createFileset( base, "**/file.txt", "**/subdir/**" ) );
>         String outputDirectory = TARGET_TEST_DIR + "/buildOutputDirectory";
>         mojo.addFileset( createFileset( outputDirectory, "**", null ) );
>         mojo.execute();
>         // fileset 1
>         assertTrue( checkExists( base ) );
>         assertTrue( checkExists( base + "/classes" ) );
>         assertFalse( checkExists( base + "/classes/file.txt" ) );
> /* TODO: looks like a bug in the file-management library
>         assertTrue( FileUtils.fileExists( base + "/subdir/file.txt" ) );
> */
>         // fileset 2
>         assertTrue( checkExists( outputDirectory ) );
>         assertFalse( checkExists( outputDirectory + "/file.txt" ) );
> 	System.exit(-1);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MCLEAN-7) empty removes the directory of the fileset

Posted by "Jesse McConnell (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MCLEAN-7?page=comments#action_61796 ] 

Jesse McConnell commented on MCLEAN-7:
--------------------------------------

ok, the setting the fileset to null above seems to throw the same exception now that using an empty excludes statement does...

blows on line 502 of DirectoryScanner when setting excludes.

now...

<excludes><exclude></exclude><excludes> blows up and have the excludes as an arraylist of size 1 and null inside..

not having the excludes and just the includes yields an arraylist of size 0 and removes the directory..

and the existing unit test ends up with a excludes arraylist of size 1 with a "" element inside.. (which is the only one that passes unit test atm)



> empty <excludes/> removes the directory of the fileset
> ------------------------------------------------------
>
>          Key: MCLEAN-7
>          URL: http://jira.codehaus.org/browse/MCLEAN-7
>      Project: Maven 2.x Clean Plugin
>         Type: Bug

>     Reporter: Jesse McConnell

>
>
> I was shifting the unit tests over to use the plugin harness and noticed a test case failing.
> if you look at the test case for the fileset test case, the second fileset test has an addFileset(dir, "**", "");
> this unit test works fine, but when you try and actually do this behavior using the plugin configuration it brings up an error
>             <fileset>
>               <directory>${basedir}/target/test-classes/fileset-clean-test/buildOutputDirectory</directory>
>               <includes>
>                 <include>**</include>
>               </includes>
>             </fileset>
> that would be the plugin configuration of the same deal.  (<exclude></exclude> results in a stack trace)
> In this case the directory is getting deleted when configured.  You can exhibit the same behavior with the existing test case if you try and pass null into the addFileset signature...
> this would be the failing test case using the existing plugin, note the null in the second addFileset()
> ------
>  public void testFilesets()
>         throws Exception
>     {
>         String base = TARGET_TEST_DIR + "/target";
>         CleanMojo mojo = new CleanMojo();
>         mojo.addFileset( createFileset( base, "**/file.txt", "**/subdir/**" ) );
>         String outputDirectory = TARGET_TEST_DIR + "/buildOutputDirectory";
>         mojo.addFileset( createFileset( outputDirectory, "**", null ) );
>         mojo.execute();
>         // fileset 1
>         assertTrue( checkExists( base ) );
>         assertTrue( checkExists( base + "/classes" ) );
>         assertFalse( checkExists( base + "/classes/file.txt" ) );
> /* TODO: looks like a bug in the file-management library
>         assertTrue( FileUtils.fileExists( base + "/subdir/file.txt" ) );
> */
>         // fileset 2
>         assertTrue( checkExists( outputDirectory ) );
>         assertFalse( checkExists( outputDirectory + "/file.txt" ) );
> 	System.exit(-1);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira