Custom sourceSets processResources task

(jdenet.anteo) #1

Hi, In a java project, i have 2 resources directories, the first should be copied directly and the content of the second one should be “filtered” to replace properties like ${…}.

So I’ve defined a custom sourceSet with the directory to be filtered:

sourceSets {
    filtered {
         resources { srcDir 'src/config' }
    main {
        java { srcDir 'src/java'
        resources { srcDir 'src/resources' }
        compileClasspath += filtered.output
        runtimeClasspath += filtered.output

According to the documentation, the java plugins adds a task called processFilteredResources. The task should be the perfect place to put my filtering stuff.

  println 'testFilteredResources'
  // filter(,project: ant.project)

But during evaluation, I have the folowibng error: Could not find method processFilteredResources() for arguments [build_4t503e7cqod04a732sqn479dli$_run_closure4@2849f686] on root project

I’m using Gradle 1.12

Please tell me if it is the best approach and if I’m missing something. Cheers,


(Peter Niederwieser) #2

Sounds like the build script might be trying to configure ‘processFilteredResources’ before the source set has been added.

(jdenet.anteo) #3

Hi Peter,

Declaring the sourceSets before configuring processFilteredResources task solved the problem.

Thank you,