I have a custom plugin which includes a custom extended task type (RunAssembler). To access this task type I have configured the buildscript to find the plugin from my local repo and used an import in the root build.xml. Finally I have created a task using the new type.
All this works fine … continue below code …
buildscript {
repositories {
mavenCentral()
maven { url "file://$projectDir/pluginRepo" }
}
dependencies {
classpath 'com.spindrift.gradle:atg-plugin:0.1'
classpath 'org.apache.commons:commons-lang3:3.1'
}
}
apply plugin: 'atg'
import com.spindrift.gradle.atg.tasks.RunAssembler
...
task runAssembler(type: RunAssembler) {
workingDir atgBinDir
generateArguments()
commandLine arguments
}
...
ext {
profiles=[]
}
…
Now I want to take this a step further to add profiles combinations. So in my main build.gradle I change the task to be a simple one. Then I want to apply profiles that will have their own custom task and add their task as dependencies to the generic version, enabling me to run any profile version or all by executing the generic task.
task runAssembler { }
// find all files in a directory with pattern *-profile-config.gradle and apply. For now just try 1
apply from: 'buildtools/gradle/live-profile-config.gradle'
This profile has the following defined:
ext {
profiles+=[
'live':[
'runAssembler':[
'modules':['DafEar.Admin','DPS','DSS','DCS.PublishingAgent','DCS.AbandonedOrderServices','Fulfillment'],
'options':['liveconfig'],
'layers':[],
'outputEarFile':"$buildDir/atg/ATGProduction.ear"
]
],
]
}
import com.spindrift.gradle.atg.tasks.RunAssembler
task runAssemblerLive(type: RunAssembler) {
workingDir atgBinDir
outputEarFile profiles.live.runAssembler.outputEarFile
options profiles.live.runAssembler.options
modules profiles.live.runAssembler.modules
generateArguments()
commandLine arguments
}
task runAssembler {
dependsOn runAssemblerLive
}
So the basic error I get is:
FAILURE: Build failed with an exception.
* Where:
Script '/Users/...../buildtools/gradle/live-profile-config.gradle' line: 16
* What went wrong:
Could not compile script '/Users/..../buildtools/gradle/live-profile-config.gradle'.
> startup failed:
script '/Users/..../buildtools/gradle/live-profile-config.gradle': 16: unable to resolve class com.spindrift.gradle.atg.tasks.RunAssembler
@ line 16, column 1.
import com.spindrift.gradle.atg.tasks.RunAssembler
I’ve even copied the buildscript and applied the plugin in the applied script but still the same error. We’ve done this type of apply from many and multiple times on our bigger projects with imports but those imports have been used directly in the tasks, so this is the first time I think that I am attempting to use a custom task type from a custom plugin in an applied file. Is this a limitation or is there a different way I need to configure this ?
Currently using gradle-1.7
Just to add that all the task dependency and profiling worked fine when I had it all in the root build.gradle, but because I want the ability to just add profile definitions as needed to extend the task list, I’ve split it out to separate files to be applied from the build.gradle and this started occurring. I can’t seem to see anything useful from the debug output either.