melix / japicmp-gradle-plugin

A Gradle plugin for JApicmp
Apache License 2.0
137 stars 30 forks source link

Add normalizedArguments as japiCmp task input instead of rule arguments #66

Closed jprinet closed 1 year ago

jprinet commented 1 year ago

Issue

the japiCmpTask is not relocatable when using rule arguments with absolute paths. Here is an example in the micronaut-build project.

The cost of this with a relocated build is 1mn23s on the micronaut-core build Screenshot 2023-08-25 at 9 34 37 AM

Here is the build scan comparison illustrating the volatile inputs Screenshot 2023-08-25 at 9 34 10 AM

Fix

This PR adds a rule constructor which allow to add a normalized version of the arguments which will be used as rule inputs. The consumer would then call this constructor with normalized are arguments, here is how in the micronaut-build:

report.addViolationTransformerWithNormalization(AcceptedApiChangesRule.class,
                                    Collections.singletonMap(AcceptedApiChangesRule.CHANGES_FILE, changesFile.getAbsolutePath()),
                                    Collections.singletonMap(AcceptedApiChangesRule.CHANGES_FILE, project.relativePath(changesFile.getAbsolutePath()))
)

Question

This PR only addresses the ViolationTransformer rule type, do all subtypes of RuleConfiguration have to be addressed the same way?

jprinet commented 1 year ago

Closing this after discussion with @melix.

The ideal solution would be to have a type to support those (StringWithPath?)