Skip to content

Commit

Permalink
Move configuration to before project evaluation (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshafeinberg authored Mar 18, 2024
1 parent 312b8e0 commit c67c042
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import com.dropbox.affectedmoduledetector.util.toPathSections
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.invocation.Gradle
import org.gradle.api.UnknownDomainObjectException
import org.gradle.api.logging.Logger
import java.io.File

Expand Down Expand Up @@ -115,7 +115,7 @@ abstract class AffectedModuleDetector {
var isConfigured = false

@JvmStatic
fun configure(gradle: Gradle, rootProject: Project) {
fun configure(rootProject: Project) {
require(rootProject == rootProject.rootProject) {
"Project provided must be root, project was ${rootProject.path}"
}
Expand Down Expand Up @@ -193,7 +193,11 @@ abstract class AffectedModuleDetector {
private fun getInstance(project: Project): AffectedModuleDetector? {
val extensions = project.rootProject.extensions

return extensions.getByName(ROOT_PROP_NAME) as? AffectedModuleDetector
return try {
extensions.getByName(ROOT_PROP_NAME) as? AffectedModuleDetector
} catch (e: UnknownDomainObjectException) {
null
}
}

private fun getOrThrow(project: Project): AffectedModuleDetector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {

registerSubprojectConfiguration(project)
registerMainConfiguration(project)
AffectedModuleDetector.configure(project)
registerCustomTasks(project)
registerTestTasks(project)

project.gradle.projectsEvaluated {
AffectedModuleDetector.configure(project.gradle, project)

filterAndroidTests(project)
filterJvmTests(project)
filterCustomTasks(project)
Expand Down

0 comments on commit c67c042

Please sign in to comment.