Repository navigation
Reuse Maven results across Muzzle modules #12801
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,11 +103,8 @@ class MuzzlePlugin : Plugin<Project> { | |
|
|
||
| val validationTasks = MuzzleValidationTasks(project.providers) { | ||
| val startTime = System.currentTimeMillis() | ||
| val system = MuzzleMavenRepoUtils.newRepositorySystem() | ||
| val session = MuzzleMavenRepoUtils.newRepositorySystemSession(system) | ||
| val taskPlanner = MuzzleTaskPlanner.from(system, session) | ||
| val directives = project.extensions.getByType<MuzzleExtension>().directives | ||
| val checks = taskPlanner.plan(directives).map { plan -> | ||
| val checks = sharedTaskPlanner(project).plan(directives).map { plan -> | ||
| val check = registerMuzzleTask(plan.directive, plan.artifact, project, muzzleBootstrap, muzzleTooling) | ||
| project.logger.info("configured ${plan.directive}") | ||
| check | ||
|
|
@@ -142,6 +139,24 @@ class MuzzlePlugin : Plugin<Project> { | |
| } | ||
| } | ||
|
|
||
| private fun sharedTaskPlanner(project: Project): MuzzleTaskPlanner { | ||
| val properties = project.rootProject.extensions.extraProperties | ||
| val key = "datadogMuzzleTaskPlanners" | ||
| if (!properties.has(key)) { | ||
| properties.set(key, mutableMapOf<List<List<Triple<String, String, String>>>, MuzzleTaskPlanner>()) | ||
| } | ||
| @Suppress("UNCHECKED_CAST") | ||
| val planners = properties.get(key) as MutableMap<List<List<Triple<String, String, String>>>, MuzzleTaskPlanner> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: This is a long type. Maybe using a kotlin type alias or a concrete value class for the key could help. Also that's the issue with extra properties it's not typed. Also, I think using the map directly here could burn us. I tend to think that making the whole thing a service offering some method. E.g. a registrar that return a planer. Or even higher level method returning a |
||
| // Repository IDs can be reused for different URLs, so keep their local metadata separate. | ||
| val repositories = project.extensions.getByType<MuzzleExtension>().directives | ||
| .map { it.additionalRepositories.toList() }.distinct() | ||
| return planners.getOrPut(repositories) { | ||
| val system = MuzzleMavenRepoUtils.newRepositorySystem() | ||
| val session = MuzzleMavenRepoUtils.newRepositorySystemSession(system) | ||
| MuzzleTaskPlanner.from(system, session) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| /** | ||
| * Registers a new muzzle task for the given directive and artifact. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: I'd avoid the extra properties here. It's not typed, and the access is not coordinated, it happens via
hasProperty/setPropertywhich looks like configuring another project.Maybe a service could better fit? I'm unsure at this stage.