# Adding external resources to sourceSets in Android

**URL:** <https://discuss.gradle.org/t/adding-external-resources-to-sourcesets-in-android/12704>\
**Category:** Help/Discuss\
**Created:** [November 11, 2015, 6:57am UTC](https://discuss.gradle.org/t/adding-external-resources-to-sourcesets-in-android/12704 "2015-11-11T06:57:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pellyadolfo](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/pellyadolfo/32/3584_2.png) [@pellyadolfo](https://discuss.gradle.org/u/pellyadolfo)\
**Post date:** [November 11, 2015, 6:57am UTC](https://discuss.gradle.org/t/adding-external-resources-to-sourcesets-in-android/12704/1 "2015-11-11T06:57:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pellyadolfo](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/pellyadolfo/32/3584_2.png) [@pellyadolfo](https://discuss.gradle.org/u/pellyadolfo)\
**Post date:** [November 12, 2015, 3:57am UTC](https://discuss.gradle.org/t/adding-external-resources-to-sourcesets-in-android/12704/2 "2015-11-12T03:57:49Z")

</div>

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** )?

---

<div class="post-metadata">

**Author:** ![pellyadolfo](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/pellyadolfo/32/3584_2.png) [@pellyadolfo](https://discuss.gradle.org/u/pellyadolfo)\
**Post date:** [November 13, 2015, 3:33am UTC](https://discuss.gradle.org/t/adding-external-resources-to-sourcesets-in-android/12704/3 "2015-11-13T03:33:51Z")

</div>

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](https://discuss.gradle.org/t/sourcesets-for-paths-not-belonging-to-projects-added-as-dependencies/12720/2)
