Skip to content

Issue #492 restore compile-only reactor module so downstream resoluti…#493

Open
yeroc wants to merge 1 commit into
apache:masterfrom
yeroc:gh-492-restore-compile-only-reactor
Open

Issue #492 restore compile-only reactor module so downstream resoluti…#493
yeroc wants to merge 1 commit into
apache:masterfrom
yeroc:gh-492-restore-compile-only-reactor

Conversation

@yeroc

@yeroc yeroc commented May 25, 2026

Copy link
Copy Markdown

Fixes #492

Description

restoreProjectArtifacts only wires up project.getArtifact() to a restored artifact when the cached file is a regular jar. For compile-only cached builds the primary cached artifact is the target/classes directory, which falls through that condition unset. In a multi-module reactor that leaves downstream modules unable to resolve the upstream as a reactor artifact on a subsequent mvn clean compile, and they fall through to remote repositories with Could not find artifact ...:jar:...-SNAPSHOT.

For the directory case this PR sets the file on the existing project artifact instead of replacing it with a RestoredArtifact. RestoredArtifact.getFile routes through restoreToDiskConsumer on every call, which would later break package-phase plugins (e.g. jar:jar) that update the file via setFile.

Added CompileOnlyReactorRestoreTest, which reuses the existing issue-393-compile-restore reactor project to exercise two consecutive compile-only invocations. The test fails on master and passes with this change.

Checklist

  • 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.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
  • Run mvn verify to make sure basic checks pass.
  • You have run the integration tests successfully (mvn -Prun-its verify).
  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004

…solution works

When a cached build did not reach the package phase the cache entry's
primary artifact is the target/classes directory rather than a jar.
restoreProjectArtifacts only set project.getArtifact() to the restored
artifact when the cached file was a regular jar, leaving directory
artifacts unbound. In a multi-module reactor that meant downstream
modules could not find the upstream's classes on the second
`mvn clean compile` invocation and fell through to remote repositories
with "Could not find artifact ...:jar:...-SNAPSHOT".

For directory artifacts, set the file on the existing project artifact
instead of replacing it with RestoredArtifact. RestoredArtifact.getFile
always re-routes through its restoreToDiskConsumer, which would later
break package-phase plugins (e.g. jar:jar) that update the artifact's
file via setFile.

Adds CompileOnlyReactorRestoreTest covering this case.
@yeroc

yeroc commented May 25, 2026

Copy link
Copy Markdown
Author

I considered renaming the existing issue-393-compile-restore reactor project to something more generic since it covers a fairly common and important case with multi-module reactor and internal dependencies that isn't covered elsewhere as far as I can tell. Thoughts on renaming that?

@yeroc

yeroc commented Jun 1, 2026

Copy link
Copy Markdown
Author

@sparsick looking at the failure for build # 2 it looked like a strange intermittent issue pulling down transitive dependencies from Maven Central. The 3rd build was cancelled. As far as I can tell the failure doesn't appear to be related to the changes I made? Thoughts?

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.

mvn clean compile twice in a multi-module reactor fails to resolve upstream module

1 participant