Bug 2129825
Summary: | maven:3.6 should work with just JRE | |||
---|---|---|---|---|
Product: | Red Hat Enterprise Linux 8 | Reporter: | Jan Lieskovsky <jlieskov> | |
Component: | maven-3.6-module | Assignee: | Mikolaj Izdebski <mizdebsk> | |
Status: | CLOSED ERRATA | QA Contact: | Martin Kyral <mkyral> | |
Severity: | high | Docs Contact: | ||
Priority: | unspecified | |||
Version: | 8.6 | CC: | igueye, jlieskov, mkoncek, mkyral, pskopek, rissingh | |
Target Milestone: | rc | Keywords: | FutureFeature, Triaged | |
Target Release: | --- | |||
Hardware: | x86_64 | |||
OS: | Linux | |||
Whiteboard: | ||||
Fixed In Version: | maven-3.6-8080020230202141236.9d367344 | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 2165591 2165593 2165595 (view as bug list) | Environment: | ||
Last Closed: | 2023-05-16 08:42:08 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: |
Description
Jan Lieskovsky
2022-09-26 11:23:40 UTC
I am not sure how much upstream maven project depends on the existence of development tools such as javac or whether the RPM requirement on java-devel is necessary. I did some experiments: $ cd <SOME MAVEN PROJECT> $ podman run --privileged --mount type=bind,source=.,target=/usr/local/src/project --rm -it fedora:rawhide # dnf install maven java-17-openjdk-headless # rpm -e java-17-openjdk-devel --nodeps # JAVA_HOME=/usr/lib/jvm/jre-17 mvn clean compile At this point, Maven runs, fetches its dependencies (including "plexus-compiler-javac") and even compiles the sources. The documentation of maven-compiler-plugin [1] at parameter named "<forceJavacCompilerUse>" implies that javac from javax.tools is optional. (`mvn install` command would fail on missing `javadoc` executable.) I believe upstream Maven *should* be able to work the same way without java-devel installed as I highly doubt it depends on .class files that are not present in JRE but only in JDK. I cannot say this with certainty, but I think we could change the RPM Requires/Suggests fields as requested. However, Mikolaj will have to confirm whether it works and whether this is actually supported. [1] https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html To add onto this: plexus-compiler-javac requires javax.tools at runtime. Since OpenJDK 9, system classes (including javax.tools) are distributed as .class files that are part of modules, not as jars. In Fedora, installing java-1.8.0-openjdk-headless installs `rt.jar` which is required by java programs to run. This does not include classes in `javax.tools`. Those are provided by tools.jar, which is provided by the package java-1.8.0-openjdk-devel. With OpenJDK 9+ (in context of Fedora: java-11-openjdk-*, java-17-openjdk-*, ...) there are no longer rt.jar / tools.jar, but instead all the .class files are installed by the -headless package. This is the reason why Maven was able to compile sources if used with java-17-openjdk-headless. With java-1.8.0-openjdk-headless (but without -devel) it shouldn't be able to. I confirmed this: # dnf install maven-openjdk8 # rpm -e --nodeps java-1.8.0-devel # JAVA_HOME=/usr/lib/jvm/jre-1.8.0 mvn -v ... Java version: 1.8.0_345, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-2.fc38.x86_64/jre ... # JAVA_HOME=/usr/lib/jvm/jre-1.8.0 mvn clean compile [INFO] Scanning for projects... [INFO] [INFO] -----------------< org.codehaus.plexus:plexus-cipher >------------------ [INFO] Building Plexus Cipher: encryption/decryption Component 2.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ plexus-cipher --- [INFO] Deleting /usr/local/src/project/target [INFO] [INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-maven) @ plexus-cipher --- [INFO] [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ plexus-cipher --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to copy filtered properties files. [INFO] skip non existing resourceDirectory /usr/local/src/project/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ plexus-cipher --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 5 source files to /usr/local/src/project/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.671 s [INFO] Finished at: 2022-09-30T09:13:14Z [INFO] ------------------------------------------------------------------------ In this case, Maven is still able to execute steps which do not invoke the compiler and fails at the `compile` step. My conclusion: Maven works without the java-*-openjdk-devel package, even though compiling sources is the primary use case. Replacing Requires for Suggests (+ possible additional changes) seems like a valid move. But I am not confirming this. @Marián Konček Thank you for your research! (In reply to Marián Konček from comment #2) > To add onto this: plexus-compiler-javac requires javax.tools at runtime. > Since OpenJDK 9, system classes (including javax.tools) are distributed as > .class files that are part of modules, not as jars. > In Fedora, installing java-1.8.0-openjdk-headless installs `rt.jar` which is > required by java programs to run. This does not include classes in > `javax.tools`. Those are provided by tools.jar, which is provided by the > package java-1.8.0-openjdk-devel. With OpenJDK 9+ (in context of Fedora: > java-11-openjdk-*, java-17-openjdk-*, ...) there are no longer rt.jar / > tools.jar, but instead all the .class files are installed by the -headless > package. This is the reason why Maven was able to compile sources if used > with java-17-openjdk-headless. With java-1.8.0-openjdk-headless (but without > -devel) it shouldn't be able to. > > I confirmed this: > # dnf install maven-openjdk8 > # rpm -e --nodeps java-1.8.0-devel > # JAVA_HOME=/usr/lib/jvm/jre-1.8.0 mvn -v > ... > Java version: 1.8.0_345, vendor: Red Hat, Inc., runtime: > /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-2.fc38.x86_64/jre > ... > # JAVA_HOME=/usr/lib/jvm/jre-1.8.0 mvn clean compile > [INFO] Scanning for projects... > [INFO] > [INFO] -----------------< org.codehaus.plexus:plexus-cipher > >------------------ > [INFO] Building Plexus Cipher: encryption/decryption Component 2.0.1-SNAPSHOT > [INFO] --------------------------------[ jar > ]--------------------------------- > [INFO] > [INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ plexus-cipher --- > [INFO] Deleting /usr/local/src/project/target > [INFO] > [INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-maven) @ > plexus-cipher --- > [INFO] > [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ > plexus-cipher --- > [INFO] Using 'UTF-8' encoding to copy filtered resources. > [INFO] Using 'UTF-8' encoding to copy filtered properties files. > [INFO] skip non existing resourceDirectory > /usr/local/src/project/src/main/resources > [INFO] > [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ > plexus-cipher --- > [INFO] Changes detected - recompiling the module! > [INFO] Compiling 5 source files to /usr/local/src/project/target/classes > [INFO] ------------------------------------------------------------- > [ERROR] COMPILATION ERROR : > [INFO] ------------------------------------------------------------- > [ERROR] No compiler is provided in this environment. Perhaps you are running > on a JRE rather than a JDK? Right. This is exactly my point. From the error (IMHO) it's clearly visible, what is the expected action to solve the problem (IOW install the java-*-devel package). This corresponds to the behavior seen in other (non-Java) tools too. For example AFAICT you can have the autoconf / automake RPM packages installed without the gcc-11-* / gcc-c++-* compilers installed at that moment, and still can run the "./configure" step on the source code. In that case it will show an error like "No compiler found", which by itself is sufficient suggestion for the user to install the necessary gcc-11-* / gcc-c++-* RPM packages to be able to perform valid "make build" step. The way the Requires are set on maven currently they are a way too strict IMHO (since maven can be used for far more actions than building something. The EAP / Wildfly "composition" of the Galleon build being more example, but there can be more - various Maven plugins not necessary compiling something). > [INFO] 1 error > [INFO] ------------------------------------------------------------- > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD FAILURE > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 0.671 s > [INFO] Finished at: 2022-09-30T09:13:14Z > [INFO] > ------------------------------------------------------------------------ > > In this case, Maven is still able to execute steps which do not invoke the > compiler and fails at the `compile` step. > > My conclusion: Maven works without the java-*-openjdk-devel package, even > though compiling sources is the primary use case. Replacing Requires for > Suggests (+ possible additional changes) seems like a valid move. But I am > not confirming this. Regarding the suggested setting of dependencies (set Requires: to java-11-openjdk-headless, and only Suggests: java-11-openjdk-devel) TBH this wasn't tested. The point was to modify the hard requirements in the way, only java-11-openjdk-headless would be installed with maven RPM. And java-11-openjdk-devel would be only suggested, when the user would perform a "dnf/microdnf" search (IOW it would be recommended to be installed, but not a strict requirement). TBH not sure, if Suggests: or Recommends: is the weak dependency to be used for this purpose (it would need to be tried/tested first). HTH Thanks again for your look / follow-up on this one JFTR: I have modified/deleted the private links in the original c#0 and made that comment public. Moreover I can also take this discussion to the fedora-devel mailing list, if you want to discuss the proposal there first. Let me know, if this is expected/desired. Regards Jan Afaik Suggests installs dependencies by default and Recommends does not. In Fedora there are also packages which do not need a compiler (they only contain .pom) and are "built" with Maven. I think taking this discussion to fedora-devel or maybe java-devel.org is a good move. Scope of the change: Replace Requires on java-devel with combination of Recommends and Requires on java-headless Right now: Requires: java-$x-openjdk-devel After change: Requires: java-$x-openjdk-headless Recommends: java-$x-openjdk-devel We'll need new gating tests to ensure that: 1) default installation of Maven pulls in java-devel and that compiler works by default 2) with weak dependencies disabled, only headless java is installed Pre-verification: Change was commited to dist-git. Tests (/Sanity/openjdk-packages) were added and check for absence of java-*-openjdk-devel packages. Tests passed. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (maven:3.6 bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2023:2899 |