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 · 2 comments

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.

@handstandsam
Copy link
Collaborator Author

As more work continues, we are prioritizing functionality over Gradle performance. Because of this, this flag is more important for people that want to install invert directly into their apps.

The approach we use for Invert in open source and Square both use an Gradle --init-script to accomplish this. This is actually a great way that we can share configurations for Invert like Kotlin Projects vs Java vs Android vs Server (etc) to have a different set of Collectors.

Going forward this is something that should be added.

I'm proposing a invert { enabled true } flag in the configuration DSL.

This would:

  • Allow us to do this in --init-scripts without having to pass in additional gradle flags.
  • Allow teams that choose to install Invert directly to add their own gradle flag to manipulate this value in the configuration.

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