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

Js2pGenerationTask does not configure input path as relative #960

Open
sergeykad opened this issue Jun 25, 2024 · 7 comments
Open

Js2pGenerationTask does not configure input path as relative #960

sergeykad opened this issue Jun 25, 2024 · 7 comments

Comments

@sergeykad
Copy link

sergeykad commented Jun 25, 2024

Js2pGenerationTask is configured as @CacheableTask, but does not configure PathSensitivity as RELATIVE.
As a result, while using distributed Gradle build cache with CI machine (e.g. Jenkins), cached results from CI cannot be reused on a local build due to the different absolute paths of the input files.

For example:

  • Jankins path: /home/jenkins/workspace/my-module/build/resources/main/json_schema
  • Local path: /home/me/best-project/my-module/build/resources/main/json_schema

Since absolute paths are not identical and the task does not use relative paths this scenario results in a cache miss. Reusing cache entries created by CI server is very desirable since it greatly speeds up local builds.

image

@eirnym
Copy link
Collaborator

eirnym commented Jun 28, 2024

Thank you for an issue.

I never met this case before and I'm glad to know that gradle can be parallelized on Jenkins on different VMs.

@eirnym
Copy link
Collaborator

eirnym commented Jun 28, 2024

I'd like to have an integration test for that. Is it possible to do this on GitHub? Should it be a separate repo? Would you like to implement it?

@eirnym
Copy link
Collaborator

eirnym commented Jun 28, 2024

Also I don't know which version you're using.

In plugin version 6.0.0, configuration has this annotation already.

In unreleased implementation, [PluginConfigJs2pIO.source](https://github.com/jsonschema2dataclass/js2d-gradle/blob/84923ed6c1fdc55bf646ba4ab39c468e42454164/plugin-gradle/common/src/main/kotlin/org/jsonschema2dataclass/ext/Js2pExtension.kt#L45-L47C18 currently have annotation PathSensitive(PathSensitivity.RELATIVE) and I unpack files only when I pass actual file names to the processor. I'd like to know where I do it wrong.

@sergeykad
Copy link
Author

sergeykad commented Jun 30, 2024

We use v6.0.0 of the plugin.

I checked the code too and was surprised to see the PathSensitive(PathSensitivity.RELATIVE) as you mentioned. If it is not part of version 6.0.0 you probably already fixed the problem.

Gradle cannot be parallelized on Jenkins on different VMs. What I meant is that build results written to a remote build cache on Jenkins can be reused in a local build. This requires identical task inputs, and the path is one of them.

You can see here a description of how to test it manually, but I don't know how to write a test for it.

@eirnym
Copy link
Collaborator

eirnym commented Jul 2, 2024

Do you know other plugins which uses input files and which cache can actually be used locally and remotely.

N.B. I probably won't be looking into gradle source code as it's not so readable as I'd like to.

@sergeykad
Copy link
Author

You can check the spotbugs-gradle-plugin for example.
I know that it works correctly.

@eirnym
Copy link
Collaborator

eirnym commented Jul 4, 2024

Thank you, it will be a great help

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

2 participants