Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude directory from sourceSet not working in Gradle

Tags:

gradle

I want to exclude a directory in Gradle .. I'm using the code below .. When I do a minus (i've also tried exclude the directory that I'm trying to remove is still present in srcDirs (when I output it at the end).

Suggestions ?

apply plugin: 'java'

sourceSets {
  test {
    java {
      srcDirs 'src/test/unit/java'
      minus 'src/test/java'            
    }
  }
}

task outputDirs << { sourceSets.test.java.srcDirs.each{f -> println(f)}}
like image 519
vicsz Avatar asked Mar 16 '12 18:03

vicsz


Video Answer


1 Answers

try this instead:

apply plugin: 'java'

sourceSets {
    test {
        java {
            srcDirs  = ['src/test/unit/java']
        }
    }
}

task outputDirs << { sourceSets.test.java.srcDirs.each{f -> println(f)}}

This reassigns the list of source directories (here only one) to the srcDirs property. using

srcDirs  = 'src/test/unit/java'

as in your sample, just adds another source folder to the existing ones.

regards, René

like image 194
Rene Groeschke Avatar answered Sep 28 '22 02:09

Rene Groeschke