hboutemy commented on code in PR #11549:
URL: https://github.com/apache/maven/pull/11549#discussion_r2621892421
##########
impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultProjectManager.java:
##########
@@ -119,15 +119,53 @@ public void attachArtifact(@Nonnull Project project,
@Nonnull ProducedArtifact a
artifact.getExtension(),
null);
}
- if (!Objects.equals(project.getGroupId(), artifact.getGroupId())
- || !Objects.equals(project.getArtifactId(),
artifact.getArtifactId())
- || !Objects.equals(
- project.getVersion(),
artifact.getBaseVersion().toString())) {
- throw new IllegalArgumentException(
- "The produced artifact must have the same
groupId/artifactId/version than the project it is attached to. Expecting "
- + project.getGroupId() + ":" +
project.getArtifactId() + ":" + project.getVersion()
- + " but received " + artifact.getGroupId() + ":" +
artifact.getArtifactId() + ":"
- + artifact.getBaseVersion());
+ // Verify groupId and version, intentionally allow artifactId to
differ as a project may be multi-module.
+ String g1 = project.getGroupId();
+ String a1 = project.getArtifactId();
+ String v1 = project.getVersion();
+ String g2 = artifact.getGroupId();
+ String a2 = artifact.getArtifactId();
+ String v2 = artifact.getBaseVersion().toString();
+
+ // ArtifactId may differ only for multi-module projects (source roots
with module name)
Review Comment:
"ArtifactId may differ" => "ArtifactId from attached artifact may differ
from project artifactId"
"(source roots with module name)" => "then must match module name from
source root in modular sources)"
##########
impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultProjectManager.java:
##########
@@ -119,15 +119,53 @@ public void attachArtifact(@Nonnull Project project,
@Nonnull ProducedArtifact a
artifact.getExtension(),
null);
}
- if (!Objects.equals(project.getGroupId(), artifact.getGroupId())
- || !Objects.equals(project.getArtifactId(),
artifact.getArtifactId())
- || !Objects.equals(
- project.getVersion(),
artifact.getBaseVersion().toString())) {
- throw new IllegalArgumentException(
- "The produced artifact must have the same
groupId/artifactId/version than the project it is attached to. Expecting "
- + project.getGroupId() + ":" +
project.getArtifactId() + ":" + project.getVersion()
- + " but received " + artifact.getGroupId() + ":" +
artifact.getArtifactId() + ":"
- + artifact.getBaseVersion());
+ // Verify groupId and version, intentionally allow artifactId to
differ as a project may be multi-module.
Review Comment:
"as a project may be multi-module." => "as Maven project may be multi-module
with modular sources structure that provide module names used as artifactIds."
--
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]