Repository navigation
Skip the main artifact when its file is a directory (module source hierarchy) #466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -249,6 +249,7 @@ private ArtifactInstallerRequest processProject(Project project) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ProjectManager projectManager = getProjectManager(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Collection<ProducedArtifact> installables = projectManager.getAllArtifacts(project); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Collection<ProducedArtifact> attachedArtifacts = projectManager.getAttachedArtifacts(project); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| List<ProducedArtifact> toInstall = new ArrayList<>(installables); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getArtifactManager().setPath(project.getPomArtifact(), project.getPomPath()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -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'."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
262
to
274
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Flattens the nested Needs a helper method added to the class: private static boolean usesModuleSourceHierarchy(Project project, ProjectManager projectManager) {
return projectManager.getSourceRoots(project).stream()
.anyMatch(sr -> sr.module().isPresent());
} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -279,7 +281,7 @@ private ArtifactInstallerRequest processProject(Project project) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ArtifactInstallerRequest.build(session, installables); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ArtifactInstallerRequest.build(session, toInstall); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private boolean isValidPath(Artifact a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, for module-source-hierarchy projects the install succeeds (POM + attachments are installed), yet the surrounding warning still says:
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:
rather than emitting a doom-and-gloom warning that contradicts the successful outcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!