hierynomus / license-gradle-plugin

Manage your license(s)
http://www.javadude.nl
Other
409 stars 114 forks source link

Test exclusions are ignored with Java plugin and Gradle 3.4.1 #131

Open simonbrandhof opened 7 years ago

simonbrandhof commented 7 years ago

The inclusion/exclusion configuration is ignored by the task licenseTest, whereas it's correctly handled by licenseMain.

The behavior can be reproduced with this project: https://github.com/simonbrandhof/reproducers/tree/master/gradle-license-test-exclusion.

Do I miss something ? Thanks.

hierynomus commented 7 years ago

Hi Simon,

Took me a few minutes to figure it out :) I started out with adding the same file to the main/resources and excluding it in the same way and that also didn't work.

It probably is not very clear in the documentation, but the in/exclusions are based on the sourcesets, that means that the paths are relative to the sourceSetDir(s). So if you would make the path sample/*.java it does work.

simonbrandhof commented 7 years ago

Thanks for the answer. That can't work as there's no way to distinguish src/test/resources from src/test/java. Imagine that src/test/resources/sample/NoHeader.java is moved to src/test/resources/foo/NoHeader.java, then it conflicts with src/test/java/foo directory.

hierynomus commented 7 years ago

Hi Simon,

Yes, it would. On the other hand I don't think you should be storing java files in the resources directory. And I think when I modeled this, I looked closely at how in other parts of Gradle the inclusion/exclusion worked and modeled it as such.

2017-03-13 14:01 GMT+01:00 Simon Brandhof notifications@github.com:

Thanks for the answer. That can't work as there's no way to distinguish src/test/resources from src/test/java. Imagine that src/test/resources/sample/ NoHeader.java is moved to src/test/resources/foo/NoHeader.java, then it conflicts with src/test/java/foo directory.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hierynomus/license-gradle-plugin/issues/131#issuecomment-286100264, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHLo2fKg3TR_5gUiWJjeMGMTd3Qlh42ks5rlT4YgaJpZM4MagVT .

simonbrandhof commented 7 years ago

Storing Java sources makes sense for the tests of a code analyzer like github.com/sonarsource/sonarqube! I don't think it's up to the Gradle plugin to decide what should be inside test directories. It should allow flexibility.

hierynomus commented 7 years ago

I see your point. Would it improve if we wold make the in/exclusions per sourceset? If so can you open an issue for that?

Op 14 mrt. 2017 10:39 a.m. schreef "Simon Brandhof" < notifications@github.com>:

Storing Java sources makes sense for the tests of a code analyzer like github.com/sonarsource/sonarqube! I don't think it's up to the Gradle plugin to decide what should be inside test directories. It should allow flexibility.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hierynomus/license-gradle-plugin/issues/131#issuecomment-286369274, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHLoyUFS9hAuxUkKMFyiAJ8H0oZ4nb_ks5rlmBbgaJpZM4MagVT .

hierynomus commented 7 years ago

Actually now that I'm working on the plugin. The current tasks extend SourceTask, so I think you can just set the includes/excludes on the task level. Have you tried that already?