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

Switch from Meson to Maven #74

Merged
merged 1 commit into from
Apr 12, 2024
Merged

Switch from Meson to Maven #74

merged 1 commit into from
Apr 12, 2024

Conversation

bgilbert
Copy link
Member

Maven is commonly used for Java packages; Meson is not. Also, Meson's Java support is incomplete and we've had to carry workarounds for adding entries to the JAR manifest.

Historically the built artifact has been called openslide.jar. We're already renaming it to openslide-java-$version.jar in CI, and Maven prefers to include the version number in the JAR filename. For clarity and consistency, use Maven's defaults with a sensible artifactId, building the artifact as openslide-java-$version.jar.

Allow Maven to add its usual additional metadata to the JAR, including a couple MANIFEST.MF properties and a complete copy of pom.xml.

Document selecting the correct JDK version at build time, if needed. Maven does not necessarily run on the latest, or default, JDK on the system (e.g. Fedora pins it to an older LTS), so it may be necessary to explicitly set JAVA_HOME.

We don't learn that our JDK is too old until we try to compile with it. The Maven toolchains mechanism could prevent this, but toolchains are not autodiscovered: they must be explicitly configured by the environment, which often does not do this. (In GitHub Actions, actions/setup-java does set up a toolchains file, but Fedora and Ubuntu do not.) If we declared a toolchain dependency, we would require the user to set up a toolchains file before building; it's easier to not do this, and fail at build time if Java is too old.

Maven prints warnings unless pom.xml hardcodes version numbers for every plugin mentioned there. If version numbers are specified, Maven fetches and runs exactly those plugin versions, with no way to smoothly use the latest available version. Maven calls these version pins a "good practice", but really they're an antipattern that encourages continued reliance on old versions of build tooling, making the ecosystem more brittle. Mitigate as best we can: hardcode plugin versions to avoid the warning, then enable monthly Dependabot version updates so we don't retain pins to stale versions.

Closes: #68

Maven is commonly used for Java packages; Meson is not.  Also, Meson's
Java support is incomplete and we've had to carry workarounds for adding
entries to the JAR manifest.

Historically the built artifact has been called openslide.jar.  We're
already renaming it to openslide-java-$version.jar in CI, and Maven
prefers to include the version number in the JAR filename.  For clarity
and consistency, use Maven's defaults with a sensible artifactId, building
the artifact as openslide-java-$version.jar.

Allow Maven to add its usual additional metadata to the JAR, including a
couple MANIFEST.MF properties and a complete copy of pom.xml.

Document selecting the correct JDK version at build time, if needed.
Maven does not necessarily run on the latest, or default, JDK on the
system (e.g. Fedora pins it to an older LTS), so it may be necessary to
explicitly set JAVA_HOME.

We don't learn that our JDK is too old until we try to compile with it.
The Maven toolchains mechanism could prevent this, but toolchains are not
autodiscovered: they must be explicitly configured by the environment,
which often does not do this.  (In GitHub Actions, actions/setup-java does
set up a toolchains file, but Fedora and Ubuntu do not.)  If we declared a
toolchain dependency, we would require the user to set up a toolchains
file before building; it's easier to not do this, and fail at build time if
Java is too old.

Maven prints warnings unless pom.xml hardcodes version numbers for every
plugin mentioned there.  If version numbers are specified, Maven fetches
and runs exactly those plugin versions, with no way to smoothly use the
latest available version.  Maven calls these version pins a "good
practice", but really they're an antipattern that encourages continued
reliance on old versions of build tooling, making the ecosystem more
brittle.  Mitigate as best we can: hardcode plugin versions to avoid the
warning, then enable monthly Dependabot version updates so we don't retain
pins to stale versions.

Closes: openslide#68
Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
@openslide-bot
Copy link

DCO signed off ✔️

All commits have been signed off. You have certified to the terms of the Developer Certificate of Origin, version 1.1. In particular, you certify that this contribution has not been developed using information obtained under a non-disclosure agreement or other license terms that forbid you from contributing it under the GNU Lesser General Public License, version 2.1.

@bgilbert bgilbert merged commit ec7a0b9 into openslide:main Apr 12, 2024
5 checks passed
@bgilbert bgilbert deleted the maven branch April 12, 2024 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Switch build system to Maven
2 participants