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
getByName
fun getByName(name: String?): SourceDirectories
Access (and potentially creates) a new SourceDirectories
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 SourceDirectories.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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["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.2/com/android/build/api/variant/Variant).\n\nsince 7.2\n\nSummary\n-------\n\n| ### Public functions ||\n|------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [SourceDirectories](/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories) | [getByName](/reference/tools/gradle-api/7.2/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 [SourceDirectories](/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories) for a custom source type that can be referenced by its [name](/reference/tools/gradle-api/7.2/com/android/build/api/variant/Sources#getByName(kotlin.String)). |\n\n| ### Public properties ||\n|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|\n| [SourceDirectories](/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories) | [java](/reference/tools/gradle-api/7.2/com/android/build/api/variant/Sources#java()) Access to the Java source folders. |\n\nPublic functions\n----------------\n\n### getByName\n\n```\nfun getByName(name: String?): SourceDirectories\n```\n\nAccess (and potentially creates) a new [SourceDirectories](/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories) for a custom source type that can be referenced by its [name](/reference/tools/gradle-api/7.2/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.2/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 [SourceDirectories.all](/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories#all()).\n\nThese sources directories are attached to the variant and will be visible to Android Studio.\n\nPublic properties\n-----------------\n\n### java\n\n```\nval java: SourceDirectories\n```\n\nAccess to the Java source folders."]]