|
| 1 | +import org.gradle.api.Project |
| 2 | +import tools.forma.android.target.AndroidTargetTypes |
| 3 | +import tools.forma.android.target.deriveTargetType |
| 4 | +import tools.forma.android.target.targetPlugin |
| 5 | +import tools.forma.android.visibility.Public |
| 6 | +import tools.forma.android.visibility.Visibility |
| 7 | +import tools.forma.deps.core.FormaDependency |
| 8 | +import tools.forma.owners.NoOwner |
| 9 | +import tools.forma.owners.Owner |
| 10 | + |
| 11 | +// F-072: Sample Path B derived target for modules that need the safe-args plugin. |
| 12 | +// Registered at class load (before call sites execute) via top-level val. |
| 13 | +// nameSuffix kept as "res" so SuffixNameMatcher + existing consumers continue to work |
| 14 | +// without touching the dependency matrix or directory names. |
| 15 | +private val navigationSafeArgs = targetPlugin(id = "androidx.navigation.safeargs.kotlin") |
| 16 | + |
| 17 | +val NavigationResType = deriveTargetType( |
| 18 | + id = "sample.navigation-res", |
| 19 | + base = AndroidTargetTypes.res, |
| 20 | + nameSuffix = "res", |
| 21 | + plugins = listOf(navigationSafeArgs), |
| 22 | +) |
| 23 | + |
| 24 | +/** |
| 25 | + * Resources target that carries the androidx.navigation.safeargs.kotlin plugin (Path B). |
| 26 | + * Call sites are Bazel-flat: only attributes, no plugin ids. |
| 27 | + * |
| 28 | + * Delegates to [resourcesTarget] with [NavigationResType] so type-owned plugins auto-apply. |
| 29 | + */ |
| 30 | +fun Project.navigationRes( |
| 31 | + packageName: String, |
| 32 | + owner: Owner = NoOwner, |
| 33 | + visibility: Visibility = Public, |
| 34 | + dependencies: FormaDependency = emptyDependency(), |
| 35 | + manifestPlaceholders: Map<String, Any> = emptyMap() |
| 36 | +) { |
| 37 | + resourcesTarget( |
| 38 | + type = NavigationResType, |
| 39 | + packageName = packageName, |
| 40 | + owner = owner, |
| 41 | + visibility = visibility, |
| 42 | + dependencies = dependencies, |
| 43 | + manifestPlaceholders = manifestPlaceholders, |
| 44 | + ) |
| 45 | +} |
0 commit comments