Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in a Gradle Property to enable the full execution of the the plugin, without interfering with typical Gradle Builds. #2

Open
handstandsam opened this issue Apr 22, 2024 · 1 comment

Comments

@handstandsam
Copy link
Collaborator

handstandsam commented Apr 22, 2024

When developing invert with org.gradle.configureondemand=true, the :invert task would run on all subprojects as one would expect. In order to do this, all projects are marked as dependencies requiring a full configuration of all the projects.

In order to avoid this in standard development, we should add a flag to only do this when a report needs to be generated.

./gradlew :invert -Pinvert.enabled=true or something like this.

handstandsam referenced this issue in msfjarvis/compose-lobsters Jun 10, 2024
@handstandsam
Copy link
Collaborator Author

In a recent conversation, it sounds like this can be accomplished without subprojects if the correct inputs/outputs are specified, and Gradle will wire it up.

Here is where the code is in invert now:

rootProject.afterEvaluate { rootProject ->
val subprojectsToRegisterOn = rootProject.subprojects
.filter { shouldRegisterOnSubproject(it, extension) }
val rootInvertTask = rootProject.tasks.register(
InvertTask.TASK_NAME,
InvertTask::class.java
) { reportTask ->
reportTask.setParams(
project = rootProject,
subprojectInvertReportDirs = subprojectsToRegisterOn.map {
File(
it.layout.buildDirectory.get().asFile,
InvertFileUtils.REPORTS_SLASH_INVERT_PATH
).absolutePath
}
)
reportTask.dependsOn(metadataTask)
}
subprojectsToRegisterOn.forEach { subproject ->
// Without evaluationDependsOn, subproject won't be configured to access the dependency graph.
rootProject.evaluationDependsOn(subproject.path)
registerOnSubproject(subproject, rootInvertTask, invertCleanTask, extension)
}
}

This is bad because:

  1. It uses afterEvaluate
  2. It uses .subprojects
  3. All of this makes it "work", but requires unnecessary configurationo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant