From 3072d823f18fbd97eeba22b214132c7ab4574481 Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Mon, 15 Dec 2025 12:13:42 +0100 Subject: [PATCH 1/2] Documentation fixes: "module" (in Maven sense) should be "subproject" (#11548) Opportunistically tune the formatting of `JavaPathType`. --- .../src/main/java/org/apache/maven/api/JavaPathType.java | 6 +++--- .../src/main/java/org/apache/maven/api/package-info.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/JavaPathType.java b/api/maven-api-core/src/main/java/org/apache/maven/api/JavaPathType.java index 58812db8b2bb..7730c1968155 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/JavaPathType.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/JavaPathType.java @@ -281,7 +281,7 @@ final String[] format(String moduleName, Iterable paths) { */ @Override public String toString() { - return "PathType[" + id() + "]"; + return "PathType[" + id() + ']'; } /** @@ -325,7 +325,7 @@ public JavaPathType rawType() { */ @Override public String id() { - return JavaPathType.this.name() + ":" + moduleName; + return JavaPathType.this.name() + ':' + moduleName; } /** @@ -405,7 +405,7 @@ public boolean equals(Object obj) { @Nonnull @Override public String toString() { - return "PathType[" + id() + "]"; + return "PathType[" + id() + ']'; } } } diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/package-info.java index 7fd2d60b9591..35f25fda6e25 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/package-info.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/package-info.java @@ -119,9 +119,9 @@ * *

Project aggregation allows building several projects together. This is only * for projects that are built, hence available on the file system. One project, - * called the aggregator project lists one or more modules + * called the aggregator project lists one or more sub-projects * which are relative pointers on the file system to other projects. This is done using - * the {@code /project/modules/module} elements of the POM in the aggregator project. + * the {@code /project/subprojects/subproject} elements of the POM in the aggregator project. * Note that the aggregator project is required to have a {@code pom} packaging.

* *

Project inheritance defines a parent-child relationship between projects. From d3b92c1b10cae2bbc00f2f8ba4b13cc42af6c8ac Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Mon, 15 Dec 2025 12:20:38 +0100 Subject: [PATCH 2/2] Use hard links of artifact files in project local repository instead of copying the files (#11550) If the hard link cannot be created, fallback on a copy as before. --- .../java/org/apache/maven/ReactorReader.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/impl/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/impl/maven-core/src/main/java/org/apache/maven/ReactorReader.java index fdca07ee8024..db4882e38696 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/ReactorReader.java +++ b/impl/maven-core/src/main/java/org/apache/maven/ReactorReader.java @@ -453,15 +453,29 @@ private void installIntoProjectLocalRepository(Artifact artifact) { Path target = getArtifactPath( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), classifier, extension); try { - LOGGER.info("Copying {} to project local repository", artifact); - Files.createDirectories(target.getParent()); - Files.copy( - artifact.getPath(), - target, - StandardCopyOption.REPLACE_EXISTING, - StandardCopyOption.COPY_ATTRIBUTES); + // Log nothing as creating links should be very fast. + Path source = artifact.getPath(); + if (!(Files.isRegularFile(target) && Files.isSameFile(source, target))) { + Files.createDirectories(target.getParent()); + try { + Files.deleteIfExists(target); + Files.createLink(target, source); + } catch (UnsupportedOperationException | IOException suppressed) { + LOGGER.info("Copying {} to project local repository.", artifact); + try { + Files.copy( + source, + target, + StandardCopyOption.REPLACE_EXISTING, + StandardCopyOption.COPY_ATTRIBUTES); + } catch (IOException e) { + e.addSuppressed(suppressed); + throw e; + } + } + } } catch (IOException e) { - LOGGER.error("Error while copying artifact to project local repository", e); + LOGGER.error("Error while copying artifact " + artifact + " to project local repository.", e); } } @@ -481,9 +495,11 @@ private Path getArtifactPath( .resolve(artifactId) .resolve(version) .resolve(artifactId - + "-" + version + + '-' + + version + (classifier != null && !classifier.isEmpty() ? "-" + classifier : "") - + "." + extension); + + '.' + + extension); } private Path getProjectLocalRepo() {