Stay organized with collections
Save and categorize content based on your preferences.
Sources
@Incubating interface Sources
Provides access to all source directories for a Variant
.
since 7.2
Summary
Public functions |
SourceDirectories.Flat |
Access (and potentially creates) a new Flat for a custom source type that can be referenced by its name .
|
Public functions
getByName
fun getByName(name: String): SourceDirectories.Flat
Access (and potentially creates) a new Flat for a custom source type that can be referenced by its name
.
The first caller will create the new instance, other callers with the same name
will get the same instance returned. Any callers can obtain the final list of the folders registered under this custom source type by calling Flat.all.
These sources directories are attached to the variant and will be visible to Android Studio.
Public properties
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# Sources\n=======\n\n\n```\n@Incubating interface Sources\n```\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nProvides access to all source directories for a [Variant](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Variant).\n\nsince 7.2\n\nSummary\n-------\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [SourceDirectories.Flat](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Flat) | [getByName](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#getByName(kotlin.String))`(name: `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Access (and potentially creates) a new Flat for a custom source type that can be referenced by its [name](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#getByName(kotlin.String)). |\n\n| ### Public properties ||\n|-------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [SourceDirectories.Flat](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Flat)`?` | [aidl](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#aidl()) Access to the aidl sources folders if [com.android.build.api.dsl.BuildFeatures.aidl](/reference/tools/gradle-api/7.4/com/android/build/api/dsl/BuildFeatures#aidl()) is true otherwise null |\n| [SourceDirectories.Layered](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Layered)`?` | [assets](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#assets()) Access to the Android assets sources folders. |\n| [SourceDirectories.Flat](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Flat)`?` | [java](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#java()) Access to the Java source folders. |\n| [SourceDirectories.Layered](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Layered)`?` | [jniLibs](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#jniLibs()) Access to the JNI libraries folders |\n| [SourceDirectories.Flat](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Flat)`?` | [kotlin](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#kotlin()) Access ot the Kotlin source folders. |\n| [SourceDirectories.Layered](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Layered)`?` | [mlModels](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#mlModels()) Access to the machine learning models folders. |\n| [SourceDirectories.Flat](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Flat)`?` | [renderscript](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#renderscript()) Access to the renderscript sources folders if [com.android.build.api.dsl.BuildFeatures.renderScript](/reference/tools/gradle-api/7.4/com/android/build/api/dsl/BuildFeatures#renderScript()) is true otherwise null. |\n| [SourceDirectories.Layered](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Layered)`?` | [res](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#res()) Access to the Android resources sources folders. |\n| [SourceDirectories.Flat](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Flat)`?` | [resources](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#resources()) Access to the Java-style resources sources folders. |\n| [SourceDirectories.Layered](/reference/tools/gradle-api/7.4/com/android/build/api/variant/SourceDirectories.Layered)`?` | [shaders](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#shaders()) Access to the shaders sources folders if [com.android.build.api.dsl.BuildFeatures.shaders](/reference/tools/gradle-api/7.4/com/android/build/api/dsl/BuildFeatures#shaders()) is true otherwise null |\n\nPublic functions\n----------------\n\n### getByName\n\n```\nfun getByName(name: String): SourceDirectories.Flat\n```\n\nAccess (and potentially creates) a new Flat for a custom source type that can be referenced by its [name](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#getByName(kotlin.String)).\n\nThe first caller will create the new instance, other callers with the same [name](/reference/tools/gradle-api/7.4/com/android/build/api/variant/Sources#getByName(kotlin.String)) will get the same instance returned. Any callers can obtain the final list of the folders registered under this custom source type by calling Flat.all.\n\nThese sources directories are attached to the variant and will be visible to Android Studio.\n\nPublic properties\n-----------------\n\n### aidl\n\n```\nval aidl: SourceDirectories.Flat?\n```\n\nAccess to the aidl sources folders if [com.android.build.api.dsl.BuildFeatures.aidl](/reference/tools/gradle-api/7.4/com/android/build/api/dsl/BuildFeatures#aidl()) is true otherwise null \n\n### assets\n\n```\nval assets: SourceDirectories.Layered?\n```\n\nAccess to the Android assets sources folders. \n\n### java\n\n```\nval java: SourceDirectories.Flat?\n```\n\nAccess to the Java source folders. \n\n### jniLibs\n\n```\nval jniLibs: SourceDirectories.Layered?\n```\n\nAccess to the JNI libraries folders \n\n### kotlin\n\n```\nval kotlin: SourceDirectories.Flat?\n```\n\nAccess ot the Kotlin source folders. \n\n### mlModels\n\n```\nval mlModels: SourceDirectories.Layered?\n```\n\nAccess to the machine learning models folders. \n\n### renderscript\n\n```\nval renderscript: SourceDirectories.Flat?\n```\n\nAccess to the renderscript sources folders if [com.android.build.api.dsl.BuildFeatures.renderScript](/reference/tools/gradle-api/7.4/com/android/build/api/dsl/BuildFeatures#renderScript()) is true otherwise null. \n\n### res\n\n```\nval res: SourceDirectories.Layered?\n```\n\nAccess to the Android resources sources folders. \n\n### resources\n\n```\nval resources: SourceDirectories.Flat?\n```\n\nAccess to the Java-style resources sources folders. \n\n### shaders\n\n```\nval shaders: SourceDirectories.Layered?\n```\n\nAccess to the shaders sources folders if [com.android.build.api.dsl.BuildFeatures.shaders](/reference/tools/gradle-api/7.4/com/android/build/api/dsl/BuildFeatures#shaders()) is true otherwise null"]]