Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Run::Clean #7

Closed
andrewrjones opened this issue Feb 29, 2012 · 8 comments
Closed

Feature request: Run::Clean #7

andrewrjones opened this issue Feb 29, 2012 · 8 comments

Comments

@andrewrjones
Copy link

Thanks for this very useful plugin.

It would be great if we could also have Dist::Zilla::Plugin::Run::Clean. One of my scripts generates a new .pm file before we build, and I would like to remove it when we clean.

@rwstauner
Copy link
Collaborator

Currently Dist::Zilla doesn't enable plugins on clean.

What is it exactly that you are trying to achieve?

If you are generating the file into your repo so that it gets included in your (built) dist
an alternative option might be to use a FileInjector (or FileGatherer) plugin to generate the file during build rather than before.
Then you wouldn't have the file leftover in your repo after the build.

Another option would be to use Run::AfterBuild or Run::AfterRelease to remove the file at an appropriate time.

If you want the file to remain in your repo but don't want to commit it you could simply add it to your .gitignore file.

There are likely other options too, depending on what it is your aiming for.

Feel free to drop by #distzilla on irc.perl.org to discuss other options.
There are lots of great people there who are willing to help out.

@rwstauner
Copy link
Collaborator

Which isn't to say that we couldn't petition for Dist::Zilla to support a Cleaner role if that would be helpful...
but you know, TIMTOWTDI.
:-)

@andrewrjones
Copy link
Author

Thanks for the detailed response.

Heres what I'm doing: I am using a web based API. This API is available in a number of languages, which is defined in an XML file. The languages are unlikely to change very often, so at BeforeBuild I run a perl script that gets the Languages.xml, parses it into a perl hash, and use Code::Generator::Perl to create a Languages.pm file to store this data.

It's probably overkill, but it works nicely (and was interesting to work on). I have added the generated file to my .gitignore, so it doesn't really cause me any problems when developing.

I also want to ensure my CI system is doing a clean build - but to get around this I just ensured it was doing a git reset --hard before building, so no generated files or left overs from the last build are around.

So, its not essential that I do it on clean, just would be nice for clean to clean up everything. But if its not easy, then its definitely not worth spending any time on.

@rwstauner
Copy link
Collaborator

Definitely an interesting use case.

I forwarded the feature request upstream: https://rt.cpan.org/Ticket/Display.html?id=75426
If Dist::Zilla adds a cleaning phase I'm sure we'll add a Run plugin for it.

Thanks for the tip on Code::Generator::Perl... I have a $work project that builds a hash inside some template pm's with data from a csv... I'll have to remember to check out CGP sometime.

I chose to commit my generated pm's since they are required by the rest of the dist and if the data actually changes it's usually a small diff... but to each his own :-)

Thanks for sharing the idea!

@dolmen
Copy link
Collaborator

dolmen commented May 4, 2012

If your CI system is Hudson/Jenkins, it does the clean before a new build (or at least there is an option to tick for that).

But the proper Dist::Zilla way would be to transform your script into a Dist::Zilla plugin similar to Dist::Zilla::Plugin::Manifest. You would put this plugin in inc/ (for example package inc::My::DataGenerator in inc/My/DataGenerator.pm) and enable it in dist.ini with [=inc::My::DataGenerator].
However that may not be appropriate if you do not want to refetch the data each time you do a dzil test.

@karenetheridge
Copy link
Collaborator

Just briefly skimming over this issue - are you aware of Dist::Zilla::Plugin::Clean?

@rwstauner
Copy link
Collaborator

Dist::Zilla::Plugin::Clean just calls the clean method on the dist builder
which currently only removes the build dirs (essentially the same as doing dzil release && dzil clean).

This feature request was specifically for getting clean to clean up additional (custom-specified) files in the source dir but the clean feature is currently not pluggable.

@karenetheridge
Copy link
Collaborator

I'd recommend patching dzil to allow more options on the 'clean' command.

Alternatively, you can put your commands in [Run::AfterRelease] and [Run::AfterBuild].

closing, as we can't really do much in this dist with the current architecture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants