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

major (behind the scenes) updates/hacks/workarounds to get relocatable build-cache working #132

Closed
wants to merge 12 commits into from

Conversation

aSemy
Copy link
Contributor

@aSemy aSemy commented Jan 5, 2024

  • refactor Dokkatoo Configurations to share Module output directories and Module included files. This is monumentally hacky and requires several absurd workarounds, but sod it, Gradle is severely borked and they don't seem to be fixing it any time soon :(
  • Deprecate DokkatooPrepareModuleDescriptorTask
  • remove DokkaModuleDescriptionKxs - saving the Module descriptor to JSON broke relocatable build cache because it contained absolute file paths.
  • update to Gradle 8.5
  • refactor some of the internal Gradle Dependency/Task/Names helper classes to be smaller/focused/better named
  • use new Gradle Configuration.isCanBeDeclared util, split up configurations into declarable/resolvable/consumable
  • Notably I haven't added any relocatable build cache tests because I really can't be arsed

This should in theory fix #66 and #67, but this is such a massive hack I'm not sure if I should go ahead...

Related issues

These are the Gradle issues that prevent sensible sharing of files between subprojects:

Comment on lines +142 to +149
attributes {
attributeProvider(
// provide the full task path of the task that generates this module
// ugly hack workaround for https://github.com/gradle/gradle/issues/13590
DokkatooModuleGenerateTaskPathAttribute,
dokkatooTasks.generateModule.map { objects.named(it.path) }
)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This the start of the ugly hack. Share the path of the task that generates the module via an Attribute.

This file path will later be used by the aggregating task so that Gradle can correctly determine the task dependencies.

Comment on lines +70 to +73
// ugly hack, workaround for https://github.com/gradle/gradle/issues/13590
dependsOn(providers.provider {
[email protected] { it.moduleGenerateTaskPath }
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here's the end result of the ugly hack. The task paths of the module-generation tasks are extracted from the incoming Artifact Attributes and passed in as a dependency here.

@aSemy
Copy link
Contributor Author

aSemy commented Jan 5, 2024

hey @martinbonnin, I've had a breakthrough with solving relocatable build caching of Dokka tasks - would you mind taking a look? It's such a hack I don't think I want to merge it in! But at least it's so wild it should make for good entertainment.

- refactor Dokkatoo Configurations to share Module output directories and Module included files. This is monumentally hacky and requires several absurd workarounds, but sod it, Gradle is severely borked and they don't seem to be fixing it any time soon :(
- Deprecate DokkatooPrepareModuleDescriptorTask
- remove DokkaModuleDescriptionKxs - saving the Module descriptor to JSON broke relocatable build cache because it contained absolute file paths.
- update to Gradle 8.5
- refactor some of the internal Gradle Dependency/Task/Names helper classes to be smaller/focused/better named
- use new Gradle `Configuration.isCanBeDeclared` util, split up configurations into declarable/resolvable/consumable
- Notably I haven't added any relocatable build cache tests because I really can't be arsed
@aSemy aSemy force-pushed the feat/relocatable-build-cache branch from c103423 to 272cf5e Compare January 6, 2024 01:26
@martinbonnin
Copy link
Contributor

Gave it a quick look, I think #66 is not valid anymore? I couldn't find a dokka_parameters.json anywhere in my build using 2.0.0.

module_descriptor is still there but might be easier removing the path from there (there aren't that many)

# Conflicts:
#	modules/dokkatoo-plugin/src/testFunctional/kotlin/MultiModuleFunctionalTest.kt
# Conflicts:
#	.idea/fileColors.xml
#	modules/dokkatoo-plugin/src/main/kotlin/DokkatooBasePlugin.kt
#	modules/dokkatoo-plugin/src/main/kotlin/internal/gradleUtils.kt
#	modules/dokkatoo-plugin/src/main/kotlin/tasks/DokkatooGenerateTask.kt
@aSemy aSemy mentioned this pull request Feb 5, 2024
@aSemy
Copy link
Contributor Author

aSemy commented Feb 5, 2024

Superseded by #155

@aSemy aSemy closed this Feb 5, 2024
@aSemy aSemy deleted the feat/relocatable-build-cache branch February 12, 2024 09:29
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

Successfully merging this pull request may close these issues.

DokkatooGenerateTask.dokkaParametersJson contains absolute paths, making the task non-relocatable
2 participants