Skip to content

Commit

Permalink
Renamed CodeOwnersTask to CodeOwnersResourcesTask
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzo committed Dec 24, 2023
1 parent 77682da commit 0e7c06e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README-jvm.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ androidComponents.onVariants {
```

## Consuming the generated `mappedCodeOwnersFile`
Each `CodeOwnersTask` produces a .CODEOWNERS like file which translates build directories to Java packages (in folder format, not '.').
Each `CodeOwnersResourcesTask` produces a .CODEOWNERS like file which translates build directories to Java packages (in folder format, not '.').

To explain this better, given a `.CODEOWNERS` file:
```
Expand Down
2 changes: 1 addition & 1 deletion README-kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ androidComponents.onVariants {
```

## Consuming the generated `mappedCodeOwnersFile`
Each `CodeOwnersTask` produces a .CODEOWNERS like file which translates build directories to Java packages (in folder format, not '.').
Each `CodeOwnersResourcesTask` produces a .CODEOWNERS like file which translates build directories to Java packages (in folder format, not '.').

To explain this better, given a `.CODEOWNERS` file:
```
Expand Down
4 changes: 2 additions & 2 deletions demo-project-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import io.github.gmazzo.codeowners.CodeOwnersReportTask
import io.github.gmazzo.codeowners.CodeOwnersTask
import io.github.gmazzo.codeowners.CodeOwnersResourcesTask

// This should not be considered part of the demo project
// It was added to be able to create test tasks for the generated mapping files
Expand All @@ -24,7 +24,7 @@ val collectTask = tasks.register<Sync>("collectTaskOutputs") {
}

rootProject.allprojects project@{
tasks.withType<CodeOwnersTask>().all task@{
tasks.withType<CodeOwnersResourcesTask>().all task@{
collectTaskOutputs.from(files(simplifiedMappedCodeOwnersFile, rawMappedCodeOwnersFile)) {
into("actualMappings/${project.path}")
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/jvm-plugin/src/main/kotlin/CodeOwnersJVMDSL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package org.gradle.kotlin.dsl

import com.android.build.api.variant.Component
import io.github.gmazzo.codeowners.CodeOwnersJVMSourceSet
import io.github.gmazzo.codeowners.CodeOwnersTask
import io.github.gmazzo.codeowners.CodeOwnersResourcesTask
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.tasks.TaskProvider

var Component.codeOwners: CodeOwnersJVMSourceSet
get() = (this as ExtensionAware).extensions.getByName<CodeOwnersJVMSourceSet>(Component::codeOwners.name)
internal set(value) = (this as ExtensionAware).extensions.add<CodeOwnersJVMSourceSet>(Component::codeOwners.name, value)

var CodeOwnersJVMSourceSet.generateTask: TaskProvider<CodeOwnersTask>
get() = (this as ExtensionAware).extensions.getByName<TaskProvider<CodeOwnersTask>>(CodeOwnersJVMSourceSet::generateTask.name)
internal set(value) = (this as ExtensionAware).extensions.add<TaskProvider<CodeOwnersTask>>(CodeOwnersJVMSourceSet::generateTask.name, value)
var CodeOwnersJVMSourceSet.generateTask: TaskProvider<CodeOwnersResourcesTask>
get() = (this as ExtensionAware).extensions.getByName<TaskProvider<CodeOwnersResourcesTask>>(CodeOwnersJVMSourceSet::generateTask.name)
internal set(value) = (this as ExtensionAware).extensions.add<TaskProvider<CodeOwnersResourcesTask>>(CodeOwnersJVMSourceSet::generateTask.name, value)
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CodeOwnersJVMPlugin : CodeOwnersPlugin<CodeOwnersJVMExtension>(CodeOwnersJ
else -> name.capitalize()
}

generateTask = tasks.register<CodeOwnersTask>("generate${prefix}CodeOwnersResources") {
generateTask = tasks.register<CodeOwnersResourcesTask>("generate${prefix}CodeOwnersResources") {
group = TASK_GROUP
description = "Process CODEOWNERS entries for source set '${this@ss.name}'"

Expand Down Expand Up @@ -160,7 +160,7 @@ class CodeOwnersJVMPlugin : CodeOwnersPlugin<CodeOwnersJVMExtension>(CodeOwnersJ
}
}}

private fun CodeOwnersTask.addDependencies(
private fun CodeOwnersResourcesTask.addDependencies(
objects: ObjectFactory,
sourceSet: CodeOwnersJVMSourceSet,
configuration: Configuration,
Expand Down Expand Up @@ -193,7 +193,7 @@ class CodeOwnersJVMPlugin : CodeOwnersPlugin<CodeOwnersJVMExtension>(CodeOwnersJ
sources: CodeOwnersJVMSourceSet
) = configure {
from(extension.addCodeOwnershipAsResources.and(sources.enabled).map {
if (it) sources.generateTask.map(CodeOwnersTask::outputDirectory) else emptyList<Any>()
if (it) sources.generateTask.map(CodeOwnersResourcesTask::outputDirectory) else emptyList<Any>()
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.util.TreeSet

@CacheableTask
@Suppress("LeakingThis")
abstract class CodeOwnersTask : DefaultTask() {
abstract class CodeOwnersResourcesTask : DefaultTask() {

@get:Internal
abstract val rootDirectory: DirectoryProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class CodeOwnersJVMPluginTest {
)

private fun Project.testGenerateCodeOwners(vararg expectedInfos: Pair<String, Set<String>>, expectedMappings: String) {
tasks.withType<CodeOwnersTask>().all { generateCodeOwnersInfo() }
tasks.withType<CodeOwnersResourcesTask>().all { generateCodeOwnersInfo() }

val actualInfos = layout.buildDirectory.dir("codeOwners/resources/main").get().let { dir ->
check(dir.asFile.isDirectory) { "'${dir.asFile}' is not a directory" }
Expand Down

0 comments on commit 0e7c06e

Please sign in to comment.