javacc / javaccPlugin

A JavaCC plugin for Gradle
MIT License
33 stars 16 forks source link

add "clean*" tasks as dependencies of task "clean" #24

Closed ypoluektovich closed 8 years ago

ypoluektovich commented 8 years ago

Gradle has a rule that a task called "clean" clears the output of the task "". However, by default these task-specific cleaners are not executed when running "gradle clean". It doesn't matter as long as a custom task's output directory is in the project's default build directory, but if that's not the case, the outputs won't be cleaned unless you specifically request it.

This commit makes it so that the task "clean", if defined in the project at the moment of the javacc plugin application, is set to depend on the cleaner counterparts of the tasks generated by this plugin. This way, even if the generated source directory is moved out of the project's build directory, it still gets cleaned when the user runs "gradle clean".

ypoluektovich commented 8 years ago

Whoops, github's comment parser ate some words from the description when creating the pull request. It'll probably make more sense if you read the commit message :)

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.02%) to 97.819% when pulling 61bb1e3858a43e0536925deae2f089eaefe5cb69 on ypoluektovich:f_clean-task-dependency into eec7bfe8ae40bc40f9039c36bee927605585dfce on johnmartel:master.

johnmartel commented 8 years ago

Thanks for your contribution,

Sorry for the delay, I have been on a long abroad trip for business, I will review and merge shortly.


Jonathan Martel Informaticien conseiller en Génie Logiciel Consultants CoGL inc. 581.986.7030 jonathan.martel@coglinc.ca Twitter: @johnmartelqc LinkedIn: http://www.linkedin.com/pub/jonathan-martel/24/312/711

Signature digitale: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x321163AE83A4068A

On Apr 26, 2016, at 03:47, Yanus Poluektovich notifications@github.com wrote:

Gradle has a rule that a task called "clean" clears the output of the task "". However, by default these task-specific cleaners are not executed when running "gradle clean". It doesn't matter as long as a custom task's output directory is in the project's default build directory, but if that's not the case, the outputs won't be cleaned unless you specifically request it.

This commit makes it so that the task "clean", if defined in the project at the moment of the javacc plugin application, is set to depend on the cleaner counterparts of the tasks generated by this plugin. This way, even if the generated source directory is moved out of the project's build directory, it still gets cleaned when the user runs "gradle clean".

You can view, comment on, or merge this pull request online at:

https://github.com/johnmartel/javaccPlugin/pull/24 https://github.com/johnmartel/javaccPlugin/pull/24 Commit Summary

add "clean*" tasks as dependencies of task "clean" File Changes

M subprojects/plugin/src/main/java/ca/coglinc/gradle/plugins/javacc/JavaccPlugin.java https://github.com/johnmartel/javaccPlugin/pull/24/files#diff-0 (6) Patch Links:

https://github.com/johnmartel/javaccPlugin/pull/24.patch https://github.com/johnmartel/javaccPlugin/pull/24.patch https://github.com/johnmartel/javaccPlugin/pull/24.diff https://github.com/johnmartel/javaccPlugin/pull/24.diff — You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/johnmartel/javaccPlugin/pull/24

johnmartel commented 8 years ago

You have not written any acceptance test to demonstrate the issue and you have no unit tests for your changes as well. I can do it if you don't, but this PR won't be merged until both acceptance and unit tests are written for it.

ypoluektovich commented 8 years ago

I started writing tests, and then I thought about something. How likely is it that somebody expects the output directories to not get cleaned? I've seen it several times how some people configure generated code directories to be outside the build directory. Some then commit it into VCS. Some even keep that code in the source directory, along with their hand-written code. Getting that deleted could be unpleasant. What do you think?

johnmartel commented 8 years ago

Yup,

one more thing is that Gradle itself does not make a dependency between the ‘clean’ task and the tasks generated by the clean rule, so I am reluctant in creating such a dependency for the plugin. If someone defines its output directory outside of the build folder and want to clean it, they still can call the cleanCompileJavacc task generated by the rule.

Given this, I think we can close this PR without merging.

Regards

On May 19, 2016, at 00:34, Yanus Poluektovich notifications@github.com wrote:

I started writing tests, and then I thought about something. How likely is it that somebody expects the output directories to not get cleaned? I've seen it several times how some people configure generated code directories to be outside the build directory. Some then commit it into VCS. Some even keep that code in the source directory, along with their hand-written code. Getting that deleted could be unpleasant. What do you think?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/johnmartel/javaccPlugin/pull/24#issuecomment-220126413