license-gradle-plugin icon indicating copy to clipboard operation
license-gradle-plugin copied to clipboard

Cannot add sourceSets to check for license in non-java gradle project

Open vermavikrant opened this issue 8 years ago • 12 comments
trafficstars

The type of project is javascript gradle. None of the file has license in it. On running license:license gradle task, it completes successfully, without scanning through 'src' folder. Assuming sourceSets is not set properly, if i set it manually by giving it list of all files in 'src', still it completes successfully.

vermavikrant avatar Nov 30 '16 10:11 vermavikrant

Meanwhile I managed to get licenseFormat (which adds license to files) work, after going through readme.

task licenseFormatSrc (type:nl.javadude.gradle.plugins.license.License) {
    source = fileTree(dir: "src")
}
licenseFormat.dependsOn licenseFormatSrc

This logic doesn't work with license check task.

vermavikrant avatar Nov 30 '16 11:11 vermavikrant

I'm having the same issue. Hopefully this gets resolved.

ewortzman avatar Dec 21 '16 17:12 ewortzman

What is the problem with the license check task @ewortzman @vermavikrant ?

hierynomus avatar Apr 13 '17 09:04 hierynomus

License check task should fail when files dont have license headers. But for non-java projects (javascript project in my case), license check task completes successfully without checking for headers. My guess is it doesn't know where the src files are.

vermavikrant avatar Apr 13 '17 10:04 vermavikrant

Do you have a sample project to analyze? As I'm working on the plugin right now, I'd prefer to tackle this if I can.

hierynomus avatar Apr 13 '17 11:04 hierynomus

I am afraid I dnt have any sample project link to share. Basically it would be a new gradle javascript project. Place any .js file in src directory (src dir is kept at root level). Run license check plugin. For me it passes even though .js file in src folder doesnt have any license header.

If i follow the approach which i mentioned in 2nd comment above, license format task works fine but license check still doesnt work.

vermavikrant avatar Apr 13 '17 12:04 vermavikrant

What kind of gradle plugins would a javascript project consist of?

hierynomus avatar Apr 13 '17 12:04 hierynomus

Good point. I dont think i added any javascript specific plugin. So basically any non-java gradle project

vermavikrant avatar Apr 13 '17 12:04 vermavikrant

I'm havin the same issue with a gradle project delegating parts the build to an ant script (dont ask me why). I can configure the licenseFormat task following recommendations from the readme. But it does not applies to the licenseMain task which still looks in /src/main/java regardless of the provided source folder.

Tasks to be executed: [task ':licenseMain']
:licenseMain (Thread[main,5,main]) started.
:licenseMain
file or directory '... \src\main\resources', not found
file or directory '... \src\main\java', not found
Skipping task ':licenseMain' as it has no source files.
:licenseMain UP-TO-DATE
:licenseMain (Thread[main,5,main]) completed. Took 0.021 secs.

For licenceFormat, i do the following to point to my "project" folder containing all my source tree:

task ylicenseFormat(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {
    source = fileTree(dir: "project")
}
licenseFormat.dependsOn ylicenseFormat

and this part works like a charm.

I also tried to do the same with the licenceCheck task:

task ylicenseCheck(type: com.hierynomus.gradle.license.tasks.LicenseCheck) {
    source = fileTree(dir: "project")
}
licenseCheck.dependsOn ylicenseCheck

but this gives me > Could not find property 'licenseCheck' on root project 'myproject'.

Okryann avatar Jun 09 '17 09:06 Okryann

I found a way to workaround the problem somehow, by just calling my own task "ylicenseCheck" manually...

task ylicenseCheck(type: com.hierynomus.gradle.license.tasks.LicenseCheck) {
    source = fileTree(dir: "project")
}

Okryann avatar Jun 09 '17 10:06 Okryann

If you have the java plugin added, the only thing you need to do is declare a new sourceSet in your build gradle file. The plugin should then automatically generate a check task for it.

hierynomus avatar Jun 09 '17 11:06 hierynomus

@hierynomus Can you please provide an example to such a sourceSet. I'm ending up in overwriting the main sourceSet but what I really need is to add another sourceSet with the path src/main/webapp where all *.js files are staying

magnusekstrand avatar Jan 24 '18 09:01 magnusekstrand