Not quite sure why this doesn't work with for-loops, but it does work if you
replace all the for loops with "each".
The first loop:
for (target in makeTargets) {
--> makeTargets.each { target ->
Also; this could be simplified:
invokeWdkBuild("$os", "$arch", "$target")
--> invokeWdkBuild(os, arch, target)
Regards,
Steinar
On Tue, Feb 1, 2011 at 10:57 PM, Bronislav Gabrhelik <[email protected]>wrote:
> Hi,
>
> I am trying to generate tasks, including their dependencies. Here is the
> code:
>
> ==================== build.gradle ==================
> if (rootProject.hasProperty('debug'))
> buildType = 'chk'
> else
> buildType = 'fre'
>
> def operatingSystems = ['wxp', 'wnet', 'wlh']
> def cpuArchs = ['x86', 'x64']
> def makeTargets = ['build', 'clean']
>
> // generate tasks
> for (target in makeTargets) {
> task "${target}"
> for (os in operatingSystems) {
> task "${target}-${os}"
> tasks["${target}"].dependsOn "${target}-${os}"
> for (arch in cpuArchs) {
> if (os != 'wxp' || arch == 'x86')
> {
> task "${target}-${os}-${arch}" << {
> invokeWdkBuild("$os", "$arch", "$target")
> }
> tasks["${target}-${os}"].dependsOn "${target}-${os}-${arch}"
> }
> }
>
> }
> }
>
> // are there both dependencies??
> println('dependencies: ' +
> tasks['build-wlh'].taskDependencies.getDependencies())
>
> def invokeMakefile(String os, String arch, String target) {
> println( "building WDK $target-$os-$arch")
> }
>
> ======EOF===========
> ==== output is following ====
> >gradle -q build-wlh
> dependencies: [task ':driver/win:build-wlh-x86', task
> ':driver/win:build-wlh-x64']
> building clean-wlh-x64
> building clean-wlh-x64
> ======== EOF=========
>
> Simply the invokeWdkBuild() is called from any task with the values,
> which are the very last iterated items in arrays. I.e.
> 'clean','wlh','x64'.
>
> What I am doing wrong? How can I achieve that the values are expanded
> right during iteration.
>
> TIA,
> Bronislav Gabrhelik
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>