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

Tycho 3 and Java toolchain #2216

Closed
LorenzoBettini opened this issue Apr 13, 2023 · 9 comments · Fixed by #2223
Closed

Tycho 3 and Java toolchain #2216

LorenzoBettini opened this issue Apr 13, 2023 · 9 comments · Fixed by #2223
Labels
Milestone

Comments

@LorenzoBettini
Copy link
Contributor

If we switch to Tycho 3 we must use Java 17.

If we want to use Java 11 for building and testing there are basically two options:

@cdietrich
Copy link
Contributor

cdietrich commented Apr 13, 2023

my main question about toolchains is:

  • how can they easily be setup (maybe we need a template to adjust)
  • how can i tell: run now with j11, run now with j17 .... (as i can do with setting JAVA_HOME now)

@cdietrich cdietrich added this to the Release_2.31 milestone Apr 13, 2023
@HannesWell
Copy link
Contributor

  • configure Jenkins so that, when running on Java 11, the tycho-version property is overridden on the command line

I believe that this option is too complex and would basically limit you to use only what's available in Tycho 2.7.

That's probably the better option forward.

* how can i tell: run now with j11, run now with j17 .... (as i can do with setting JAVA_HOME now)

For plain Maven project (with packaging-type jar) this magic should happen in the maven-toolchain-plugin:
https://maven.apache.org/guides/mini/guide-using-toolchains.html#using-toolchains-in-your-project

From #2210 (comment)

@HannesWell I created a dedicated issue. If, in the meantime, could you please point me to the relevant parts needed for the toolchain? I saw the XML file and it's simple, but I don't see in the SWT repository how to activate a specific toolchain. Moreover, who provides the locations for the actual JDK installations? If you have time, please comment on the other issue.

Tycho can auto-magically selects the corresponding Toolchain based on the BREE/osgi.ee requirement of a bundle, when using the tycho-compiler-plugin:useJDK configuration parameter.

Regarding the locations of the actual JVM, please see: https://github.com/actions/setup-java/#install-multiple-jdks

The setup-java action can even create a toolchains file on the fly, but I have not yet checked if that is suitable:
https://github.com/actions/setup-java/#using-maven-toolchains
But if it is, it is maybe sufficient to just specify the multiple java-version and everything else works automagically.

In Jenkins you could do something like the following. You only have to ensure that the env-variable names match the names used in the toolchain.xml

withEnv([
'JAVA_HOME_11_X86=' +tool(type:'jdk', name:'temurin-jdk11-latest'),
'JAVA_HOME_17_X86=' +tool(type:'jdk', name:'temurin-jdk17-latest')
]) {
  ... <Maven build steps>
}

@LorenzoBettini
Copy link
Contributor Author

@HannesWell but the Maven documentation mentions that you need to use a maven toolchain plugin, and I haven't found that in the SWT repository.

Please, remember that in some projects (packaging jar) the tycho-compiler-plugin is not used and the default maven-compiler-plugin is used.

@HannesWell
Copy link
Contributor

@HannesWell but the Maven documentation mentions that you need to use a maven toolchain plugin, and I haven't found that in the SWT repository.

That's probably because in the SWT repo there are not jar-typed projects.

Please, remember that in some projects (packaging jar) the tycho-compiler-plugin is not used and the default maven-compiler-plugin is used.

Then for xtext we probably need to configure both, tycho-compiler-plugin:useJDK and the maven-toolchain-plugin. I have not yet used the latter myself so cannot yet provide any more details in that regard yet.

In general it is often a good idea to only require toolchains in the CI activated in a corresponding Maven profile. This allows local builds without the need to set up toolchains on a computer. Then just the release option of the compiler is used, which is often not that bad. Using toolchains you can just be more confident.

@LorenzoBettini do you plan to provide a PR to do the migration to Tycho 3? Alternativly I can offer to work that out?

@LorenzoBettini
Copy link
Contributor Author

@HannesWell I cannot work on that right now. If you are willing to work on that I can follow.

Of course, first, you can only try on GitHub Actions, then we'll deal with Jenkins.

First, let's hear from @cdietrich : do you think we can give it a try?

@cdietrich
Copy link
Contributor

sure. give it a try.

@HannesWell
Copy link
Contributor

sure. give it a try.

Great, I have started to work on it. I'll provide a draft as soon.
If #2214 is merged before that would avoid some unrelated changes. :)

@LorenzoBettini
Copy link
Contributor Author

@HannesWell #2214 has been merged

HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 16, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/integration-test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216
Signed-off-by: Hannes Wellmann <[email protected]>
HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 16, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216
Signed-off-by: Hannes Wellmann <[email protected]>
HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 16, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216
@HannesWell
Copy link
Contributor

Created #2223 with the current state of the work, which should be quite complete besides the failures that have to be fixed.

HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 17, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216
HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 18, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216
HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 18, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216
HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 18, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216
LorenzoBettini pushed a commit that referenced this issue Apr 19, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes #2216
HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 19, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216

Co-authored-by: Lorenzo Bettini <[email protected]>
HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 19, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216

Co-authored-by: Lorenzo Bettini <[email protected]>
HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 19, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216

Signed-off-by: Hannes Wellmann <[email protected]>
HannesWell added a commit to HannesWell/eclipse.xtext that referenced this issue Apr 19, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes eclipse-xtext#2216

Co-authored-by: Lorenzo Bettini <[email protected]>
Signed-off-by: Hannes Wellmann <[email protected]>
LorenzoBettini pushed a commit that referenced this issue Apr 20, 2023
General guide for Maven toolchains:
https://maven.apache.org/guides/mini/guide-using-toolchains.html
Using the Maven-Toolchain-Plugin and its 'toolchain' goal the
maven-compiler-plugin is configured to use a JDK from the toolchain that
matches the specified release version.

Configure the Tycho-Compiler-Plugin to use the JDK in the toolchain that
matches the Bundle-RequiredExecutionEnvironment:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-compiler-plugin/compile-mojo.html#useJDK

Configure the Maven-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jdkToolchain

Configure the Tycho-Surefire-Plugin to use a specific JDK version from
the toolchain to launch a test runtime:
https://tycho.eclipseprojects.io/doc/3.0.4/tycho-surefire-plugin/test-mojo.html#useJDK

About the toolchains.xml generated by the setup-java Github action and
the exported JAVA_HOME_ environment variables:
- https://github.com/actions/setup-java/#install-multiple-jdks
- https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Modifying-Maven-Toolchains

Fixes #2216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants