jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
https://eclipse.dev/jetty
Other
3.86k stars 1.91k forks source link

Jetty maven plugin is not Maven toolchain aware #8867

Open deepakab03 opened 2 years ago

deepakab03 commented 2 years ago

Jetty version(s) jetty-maven-plugin: all versions but checking the latest 9.x version: 9.4.49.v20220914 and latest 11.0.12 versions

Java version/vendor (use: java -version) any, for e.g. 11.x or 17.x OS type/version Windows 11

Description When Maven toolchains are used, the jetty-maven plugin does not use the JDK specified there but uses the JDK which is used to build maven

How to reproduce?

  1. Create a toolchain.xml that specified multiple JDK versions. For e.g:
    <?xml version="1.0" encoding="UTF-8"?>
    <toolchains>
    <!-- JDK toolchains -->
    <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.17</version>
      <vendor>oracle</vendor>
    </provides>
    <configuration>
      <jdkHome>${JDK17_HOME}</jdkHome>
    </configuration>
    </toolchain>
    <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.11</version>
      <vendor>oracle</vendor>
    </provides>
    <configuration>
      <jdkHome>${JDK11_HOME}</jdkHome>
    </configuration>
    </toolchain>
    </toolchains>

2.. Stick the toolchain.xml into your ~/.m2 folder.

  1. In any jetty-maven supported project, add the toolchain plugin entry specifying a JDK version - say 17 in this example - in your build plugins section In you maven pom.xml:
    <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-toolchains-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <goals>
              <goal>toolchain</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <toolchains>
            <jdk>
              <version>17</version>
              <vendor>oracle</vendor>
            </jdk>
          </toolchains>
        </configuration>
      </plugin>
     </plugins>
    </build>
  2. Add any common jetty maven plugin to run the application to your pom.xml
  3. Run a maven build using a different JDK like JDK 11 (assign JAVA_HOME to this JDK, add JDK/bin folder this to the windows path)
  4. The jetty maven plugin will use JDK 11 thought the JDK 17 toolchain was specified and activated - the correct JDK 17 version will be used by the maven-compiler-plugin, surefire-plugin etc.
olamy commented 2 years ago

not sure which goal you would like to use with toolchain? jetty:run is embedded so it can not use toolchain.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 4 days ago

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.