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

Output of asciidoctorPdf can be pulled from cache when run on machines with different checkout directories #2794

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

erichaagdev
Copy link
Contributor

@erichaagdev erichaagdev commented Sep 1, 2023

This sets the path sensitivity to relative for the sourceDir property of the asciidoctorPdf task. Previously, the full absolute path to the source directory would be considered as an input to the task. This would cause a local build cache miss when executing the task from two different directories or a remote build cache hit given that the paths to the sources directory on CI and for local developers will undoubtedly be different.

You can recreate this with the Gradle Enterprise Build Validation Scripts using the following command:

./03-validate-local-build-caching-different-locations.sh \
  -r https://github.com/spring-projects/spring-kafka \
  -t asciidoctorPdf \
  -c d171f04ec88874db9d3385fc454a09a5a97dbacb

Looking at the task inputs comparison we can see the difference: https://ge.solutions-team.gradle.com/c/2dq5dfpctwmlc/7zthc3fpbm2m4/task-inputs?cacheability=cacheable,overlapping-outputs,validation-failure

Using the diffoscope tool we can see the only difference for the generated index.pdf is in the creation and modification dates:

image

See also: spring-projects/spring-amqp#2520

This sets the path sensitivity to relative for the sourceDir property
of the asciidoctorPdf task. Previously, the full absolute path to the
sources directory would be considered as an input to the task. This
would cause a local build cache miss when executing the task from two
different directories or a remote build cache hit given that the paths
to the sources directory on CI and for local developers will undoubtedly
be different.
@erichaagdev erichaagdev changed the title Task output of asciidoctorPdf receives a cache hit when run on machines with different checkout paths Task output of asciidoctorPdf can be pulled from cache when run on machines with different checkout directories Sep 1, 2023
@erichaagdev erichaagdev changed the title Task output of asciidoctorPdf can be pulled from cache when run on machines with different checkout directories Output of asciidoctorPdf can be pulled from cache when run on machines with different checkout directories Sep 1, 2023
@@ -497,7 +497,7 @@ asciidoctorPdf {

asciidoctorj {
sourceDir "$buildDir/asciidoc"
inputs.dir(sourceDir)
inputs.dir(sourceDir).withPathSensitivity(PathSensitivity.RELATIVE)
Copy link
Member

Choose a reason for hiding this comment

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

I guess something like build/asciidoc would work as well, but then sourceDir property of the asciidoctorj plugin might not be happy.
I'll merge after your answer.
Thanks

Copy link
Member

Choose a reason for hiding this comment

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

BTW, we are in the process of migrating our docs to Antora, so very likely this PDF generation task will go away, like we have now in Spring Integration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess something like build/asciidoc would work as well, but then sourceDir property of the asciidoctorj plugin might not be happy.

Still, the full absolute path will be considered. This is a quirk of Gradle. The default path sensitivity is absolute.

@artembilan artembilan added this to the 3.1.0-M1 milestone Sep 1, 2023
@artembilan artembilan merged commit 765efdc into spring-projects:main Sep 1, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants