Skip to content

[MBUILDCACHE-73] Allow arbitrary expressions as additional reconcilation properties#416

Open
pdudits wants to merge 6 commits intoapache:masterfrom
pdudits:mbuildcache-73
Open

[MBUILDCACHE-73] Allow arbitrary expressions as additional reconcilation properties#416
pdudits wants to merge 6 commits intoapache:masterfrom
pdudits:mbuildcache-73

Conversation

@pdudits
Copy link

@pdudits pdudits commented Dec 6, 2025

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (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

<plugin goal="deploy" artifactId="maven-deploy-plugin" groupId="org.apache.maven.plugins">
    <reconciles>
        <reconcile propertyName="project.version" expression="${project.version}"/>
     </reconciles>
</plugin>

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.


public static void addProperty(
CompletedExecution execution, String propertyName, Object value, String baseDirPath, boolean tracked) {
CompletedExecution execution, String propertyName, Object value, Path baseDirPath, boolean tracked) {
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Author

Choose a reason for hiding this comment

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

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?

Copy link

Choose a reason for hiding this comment

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

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?

https://www.hyrumslaw.com/ 🙈

Copy link
Contributor

Choose a reason for hiding this comment

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

How do you know you've replaced all usages? They are not necessarily in this repo.

Copy link
Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nine times out of ten you're correct. The tenth time things break. Dependencies outside a monorepo are not predictable or even sane.

@pdudits
Copy link
Author

pdudits commented Feb 26, 2026

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?

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

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

"arbitrary" expression strikes me as potentially risky. I need to think about this more

@pdudits
Copy link
Author

pdudits commented Feb 26, 2026

Rebased, updated tests to match new behavior of not caching without an artifact and addressed your concerns, @elharo

- absolute paths outside of project directory could not be deterministically
relativized and not touched
*/
private static String normalizedPath(Path path, Path baseDirPath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Author

Choose a reason for hiding this comment

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

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 :)

Copy link
Author

Choose a reason for hiding this comment

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

pdudits and others added 2 commits February 26, 2026 14:49
squash! [MBUILDCACHE-73] Allow arbitrary expressions as additional reconcilation properties
Co-authored-by: Erik Meuwese <Erik.Meuwese@topicus.nl>
return normalizedPath;
}

public static Object interpolateExpression(String expression, MavenSession session, MojoExecution execution) {
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Author

Choose a reason for hiding this comment

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

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?

  • createDigestedFile would go directly to MavenProjectInput
  • createAttachedArtifacts and createDigestedByProjectCheckSum belongs solely to Build
  • all other methods are used by BuildCacheMajosExecutionStrategy and CacheControllerImpl in main package so we could move rest of the class as non-public Utils over there.

What would your proposed change?

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't looked at this in detail, but the goal is to avoid introducing new public API wherever possible.

Copy link
Author

Choose a reason for hiding this comment

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

Then I will proceed like I suggested, and deprecate entire DtoUtils class, with no usages in the codebase left.

Copy link
Contributor

Choose a reason for hiding this comment

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

keep in mind we can't change old code. This is only for new methods.

Copy link
Author

Choose a reason for hiding this comment

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

Thankfully there already was CacheUtils class in main package so I just moved the new from DtoUtils over there, orphaning the old addProperty method.

@pdudits
Copy link
Author

pdudits commented Mar 3, 2026

Spotless should be happy now after last push. Can you please retry that?

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.

[MBUILDCACHE-73] Add project version as additional property for reconcilation

4 participants