|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Assembling a JAR for a custom source setI`m trying to reuse this example:
build.gradle task intTestJar(type: Jar) { from sourceSets.intTest.classes } I`m trying to do it from custom plugin so I have: public class LibraryPlugin implements Plugin { ... def void use (Project project, ProjectPluginsContainer projectPluginsHandler){ project.usePlugin('java') ... project.task unitTestJar(type: Jar) { from project.sourceSets.unitTest.classes } } ... } The gradle throws exception on evaluating: * What went wrong: A problem occurred evaluating project ':app'. Cause: No signature of method: lv.ctco.scm.cs.LibraryPlugin.unitTestJar() is app licable for argument types: (java.util.LinkedHashMap, lv.ctco.scm.cs.LibraryPlug in$_LibraryBuild_closure3) values: [[type:class org.gradle.api.tasks.bundling.Ja r], lv.ctco.scm.cs.LibraryPlugin$_LibraryBuild_closure3@10948cf] How to reuse task type of other plugin? |
|
|
Re: Assembling a JAR for a custom source setHi Narco,
On Oct 30, 2009, at 3:21 PM, Narco wrote: > > I`m trying to reuse this example: > build.gradle > > task intTestJar(type: Jar) { > from sourceSets.intTest.classes > } > > > I`m trying to do it from custom plugin so I have: > > public class LibraryPlugin implements Plugin { > ... > def void use (Project project, ProjectPluginsContainer > projectPluginsHandler){ > project.usePlugin('java') > ... > project.task unitTestJar(type: Jar) { > from project.sourceSets.unitTest.classes > } > } > ... > } The 'task taskName(...)' syntax you can only use from the build script. We do some underlying transformation to make this legal Groovy code. What you can do in a plugin class like above is to use the 'normal' api: project.tasks.add('unitTestJar', Jar).from project.sourceSets.unitTest.classes We will improve this in the future. The above way of declaring a plugin will always be possible. But alternatively you will be able to simply declare another build script as a plugin where you can use all the syntactic sugar we provide for that. - Hans -- Hans Dockter Gradle Project Manager http://www.gradle.org --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Assembling a JAR for a custom source setI believe I am missing something but gradle gives an error. Tried with Test task and gave the same error:
* What went wrong: A problem occurred evaluating project ':app'. Cause: Could not find method add() for arguments [unitTestJar, class org.gradle. api.tasks.bundling.Jar, lv.ctco.scm.cs.LibraryPlugin$_LibraryBuild_closure3@1e35 ecd] on task container. My plugin: project.sourceSets { unitTest { compileClasspath = project.sourceSets.main.classes + project.configurations.compile + project.configurations.testCompile runtimeClasspath = project.sourceSets.unitTest.classes + project.sourceSets.main.classes + project.configurations.compile + project.configurations.testRuntime } } project.tasks.add('unitTestJar', Jar){ from project.sourceSets.unitTest.classes }
|
|
|
Re: Assembling a JAR for a custom source setFound the correct solution:
project.sourceSets { 'test-unit' { compileClasspath = project.sourceSets.main.classes + project.configurations.compile + project.configurations.testCompile runtimeClasspath = project.sourceSets.'test-unit'.classes + project.sourceSets.main.classes + project.configurations.compile + project.configurations.testRuntime } } project.getTasks().add('testUnitJar', Jar.class) project.testUnitJar.from(project.sourceSets.'test-unit'.classes) project.testUnitJar.fileSet(dir: project.sourceSets.'test-unit'.classesDir) project.testUnitJar.appendix = 'test-unit' project.getTasks().add('testUnitTest', Test.class) project.testUnitTest.testClassesDir = project.sourceSets.'test-unit'.classesDir project.testUnitTest.classpath = project.sourceSets.'test-unit'.runtimeClasspath Works nice, but I need to define almost every task attribute by hands. I was expecting that 'test-unit' folder will be mapped everywhere by default.
|
|
|
Re: Assembling a JAR for a custom source setNarco wrote:
That would be good. Could you add a JIRA issue for this? Narco wrote: -- Adam Murdoch Gradle Developer http://www.gradle.org |
|
|
Re: Assembling a JAR for a custom source setIt is hard to define what I want. By adding new sourceSet user wouldn`t always want new tests. There may be anything else. So that means customly created tasks shouldn`t be somehow automatically reconfigured. I`m happy I got it how to create my own targets in plugins and let`s leave it as is for now.
|
| Free embeddable forum powered by Nabble | Forum Help |