Adding external resources to sourceSets in Android

Hi, I have an multiproject android configuration with an structure as follows

  • app
    • manifest
    • java
    • res
  • library 1
    • manifest
    • java
    • res
      • layout
      • values
      • xml
    • assets
  • library 2

when building app, I need to include some of the non-java resources from the libraries (string.xml, fonticons en xml and ttf assets) when they are not included in the flavours as dependencies. I have tried extending the sourceSets definition to access these library resources as external resources, but no combination seems to work. I could not find anything in manuals referring to this case of external non-java paths and I wonder if is a forbidden case by any reason. Clarify that Library1 is not included as a dependency.

This is my set of unsuccessful experimental configurations.

sourceSets {

    main.res.srcDirs += '/home/username/AndroidStudioProjects/Lib1/lib/src/main/res/values'

    main.res.srcDirs += new File("/home/username/AndroidStudioProjects/Lib1/lib/src/main/res/values").absolutePath

    main.res.srcDirs += new File('/home/username/AndroidStudioProjects/Lib1/lib/src/main/res/values').absolutePath

    main.res.srcDirs += new File(new URI("file:///home/username/AndroidStudioProjects/Lib1/lib/src/main/res/values")).absolutePath

    main.res.srcDirs += '../../Lib1/lib/src/main/resources/values'

    main.res.srcDirs += '../Lib1/lib/src/main/resources/values'

    main.res.srcDirs += '../../Lib1/lib/src/main/res/values'

    main.res.srcDirs += '../Lib1/lib/src/main/res/values'

    main.res.srcDirs += '../Lib1/lib/src/main/resources/xml'

    main.res.srcDirs += '../Lib1/lib/src/main/assets'

    main.resources.srcDirs += 'project(Lib1).sourceSets.main.srcDirs'

    main.resources.srcDirs += 'project(:Lib1).sourceSets.main.srcDirs'
    
    main.resources.srcDirs += 'project(:..:Lib1).sourceSets.main.srcDirs'
}

So:

  1. is this allowed when the path does not belong to a dependency? Maybe is my failure or maybe I am dealing with something impossible.

  2. could someone point out, please, how an external non-java resource is expected to be referenced in build.gradle so it is included in the build?

Thanks

Should I add a new enhancement request on Gradle issues list?

Or this is a case intentionally not covered by gradle? (i.e. request for amending the documentation saying that sourceSet paths must be from projects already referred as dependencies)?

UPDATE: as there is not a clear answer for this issue, I opened a bug request in gradle’s forum. Follow here: sourceSets for paths not belonging to projects added as dependencies