Maven Clean Plugin
  1. Maven Clean Plugin
  2. MCLEAN-38

Allow a global set of include and exclude filters

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      I am about to submit a patch to the maven-clean-plugin which will allow a global includes and excludes patterns to be configured.
      Currently, it is not possibly to easily do a clean and have specific files in the default output directories preserved.

      The patch will allow a comma separated list of exclusions and inclusions to use when removing the default output directories.

        Activity

        Hide
        Nick Pellow added a comment -

        This patch allows the following parameters to be passed to the maven-clean-plugin:

        1. includes a comma-delimited list of file patterns to be deleted when removing the defaultOutputDirectories
        2. excludes a comma-delimited list of file patterns to be preserved when removing the defaultOutputDirectories
        Show
        Nick Pellow added a comment - This patch allows the following parameters to be passed to the maven-clean-plugin: includes a comma-delimited list of file patterns to be deleted when removing the defaultOutputDirectories excludes a comma-delimited list of file patterns to be preserved when removing the defaultOutputDirectories
        Hide
        Benjamin Bentmann added a comment -

        Not sure whether we really need this extra complexity. With the fix for MCLEAN-33, one could simply exclude the default directories from cleaning and employ the filesets parameter instead which already provides includes/excludes.

        Also, I am not in favor of specifying the includes/excludes all in one simple string given that these patterns are usually provided by means of a real collection. That is to say, the usage would become inconsistent IMHO.

        Can you elaborate more on your specific use case?

        Show
        Benjamin Bentmann added a comment - Not sure whether we really need this extra complexity. With the fix for MCLEAN-33 , one could simply exclude the default directories from cleaning and employ the filesets parameter instead which already provides includes/excludes. Also, I am not in favor of specifying the includes/excludes all in one simple string given that these patterns are usually provided by means of a real collection. That is to say, the usage would become inconsistent IMHO. Can you elaborate more on your specific use case?
        Hide
        Nick Pellow added a comment - - edited

        I saw MCLEAN-33, and it is not fine grained or flexible enough.
        ie - the clean plugin can either delete all default directories, or none.

        I considered excluding the default directories from cleaning, and then using the filesets parameter. The problems with this approach however are:

        1. users are required to have duplicate configuration (ie - the build directory locations) in their pom.xml
        2. the maven-clean-plugin will need to be added to the users pom

        Allowing a simple String to be used, instead of a Collection, allows the patterns to be passed in on the command line.

         -Dexcludes=**/expensive.file1
        

        It also allows other plugins (this is my use case), which are bound to the pre-clean phase to set this property on the project to avoid specific files being deleted when clean is run.

        I agree that this usage is somewhat inconsistent. You would have to agree however, that it is extremely practical.

        IMO, maven should support splitting of comma and space separated Strings into Collection parameters automatically. This is exactly what Ant does. It would make the pom a lot more readable, and allow passing of collection arguments on the command line.

        Show
        Nick Pellow added a comment - - edited I saw MCLEAN-33 , and it is not fine grained or flexible enough. ie - the clean plugin can either delete all default directories, or none. I considered excluding the default directories from cleaning, and then using the filesets parameter. The problems with this approach however are: users are required to have duplicate configuration (ie - the build directory locations) in their pom.xml the maven-clean-plugin will need to be added to the users pom Allowing a simple String to be used, instead of a Collection, allows the patterns to be passed in on the command line. -Dexcludes=**/expensive.file1 It also allows other plugins (this is my use case), which are bound to the pre-clean phase to set this property on the project to avoid specific files being deleted when clean is run. I agree that this usage is somewhat inconsistent. You would have to agree however, that it is extremely practical. IMO, maven should support splitting of comma and space separated Strings into Collection parameters automatically. This is exactly what Ant does. It would make the pom a lot more readable, and allow passing of collection arguments on the command line.
        Hide
        Benjamin Bentmann added a comment -

        It also allows other plugins (this is my use case), which are bound to the pre-clean phase to set this property on the project to avoid specific files being deleted when clean is run.

        Out of curiosity, could you give some more details on this? For instance, what generated the files to exclude, your plugin or something else? If the files should be excluded from cleaning, why aren't they put somewhere else? How can they ever be deleted by Maven or isn't that intended?

        Show
        Benjamin Bentmann added a comment - It also allows other plugins (this is my use case), which are bound to the pre-clean phase to set this property on the project to avoid specific files being deleted when clean is run. Out of curiosity, could you give some more details on this? For instance, what generated the files to exclude, your plugin or something else? If the files should be excluded from cleaning, why aren't they put somewhere else? How can they ever be deleted by Maven or isn't that intended?
        Hide
        Nick Pellow added a comment -

        My plugin consists of several MOJOs. One of which runs at the end of the build, storing some state about what happened during the build. This data is optionally required for following builds, allowing the build time to be drastically reduced.

        For instance, what generated the files to exclude, your plugin or something else?

        Yes, the same plugin generated the files to exclude. However, conceivably they could be produced by any plugin.

        If the files should be excluded from cleaning, why aren't they put somewhere else?

        They can optionally be put somewhere else. This requires extra configuration (and effort) by the user however. The target directory is the best location for these files however, since they will be removed when the user runs the clean goal, without running my plugin first.

        How can they ever be deleted by Maven or isn't that intended?

        By simply running $> mvn clean, without my mojo being explicitly called first. Also, my mojo will be able to decide when those files are to be deleted.

        Apart from the use case I describe above, I see this patch to be providing the extremely useful ability to specify excludes and includes on the command line.

        Show
        Nick Pellow added a comment - My plugin consists of several MOJOs. One of which runs at the end of the build, storing some state about what happened during the build. This data is optionally required for following builds, allowing the build time to be drastically reduced. For instance, what generated the files to exclude, your plugin or something else? Yes, the same plugin generated the files to exclude. However, conceivably they could be produced by any plugin. If the files should be excluded from cleaning, why aren't they put somewhere else? They can optionally be put somewhere else. This requires extra configuration (and effort) by the user however. The target directory is the best location for these files however, since they will be removed when the user runs the clean goal, without running my plugin first. How can they ever be deleted by Maven or isn't that intended? By simply running $> mvn clean, without my mojo being explicitly called first. Also, my mojo will be able to decide when those files are to be deleted. Apart from the use case I describe above, I see this patch to be providing the extremely useful ability to specify excludes and includes on the command line.
        Hide
        Karl-Heinz Marbaise added a comment -

        What about http://maven.apache.org/plugins/maven-clean-plugin/examples/delete_additional_files.html ? Does that fit ? If not don't hesitate to reopen the issue.

        Show
        Karl-Heinz Marbaise added a comment - What about http://maven.apache.org/plugins/maven-clean-plugin/examples/delete_additional_files.html ? Does that fit ? If not don't hesitate to reopen the issue.

          People

          • Assignee:
            Karl-Heinz Marbaise
            Reporter:
            Nick Pellow
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: