Issue Details (XML | Word | Printable)

Key: MCLEAN-38
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Nick Pellow
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Maven 2.x Clean Plugin

Allow a global set of include and exclude filters

Created: 17/Sep/08 01:36 AM   Updated: 17/Sep/08 06:47 PM
Component/s: None
Affects Version/s: 2.2
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Text File MCLEAN-38-maven-clean-plugin.patch (6 kB)



 Description  « Hide

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.



Nick Pellow added a comment - 17/Sep/08 01:50 AM

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

Benjamin Bentmann added a comment - 17/Sep/08 02:32 AM

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?


Nick Pellow added a comment - 17/Sep/08 02:51 AM - 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.


Benjamin Bentmann added a comment - 17/Sep/08 07:51 AM

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?


Nick Pellow added a comment - 17/Sep/08 06:47 PM

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.