gnodet commented on code in PR #13403:
URL: https://github.com/apache/maven/pull/13403#discussion_r4241723984
##########
impl/maven-core/src/main/java/org/apache/maven/ReactorReader.java:
##########
@@ -463,12 +468,43 @@ private Stream<Artifact> getProjectArtifacts(MavenProject
project) {
// pom artifact
Stream.of(new ProjectArtifact(project)),
// main project artifact if not a pom
- "pom".equals(project.getPackaging()) ? Stream.empty()
: Stream.of(project.getArtifact())),
+ !producesMainArtifact(project) ? Stream.empty() :
Stream.of(project.getArtifact())),
// attached artifacts
project.getAttachedArtifacts().stream());
return artifacts.map(RepositoryUtils::toArtifact);
}
+ /**
+ * Determines whether the project produces a main artifact.
+ * Package-private for testing.
+ */
+ boolean producesMainArtifact(MavenProject project) {
+ if ("pom".equals(project.getPackaging())) {
+ return false;
+ }
+ try {
+ if (session != null && session.getSession() != null) {
+ if (session.getSession() instanceof InternalMavenSession ims) {
+ Project p = ims.getProject(project);
+ if (p != null) {
+ return p.producesMainArtifact();
+ }
+ }
+ Packaging pkg =
session.getSession().requirePackaging(project.getPackaging());
+ if (pkg != null && !pkg.producesMainArtifact()) {
Review Comment:
💡 **Nit:** `pkg != null` is dead code — `requirePackaging()` is `@Nonnull`
and throws `IllegalArgumentException` or `LookupException` on unknown packaging
(already caught above). This guard can never be false.
```suggestion
if (!pkg.producesMainArtifact()) {
```
--
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]