0

My build.gradle file contains the following:

sourceSets {
   main { output.resourcesDir = "build/app" }
}

This is working well, content of src/main/resources is correctly copied into build/app folder.

However, I have some resources (scripts) for which I need to force the line ending character. I need to always force an LF. In order word, need to be sure that we never have any CRLF.

Question: is it possible to filter resources included via a sourceSets?

Ragul
  • 3,042
  • 3
  • 13
  • 29
hublo
  • 776
  • 2
  • 9
  • 26

1 Answers1

1

Following works well:

import org.apache.tools.ant.filters.FixCrLfFilter

processResources {
    filesMatching('**/*.sh') {
        filter(FixCrLfFilter.class,
        eol:FixCrLfFilter.CrLf.newInstance("lf"))
    }
    filesMatching('**/*.properties') {
        filter(FixCrLfFilter.class,
        eol:FixCrLfFilter.CrLf.newInstance("lf"))
    }
    filesMatching('**/*.xml') {
        filter(FixCrLfFilter.class,
        eol:FixCrLfFilter.CrLf.newInstance("lf"))
    }
}
Oleg Shavrov
  • 73
  • 1
  • 7
hublo
  • 776
  • 2
  • 9
  • 26