You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "ascheman (via GitHub)" <gi...@apache.org> on 2026/10/09 21:49:34 UTC

[PR] Skip the main artifact when its file is a directory (module source hierarchy) [maven-install-plugin]

ascheman opened a new pull request, #466:
URL: https://github.com/apache/maven-install-plugin/pull/466

   When a project uses the Maven 4 **module source hierarchy**, the JAR plugin produces one JAR per Java module and attaches them as separate artifacts, without assigning a file to the project's main artifact — its path stays the (directory) build output.
   
   With `allowIncompleteProjects=true`, `install` warned about the missing main file but still passed the directory to the installer, which failed:
   
   ```
   Failed to install artifact …:jar:…: is a folder
   ```
   
   (reported by @desruisseaux while building apache/sis.)
   
   This drops the main artifact from the install request in that case and installs the POM + the attached per-module JARs only. A new `InstallMojoTest` case asserts the directory main artifact is excluded from the request (it fails without this change).
   
   The existing "change packaging to 'pom'" warning is kept as-is for minimality; it now reads a bit oddly since the attachments install successfully — happy to reword if preferred.
   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Skip the main artifact when its file is a directory (module source hierarchy) [maven-install-plugin]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet closed pull request #466: Skip the main artifact when its file is a directory (module source hierarchy)
URL: https://github.com/apache/maven-install-plugin/pull/466


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Skip the main artifact when its file is a directory (module source hierarchy) [maven-install-plugin]

Posted by "ascheman (via GitHub)" <gi...@apache.org>.
ascheman commented on code in PR #466:
URL: https://github.com/apache/maven-install-plugin/pull/466#discussion_r4235300229


##########
src/main/java/org/apache/maven/plugins/install/InstallMojo.java:
##########
@@ -267,6 +268,11 @@ private ArtifactInstallerRequest processProject(Project project) {
                             getLog().warn("");
                             getLog().warn("Incomplete projects like this will fail in future Maven versions!");
                             getLog().warn("");
+                            // The main artifact has no file (its path is e.g. the output directory of a module
+                            // source hierarchy, where the JAR plugin attaches one JAR per Java module instead).
+                            // Install the POM and the attachments only; do not hand the directory to the installer,
+                            // which would otherwise fail with "is a folder".
+                            toInstall.remove(installable);

Review Comment:
   Addressed: replaced the misleading "will fail in future Maven versions" warning with an informational log message on the remove path — when the directory-backed main artifact is skipped, it now says the POM and attachments are installed only. Applied the same to maven-deploy-plugin#717 for consistency. Thanks for the catch!



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Skip the main artifact when its file is a directory (module source hierarchy) [maven-install-plugin]

Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #466:
URL: https://github.com/apache/maven-install-plugin/pull/466#discussion_r4235189793


##########
src/main/java/org/apache/maven/plugins/install/InstallMojo.java:
##########
@@ -267,6 +268,11 @@ private ArtifactInstallerRequest processProject(Project project) {
                             getLog().warn("");
                             getLog().warn("Incomplete projects like this will fail in future Maven versions!");
                             getLog().warn("");
+                            // The main artifact has no file (its path is e.g. the output directory of a module
+                            // source hierarchy, where the JAR plugin attaches one JAR per Java module instead).
+                            // Install the POM and the attachments only; do not hand the directory to the installer,
+                            // which would otherwise fail with "is a folder".
+                            toInstall.remove(installable);

Review Comment:
   ⚠️ **Misleading warning for module-source-hierarchy projects**
   
   After this change, for module-source-hierarchy projects the install *succeeds* (POM + attachments are installed), yet the surrounding warning still says:
   > `"Incomplete projects like this will fail in future Maven versions!"`
   
   This is now factually wrong for the case this PR targets — the install does **not** fail. The warning was written for the truly broken case (missing file + attachments but wrong packaging), not for legitimate module-source-hierarchy usage.
   
   You noted this in the PR description ("it now reads a bit oddly") — worth addressing: either split the warning so it only fires for the unresolved case, or soften the wording when the remove path is taken. Something like:
   ```java
   getLog().info("Skipping directory-backed main artifact — "
       + "installing POM and attachments only (module source hierarchy).");
   ```
   rather than emitting a doom-and-gloom warning that contradicts the successful outcome.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Skip the main artifact when its file is a directory (module source hierarchy) [maven-install-plugin]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #466:
URL: https://github.com/apache/maven-install-plugin/pull/466#discussion_r4235493849


##########
src/main/java/org/apache/maven/plugins/install/InstallMojo.java:
##########
@@ -260,13 +261,14 @@ private ArtifactInstallerRequest processProject(Project project) {
                                 "The packaging for this project did not assign a file to the build artifact");
                     } else {
                         if (allowIncompleteProjects) {
-                            getLog().warn("");
-                            getLog().warn("The packaging plugin for this project did not assign");
-                            getLog().warn(
-                                            "a main file to the project but it has attachments. Change packaging to 'pom'.");
-                            getLog().warn("");
-                            getLog().warn("Incomplete projects like this will fail in future Maven versions!");
-                            getLog().warn("");
+                            // The main artifact has no file: its path is e.g. the output directory of a module
+                            // source hierarchy, where the JAR plugin attaches one JAR per Java module instead of
+                            // assigning a single main JAR. Install the POM and the attachments only; do not hand
+                            // the directory to the installer, which would otherwise fail with "is a folder".
+                            getLog().info("The project's main artifact has no file"
+                                    + " (e.g. a module source hierarchy produces one artifact per Java module);"
+                                    + " installing the POM and the attached artifacts only.");
+                            toInstall.remove(installable);
                         } else {
                             throw new MojoException("The packaging plugin for this project did not assign "
                                     + "a main file to the project but it has attachments. Change packaging to 'pom'.");

Review Comment:
   ```suggestion
                       } else if (usesModuleSourceHierarchy(project, projectManager)) {
                           getLog().info("Module source hierarchy: no main artifact produced;"
                                   + " installing POM and per-module artifacts only.");
                           toInstall.remove(installable);
                       } else if (allowIncompleteProjects) {
                           getLog().warn("");
                           getLog().warn("The packaging plugin for this project did not assign");
                           getLog().warn(
                                           "a main file to the project but it has attachments. Change packaging to 'pom'.");
                           getLog().warn("");
                           getLog().warn("Incomplete projects like this will fail in future Maven versions!");
                           getLog().warn("");
                           toInstall.remove(installable);
                       } else {
                           throw new MojoException("The packaging plugin for this project did not assign "
                                   + "a main file to the project but it has attachments. Change packaging to 'pom'.");
   ```
   Flattens the nested `if/else` into a chain with **module source hierarchy first** (auto-detected, no flag), then `allowIncompleteProjects` (preserved for other edge cases), then error. Also adds `toInstall.remove(installable)` in the `allowIncompleteProjects` branch (the original PR only removes it in the module-hierarchy branch).
   
   Needs a helper method added to the class:
   ```java
   private static boolean usesModuleSourceHierarchy(Project project, ProjectManager projectManager) {
       return projectManager.getSourceRoots(project).stream()
               .anyMatch(sr -> sr.module().isPresent());
   }
   ```



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Skip the main artifact when its file is a directory (module source hierarchy) [maven-install-plugin]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #466:
URL: https://github.com/apache/maven-install-plugin/pull/466#issuecomment-6091384640

   Alternative implementation in #468 — auto-detects module source hierarchy via `ProjectManager.getSourceRoots()` / `SourceRoot.module()` instead of gating on `allowIncompleteProjects`. No flag needed, existing `allowIncompleteProjects` behavior preserved unchanged.
   
   _Fully automatic review from Claude Code_


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org