eriwen / gradle-js-plugin

Gradle plugin for working with JS
http://eriwen.github.io/gradle-js-plugin
Apache License 2.0
382 stars 113 forks source link

SourceSets syntax for javascript is inconsistent with other languages #57

Open jamiefolson opened 11 years ago

jamiefolson commented 11 years ago

Other language plugins (e.g. Java, Groovy and Scala) create and or modify project.sourceSets, which allows the gradle DSL to be consistent across different languages. It would be great if the javascript source sets were consistent with the other languages in this respect.

Desirable example: specifying LESS and javascript sources

sourceSets {
    main {
        javascript {
            exclude "*.min.js"
        }
        less {
            exclude "_*"
        }
    }
}
eriwen commented 11 years ago

Makes sense to me. I'll investigate why this is. Thanks.

jamiefolson commented 11 years ago

FYI, I did some looking and the DefaultSourceSetsContainer instantiates DefaultSourceSets, which kind of assume a jvm-compiled language (ie there's a classes output location). The other plugins mostly just apply the java plugin, which makes it easy for them.

For now, you can just do what java does and explicitly add your own sourcesSet object (subclassed to allow javascript-specific source sets). A more general solution could be creating a delegating SourceSetsContainer that creates javascript source sets and delegates any other source sets to the previously existing project.sourceSets object. I think this might call for talking to the Gradle folks, though.