Skip to content
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

[deploy] Checking Maven Central rules fails for submodules not producing jar archives #1031

Closed
mikemybytes opened this issue Nov 7, 2022 · 5 comments
Assignees
Labels
bug Something isn't working released Issue has been released
Milestone

Comments

@mikemybytes
Copy link
Contributor

The current implementation of the AbstractMavenDeployer#checkMavenCentralRules seems not to be prepared for a multi-module Maven project containing modules that don't produce jar archives. For example, verification fails on a submodule with <packaging>pom</packaging> with a following message:

[nexus2] submodule-with-pom-packaging-0.0.1-sources.jar is missing
(...)
[ERROR] Failed to execute goal org.jreleaser:jreleaser-maven-plugin:1.3.1:full-release (default-cli) on project multi-module-project: Execution default-cli of goal org.jreleaser:jreleaser-maven-plugin:1.3.1:full-release failed: Rules for publishing to Maven Central were not met
(...)
Caused by: org.jreleaser.model.JReleaserException: Rules for publishing to Maven Central were not met
    at org.jreleaser.sdk.commons.AbstractMavenDeployer.collectDeployables (AbstractMavenDeployer.java:116)
    at org.jreleaser.sdk.nexus2.Nexus2MavenDeployer.deploy (Nexus2MavenDeployer.java:54)
    at org.jreleaser.engine.deploy.maven.ProjectMavenDeployer.deploy (ProjectMavenDeployer.java:55)
    at org.jreleaser.engine.deploy.maven.MavenDeployers.deploy (MavenDeployers.java:124)
    at org.jreleaser.engine.deploy.maven.MavenDeployers.deploy (MavenDeployers.java:111)

An example project structure causing such issues could be observed here.

Probably, the Deployable class could be extended with a packaging type info, that could be then used to decide whether or not to expect sources and Javadoc jar archives.

@mikemybytes mikemybytes added the bug Something isn't working label Nov 7, 2022
@aalmiray
Copy link
Member

aalmiray commented Nov 7, 2022

Oof, absolutely. Staged artifacts with <packaging>pom</packaging> (such as BOMs and parent poms) will cause rules to fail.

@aalmiray aalmiray added this to the v1.4.0 milestone Nov 7, 2022
@aalmiray aalmiray changed the title Checking Maven Central rules fails for submodules not producing jar archives [deploy] Checking Maven Central rules fails for submodules not producing jar archives Nov 7, 2022
@aalmiray
Copy link
Member

aalmiray commented Nov 7, 2022

Deployable could add a packaging property containing the value of <packaging>. This means parsing XML will be a must. Recall that <packaging> may not be present, in which case its default value is jar.

Simple XML parsing should be performed otherwise we'd have to resolve parent poms that may also be staged and that would complicate matters a lot.

@mikemybytes
Copy link
Contributor Author

What about a good-old javax.xml? A simple XPath query like this should do the trick:

// warning: just a POC
try {
    Document document = DocumentBuilderFactory.newInstance()
                       .newDocumentBuilder()
                       .parse(new File(path));
    String query = "/project/packaging";
    String packaging = (String) XPathFactory.newInstance()
                   .newXPath()
                   .compile(query)
                   .evaluate(document, XPathConstants.STRING);
     // value or an empty string (default packaging)
} catch (ParserConfigurationException | IOException | SAXException | XPathExpressionException e) {
    throw new RuntimeException(e); // TODO: do something meaningful instead
}

I'll be happy to pick this up unless you're very into XML parsing 😉

@aalmiray
Copy link
Member

aalmiray commented Nov 7, 2022

Thank you @mikemybytes, we welcome contributions! 😄

@aalmiray
Copy link
Member

@aalmiray aalmiray added the released Issue has been released label Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released Issue has been released
Projects
None yet
Development

No branches or pull requests

2 participants