I have a Maven project with Java sources that generates one JAR file and that JAR file has a classifier (more on why in a separate section below). As described by others in this bug, this causes an error:

Failed to execute goal org.apache.maven.plugins:maven-install-plugin:3.1.1:install (default-install) on project <project_name>: NoFileAssignedException:
The packaging plugin for this project did not assign a main file to the project but it has attachments. Change packaging to 'pom'. -> [Help 1]

A comment on this bug led me to the <allowIncompleteProjects> configuration, an "escape hatch" that is considered to "resolve" this bug, but the explanation for this tag makes me concerned that this is not "the right way":

By default, such projects are forbidden and Mojo will fail to process them. ... In the majority of cases, what user really wants here is a project with "pom" packaging and some classified artifact attached (typical example is some assembly being packaged and attached with classifier).

It sure sounds like I really need <packaging>pom</packaging> instead of <packaging>jar</packaging>. So I tried that. Understandably, I had to jump through some extra hoops to configure executions for resources, compiler, and surefire plugins. However, using pom appears to completely the disable javadoc and source plugins: I cannot generate a sources JAR or a javadoc JAR and I cannot even generate a javadoc report in <reporting> with mvn site. The Javadoc JAR attempt, at least, gives me some feedback, though I do not understand it:

Not executing Javadoc as the project is not a Java classpath-capable package

But the site report just appears to work and then does nothing (no output or content generated):

[INFO] configuring report plugin org.apache.maven.plugins:maven-javadoc-plugin:3.6.0
[INFO] 1 report configured for maven-javadoc-plugin:3.6.0: javadoc-no-fork [INFO] Rendering site with default locale English (en)

Those two lines are identical to the two lines on a separate jar project whose Javadoc works correctly. That project, however, has additional output below that, which is missing from this project's output:

[INFO] configuring report plugin org.apache.maven.plugins:maven-javadoc-plugin:3.6.0
[INFO] 1 report configured for maven-javadoc-plugin:3.6.0: javadoc-no-fork
[INFO] Rendering site with default locale English (en)
...
[INFO] Generating "Javadoc" report --- maven-javadoc-plugin:3.6.0:javadoc-no-fork
[INFO] Configuration changed, re-generating javadoc.
[INFO]
Loading source files for package io.oddsource.java.maven.profile...
...

It appears that the creators of the Javadoc and Source plugins have intentionally crippled these plugins for pom projects and my only option is jar with <allowIncompleteProjects>, but maybe I'm doing something wrong. Is there a better way?

As of publishing this, the current commit hash for my project is f53ab7a8. I link specifically to that commit because that's the current pom version of the pom.xml that won't build Javadoc or Source JARs, and I'm probably going to switch back to jar just to get it to work for now.

A Note on Why the Classifier

This project includes C++ JNI code that gets compiled into a shared library and bundled in the JAR, but that makes the JAR platform-dependent. So I'm adding a platform-identifying classifier to the JAR file, and I'll compile and release this from multiple machines to have multiple JARs with different platform classifiers. I also plan on eventually creating a JAR with classifier uber (or similar) that contains multiple platforms in one JAR.

0

There are 0 best solutions below