gnodet opened a new pull request, #2198: URL: https://github.com/apache/maven-resolver/pull/2198
## Summary Add `aether.installer.hardLink` configuration property (default `true`) to make `DefaultInstaller` create a hard link from the build output file to its destination in the local repository, instead of copying it. This saves significant disk I/O for large JARs when building locally: instead of reading and writing the full file, the OS simply adds a new directory entry pointing to the same inode. ## Motivation This was raised as a follow-up to [apache/maven-install-plugin#468](https://github.com/apache/maven-install-plugin/pull/468#pullrequestreview-5478638729). The install plugin only assembles the `ArtifactInstallerRequest` — the right place to implement hard-link installation is here in `DefaultInstaller`, which owns the file-copy step. The feature is analogous to `FileTransporter.WriteOp.HARDLINK` which already exists for `file://` remote repositories. ## Behaviour - **Default: `aether.installer.hardLink=true`** — hard link attempted first. - **Fallback to copy** — when `Files.createLink` throws `UnsupportedOperationException` (unsupported filesystem) or `IOException` (cross-device link, `EXDEV`), the installer silently falls back to a regular file copy. The build is never broken. - **Opt out: `aether.installer.hardLink=false`** — always copy, same as the previous behaviour. ## Design notes - Property defined on `ConfigurationProperties` with full `@configurationSource` / `@configurationType` / `@configurationDefaultValue` / `@configurationRepoIdSuffix` annotations following the established pattern. - `PREFIX_INSTALLER = "aether.installer."` added alongside the existing prefix constants. - Hard links share an inode. Any tool that overwrites build output **in-place** (not via atomic rename) would silently corrupt the cached artifact. Standard Maven tooling always uses atomic rename for `target/`, so this is safe in practice. - When destination exists as a directory, the code explicitly checks and falls through to `copyWithTimestamp` (which will fail as before), preserving existing error semantics. ## Testing - `testHardLinkInstallCreatesHardLink` — verifies that install succeeds and (on same-device filesystems) produces a hard link (same inode). Gracefully skips the inode assertion on cross-device environments (common in CI containers). - `testHardLinkDisabledFallsThroughToCopy` — sets `aether.installer.hardLink=false` and verifies install still succeeds with correct content. - All 585 existing tests in `maven-resolver-impl` pass unchanged. ## Configuration To opt out globally, add to `~/.m2/settings.xml`: ```xml <!-- in Maven 4: via project properties or system property --> ``` Or pass on the command line: ``` mvn install -Daether.installer.hardLink=false ``` --- _Hermès Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
