[MBUILDCACHE-73] Allow arbitrary expressions as additional reconcilation properties#416
[MBUILDCACHE-73] Allow arbitrary expressions as additional reconcilation properties#416pdudits wants to merge 6 commits intoapache:masterfrom
Conversation
|
|
||
| public static void addProperty( | ||
| CompletedExecution execution, String propertyName, Object value, String baseDirPath, boolean tracked) { | ||
| CompletedExecution execution, String propertyName, Object value, Path baseDirPath, boolean tracked) { |
There was a problem hiding this comment.
This is a breaking change. Keep the old method as a delegate to the new method and deprecate it with reference to use this method
There was a problem hiding this comment.
I've done that, because technically it is true, however all usages all the method have been replaced. Who are potential users of the old method?
There was a problem hiding this comment.
I've done that, because technically it is true, however all usages all the method have been replaced. Who are potential users of the old method?
There was a problem hiding this comment.
How do you know you've replaced all usages? They are not necessarily in this repo.
There was a problem hiding this comment.
How do you know you've replaced all usages? They are not necessarily in this repo.
Hence the question. I couldn't imagine a third-party code depending on utility method that modifies internal state of Maven extension (unless it's a fork, of course in which case they are better of migrating to new method anyway). But people closer to this project may be better informed.
There was a problem hiding this comment.
Nine times out of ten you're correct. The tenth time things break. Dependencies outside a monorepo are not predictable or even sane.
src/test/projects/reconcile-expressions/.mvn/maven-build-cache-config.xml
Outdated
Show resolved
Hide resolved
src/test/projects/reconcile-expressions/src/main/java/org/apache/maven/buildcache/Test1.java
Outdated
Show resolved
Hide resolved
src/test/projects/reconcile-expressions/src/main/resources/resources.properties
Show resolved
Hide resolved
9ef4dce to
e95fc97
Compare
|
Hello, how shall we proceed here? I will rebase the PR on main, but I would like to get some feedback whether this feature is desirable and on what would be then the plans for releasing 1.3.0, are there more signification changes in the pipeline? |
elharo
left a comment
There was a problem hiding this comment.
"arbitrary" expression strikes me as potentially risky. I need to think about this more
6581eee to
54bb5c8
Compare
|
Rebased, updated tests to match new behavior of not caching without an artifact and addressed your concerns, @elharo |
54bb5c8 to
b1011b6
Compare
| - absolute paths outside of project directory could not be deterministically | ||
| relativized and not touched | ||
| */ | ||
| private static String normalizedPath(Path path, Path baseDirPath) { |
There was a problem hiding this comment.
I feel like there must be existing code for this in mavcen-shared-utils or apache commons IO. This is tricky to get right. Can we avoid reinventing the wheel here or is this very specific to hopw this extension needs to relativize?
There was a problem hiding this comment.
I don't know Maven internals and utilities enough to tell. What I know is that this reduced number of wheels from two to one in this plugin alone :)
There was a problem hiding this comment.
There's https://github.com/apache/maven-shared-utils/blob/master/src/main/java/org/apache/maven/shared/utils/PathTool.java but it's deprecated in favor of Path.relativize()
squash! [MBUILDCACHE-73] Allow arbitrary expressions as additional reconcilation properties
Co-authored-by: Erik Meuwese <Erik.Meuwese@topicus.nl>
b1011b6 to
9a8175e
Compare
| return normalizedPath; | ||
| } | ||
|
|
||
| public static Object interpolateExpression(String expression, MavenSession session, MojoExecution execution) { |
There was a problem hiding this comment.
This is only used in one package, which is not this one, so far as I can ell. Maybe move it into that package and make it non-public?
There was a problem hiding this comment.
I'm not really sure about that. None of the static methods in this class is used by more than one package. Rarely they are used by more than one class. Should it be then split to 3 parts?
createDigestedFilewould go directly toMavenProjectInputcreateAttachedArtifactsandcreateDigestedByProjectCheckSumbelongs solely toBuild- all other methods are used by
BuildCacheMajosExecutionStrategyandCacheControllerImplin main package so we could move rest of the class as non-publicUtilsover there.
What would your proposed change?
There was a problem hiding this comment.
I haven't looked at this in detail, but the goal is to avoid introducing new public API wherever possible.
There was a problem hiding this comment.
Then I will proceed like I suggested, and deprecate entire DtoUtils class, with no usages in the codebase left.
There was a problem hiding this comment.
keep in mind we can't change old code. This is only for new methods.
There was a problem hiding this comment.
Thankfully there already was CacheUtils class in main package so I just moved the new from DtoUtils over there, orphaning the old addProperty method.
5d6a2de to
8cf429c
Compare
8cf429c to
1d4c981
Compare
|
Spotless should be happy now after last push. Can you please retry that? |
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
mvn -Prun-its verify).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
The change realizes the approach I originally suggested in MBUILDCACHE-73. It is now possible to declare plugin's reconcilation property as
Along the way I unified how the string value for reconciled expression is constructed -- they were different upon saving and restoration before.
Since this relies on new model properties an initial failing test case wasn't really possible.
Fixes #268.