Search code examples
javamavenmaven-bom

What is the correct way to release Maven parent pom/bom (with no java src) to Nexus


I'm making a standard set of libraries for myself, (common data structures, services, and other utilities) I use very regularly and end up redefining.

Since I don't need everything every time, I've set up a BOM project and other discrete modules so I can only pull in the things I need when I need them.

The problem I'm running into is with my BOM module. When I run a mvn package or mvn release related command my parent pom and bom pom fail.

[ERROR] error: source file or directory not found: /Users/paul.baker/projects/personal/paulbaker-common-libs/src/main/java
[ERROR] warning: classpath entry points to a non-existent location: /Users/paul.baker/projects/personal/paulbaker-common-libs/target/classes

The error makes sense to a degree. It's telling me it failed to find source code for these modules, but they're not intended to have java source. They're only supposed to be POM files (they've been set as such via <packaging>pom</packaging>).

It seems like I'm missing some configuration, but I can't seem to find the right flag to set.

The project structure is:

parent
- bom
- data-structures
- aws-data-structures
- aws-data-service

but here is the relevant git repository, in case there are more needed details I'm overlooking.


Solution

  • Looking at BOM for Spring Framework 5.1.4.RELEASE <packaging>pom</packaging> is all that is needed.

    Your problem comes from declaring non-standard plugins in the root pom.xml e.g. dokka-maven-plugin or maven-gpg-plugin. These plugins are inherited by bom module but don't support <packaging>pom</packaging> in their current configuration so they fail to execute. Standard Maven plugins work out of the box.

    Either you have to move these plugins outside of root pom.xml or they have to be disabled in bom module.