# Sources

# Sources

<br />

```
@Incubating interface Sources
```

<br />

*** ** * ** ***

Provides access to all source directories for a[Variant](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/variant/Variant).

since 7.2

## Summary

|                                                                                                                                                                                                                                                                                                                                                            ### Public functions                                                                                                                                                                                                                                                                                                                                                            ||
|-----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SourceDirectories](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories) | [getByName](https://developer.android.com/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](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories)for a custom source type that can be referenced by its[name](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/variant/Sources#getByName(kotlin.String)). |

|                                                                                                                                  ### Public properties                                                                                                                                  ||
|-----------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SourceDirectories](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories) | [java](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/variant/Sources#java()) Access to the Java source folders. |

## Public functions

### getByName

```
fun getByName(name: String?): SourceDirectories
```

Access (and potentially creates) a new[SourceDirectories](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories)for a custom source type that can be referenced by its[name](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/variant/Sources#getByName(kotlin.String)).

The first caller will create the new instance, other callers with the same[name](https://developer.android.com/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](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/variant/SourceDirectories#all()).

These sources directories are attached to the variant and will be visible to Android Studio.

## Public properties

### java

```
val java: SourceDirectories
```

Access to the Java source folders.