Question

i have run a code snippet from Gradle Cookbook


apply plugin: 'java'

task "create-dirs" << {
   convention.sourceSets.all*.java.srcDirs*.each { it.mkdirs() }
   convention.sourceSets.all*.resources.srcDirs*.each { it.mkdirs() }
}

when i run i am getting following error

Cause: No such property: sourceSets for class: org.gradle.api.plugins.Convention

i am using Gradle 0.9-rc-3

Was it helpful?

Solution 2

Ok sorry. i got it

it must be

 
apply plugin: 'java'

task "create-dirs" << { sourceSets.all*.java.srcDirs*.each { it.mkdirs() } sourceSets.all*.resources.srcDirs*.each { it.mkdirs() } }

OTHER TIPS

The property all has been removed now ,So you can do it as:

   task "create-dirs" {
        def defaultPackage = "org.akash.gradle";
        ['java', 'groovy', 'resources'].each { String dir ->
           sourceSets*."$dir".srcDirs*.each { dir1 ->
             def newDir = new File(dir1, defaultPackage);
             newDir.mkdirs();
           }
        }
   }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top