3

I have an lint.xml file and want to apply it to whole project but not only one module. It can't be found when i move it from module dir to project dir.

This is my config about lintOptions in build.gradle from module

  lintOptions {
        checkReleaseBuilds false
        abortOnError false
        lintConfig file("../lint.xml")
    }

and my lint.xml file is under project dir.(same dir as settings.gradle)

Bruno
  • 3,872
  • 4
  • 20
  • 37
Cyrus
  • 8,995
  • 9
  • 31
  • 58
  • It's a wild guess, but maybe write a function for retreiving the file? – Mariusz Brona Jun 16 '20 at 09:32
  • However it is weird, file() function should exactly that. Maybe you have to copy it to module directory anyway? – Mariusz Brona Jun 16 '20 at 09:43
  • @PanWrona Yes, i have no idea why, if i copy it to module directory, which means i need to change every copy when that lint file changed – Cyrus Jun 16 '20 at 09:47
  • 1
    hey I added a simple function (not sure if it works, but idea is here). Basically you can change one lint file and every time it should be put in every module you have this piece of code. You can also look if you can make it as a hmm global/util function so you only change it in one place – Mariusz Brona Jun 16 '20 at 09:51

1 Answers1

1

I don't know why it's not working exactly, but maybe you have to copy it to module directory anyway?

def copyLintFile(path) {
    from file(path)
    into file("lint.xml")
    file("lint.xml")
}

lintOptions {
        checkReleaseBuilds false
        abortOnError false
        lintConfig copyLintFile("../lint.xml")
    }

Mariusz Brona
  • 1,549
  • 10
  • 12