Maven JAR Plugin
  1. Maven JAR Plugin
  2. MJAR-62

Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Manifest.mf does not reflect the version of the compiler that built the jar, but defaults to the version that maven runs under: Build-Jdk: $

      {java.version}

      .
      I believe this makes users uncertain of which compiler was actually used to build the classes.

      1. example-app.zip
        4 kB
        Peter Janssen

        Activity

        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        Agree in case of forked compilation.
        But currently it's impossible for the jar plugin to know if the javac was forked with using an other JAVA_HOME.
        http://docs.codehaus.org/display/MAVEN/Toolchains will probably help.

        Show
        Olivier Lamy (*$^¨%`£) added a comment - Agree in case of forked compilation. But currently it's impossible for the jar plugin to know if the javac was forked with using an other JAVA_HOME. http://docs.codehaus.org/display/MAVEN/Toolchains will probably help.
        Hide
        Frederic added a comment -

        Is it possible for the jar plugin to support the toolchain features?
        The manifest information (Build-Jdk) would then be correct.

        Show
        Frederic added a comment - Is it possible for the jar plugin to support the toolchain features? The manifest information (Build-Jdk) would then be correct.
        Hide
        Michael Osipov added a comment -

        Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.

        Show
        Michael Osipov added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.
        Hide
        Peter Janssen added a comment -

        I agree with Stefan that this is not expected behaviour. I supplied an example project (requiring a JDK17 profile in the settings.xml). Can we reconsider the close?

        Show
        Peter Janssen added a comment - I agree with Stefan that this is not expected behaviour. I supplied an example project (requiring a JDK17 profile in the settings.xml). Can we reconsider the close?
        Hide
        Michael Osipov added a comment -

        Reopening per request.

        Show
        Michael Osipov added a comment - Reopening per request.
        Hide
        Nathan Revo added a comment -

        I just spent 3 days trying to work around this problem. Lots of frustration involved, and I want to know why Build-Jdk is defined inside maven-archiver.

        Also, why doesn't toolchains expose useful properties by default. Version, home and architecture seem important to me.

        Our solution is to create a custom plugin that will call the javac binary with the -version argument and extract the version. This value will be set as a maven property, which should be usable inside the pom.

        Show
        Nathan Revo added a comment - I just spent 3 days trying to work around this problem. Lots of frustration involved, and I want to know why Build-Jdk is defined inside maven-archiver. Also, why doesn't toolchains expose useful properties by default. Version, home and architecture seem important to me. Our solution is to create a custom plugin that will call the javac binary with the -version argument and extract the version. This value will be set as a maven property, which should be usable inside the pom.
        Hide
        Michael Osipov added a comment -

        Nathan, do you think you can provide some valueable patch because toolchains support has been improved lately?

        Show
        Michael Osipov added a comment - Nathan, do you think you can provide some valueable patch because toolchains support has been improved lately?
        Hide
        Nathan Revo added a comment -

        Michael OsipovI will look into creating a patch. What maven version were you referring to in your comment? Also, it felt like my custom plugin would turn into a messy patch as I was calling the "javac" command directly and parsing the output.

        Here are some questions I have that should be addressed before a meaningful patch can be created:

        • How are these options handled for for compiling code and/or making archives (jar files). What is the precedence?
        • - runtime jdk. assuming it is a JDK and not just a JRE use javac/jar binaries from here?
        • - toolchains.xml, is it present, is it configured properly, use javac/jar binaries from here?
        • - compiler executable, do I use the value from the maven compiler plugin, do I provide one in the archiver plugin?
        • - java.home environment variable, is this where javac or jar are executed from?
        • which plugin will this be added to? archiver, compiler, jar?
        Show
        Nathan Revo added a comment - Michael Osipov I will look into creating a patch. What maven version were you referring to in your comment? Also, it felt like my custom plugin would turn into a messy patch as I was calling the "javac" command directly and parsing the output. Here are some questions I have that should be addressed before a meaningful patch can be created: How are these options handled for for compiling code and/or making archives (jar files). What is the precedence? - runtime jdk. assuming it is a JDK and not just a JRE use javac/jar binaries from here? - toolchains.xml, is it present, is it configured properly, use javac/jar binaries from here? - compiler executable, do I use the value from the maven compiler plugin, do I provide one in the archiver plugin? - java.home environment variable, is this where javac or jar are executed from? which plugin will this be added to? archiver, compiler, jar?
        Hide
        Michael Osipov added a comment -

        Maven version 3.3.1 has improved toolchains support. I have a look at your questions later.

        Show
        Michael Osipov added a comment - Maven version 3.3.1 has improved toolchains support. I have a look at your questions later.

          People

          • Assignee:
            Unassigned
            Reporter:
            Stefan Magnus Landrø
          • Votes:
            6 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:

              Development