RFC: Automatically generated BuildRequires for maven-based Java projects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Good $LOCAL_TIME_OF_DAY,

I've been working on experimental support for automatically generating
BuildRequires for maven-based Java projects, and it's now available
for testing in rawhide (and in fedora 32, for local testing).

There's no "macro support" for this yet, because it's still
work-in-progress, though when it proves useful support for it might
eventually get merged into the Java packaging macros directly.

The good new is: it should basically "just work" if your package isn't
doing anything weird, but this is Java we're talking about, so there's
at least three limitations I can think of right now (the bad news):

1. no built-in blacklist for irrelevant plugins yet (e.g. maven-release-plugin)
2. no support for different profiles yet
3. no support for plugins that add additional dependencies in their
configuration

There are workarounds for the first two limitations:

1. It's pretty easy to just disable those plugins manually in %prep
with "%pom_remove_plugin :maven-foo-plugin".
2. If you know ahead of time which submodules will get activated (e.g.
based on a previous package build), just specify those modules on the
mvn-genbr command line instead of letting mvn-genbr fail to find them.
3. just continue to specify those non-discoverable dependencies manually

Usage in .spec files should be pretty simple, and similar to how other
tools handle generated BuildRequires:

- replace all java / "mvn(foo:bar)" dependencies with "BuildRequires:
mvn-genbr",
- but keep "BuildRequires: maven-local" (this is not automatically generated).
- keep your "pom.xml" modifications in %prep, as usual (e.g. removing
unnecessary maven plugins, changing dependencies, modifying XML with
XPath queries)
- add the following section to your .spec after %prep:

    %generate_buildrequires
    mvn-genbr -t .

If you're not running the test suite (%mvn_build -f), then drop the -t
/ --with-tests flag. If the root directory of the maven project is not
the toplevel directory, specify the name of the root directory /
directories instead of "." (mvn-genbr accepts multiple arguments for
this purpose. use "mvn-genbr --help" for current list of command line
options).

If you want to check out what automatic dependencies mvn-genbr will
generate for your package, you can try it without kicking off a
package build by dnf-installing "mvn-genbr" (available fedora 32+),
and running it with the same arguments as in your .spec file in the
source directory that's generated and processed by "fedpkg prep".
Comparisons between the generated dependency lists and those that were
curated "manually" would be of interest, especially for bug reports :)

Since this is still work-in-progress (though it works for a few simple
packages I tried it with), please feel free to report your
experiences, and - more importantly - open issues when the tool either
crashes (it shouldn't, since the POM parser successfully parsed all
non-broken maven project files from all fedora packages), or when it
generates too many (not that problematic) or too few (not so good)
dependencies.

The code for the POM parser and mvn-genbr lives in this project on pagure:
https://pagure.io/ironthree/pommes

Go forth and break my code!
Fabio
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux