question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maven Toolchains Support

See original GitHub issue

Description: This is related to #44, however, while that issue in particular asks for multiple JDKs to be installed with a single setup-java invocation, I would like the general setup-java invocation to provide a Maven Toolchains declaration for the selected JDK(s).

This requires putting a toolchains.xml file with the proper definitions into the $HOME/.m2 location of the current user, i.e. the one running Maven.

Implementation of #44 would require changes to this, i.e. all additional JDKs would have to be correctly exposed in the toolchains declaration as well.

Justification: This would allow using setup-java with less overhead in projects that have Maven toolchain requirements configured and also allow Gradle to pick up JDK locations automatically starting with 7.4. This was something discussed in #44 as well and is to be implemented in gradle/gradle#14903 with a different solution.

Are you willing to submit a PR? There’s a pull request: #282

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:15
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
brcristacommented, Jun 29, 2022

I see thanks for the explanation and for suggesting the feature. I’m happy to leave this issue open to see if it attracts more attention, but wanted to make sure you weren’t blocked.

1reaction
Okeanoscommented, Jun 19, 2022

To set context, I’m not very familiar with Maven. That said, would it be possible today to handle Maven configuration in a separate step or action? If not, is there some sort of output we can add to setup-java to make that possible?

That depends a little – the toolchains.xml declaration works independently from a particular Maven installation and can also be used by Gradle to streamline detection of available JDKs.

To generate a useful and valid toolchains declaration for a particular JDK the following information is necessary:

  • JDK version (major version only, e.g. 1.6, 8, 16, 17)
  • JDK location (/path/to/jdk)

Optionally, some additional useful information needs to be made available – in particular important for setup-java because it offers choices with side-effects:

  • JDK vendor
  • some sort of stable unique ID to identify this particular toolchain

The toolchains.xml exists only once and can be extended to contain any number of known JDKs and allow detection/usage by Maven and Gradle. So multiple setup-java (or matrix?) invocations should be consumable and generate a full toolchains declaration. Any other tooling just builds on top of this and makes using setup-java easier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guide to Using Toolchains - Apache Maven
The Maven Toolchains provide a way for plugins to discover what JDK (or other tools) are to be used during the build, without...
Read more >
Apache Maven Toolchains Plugin – Introduction
The Toolchains Plugins allows to share configuration across plugins. For example to make sure the plugins like compiler, surefire, javadoc, ...
Read more >
Apache Maven Toolchains Plugin – JDK Toolchain
Maven Toolchains Plugin can match against a single version or any version ... tokens will be accepted, but only exact matches are supported....
Read more >
Apache Maven Toolchains Plugin – toolchains:help
Display help information on maven-toolchains-plugin. Call mvn toolchains:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.
Read more >
Apache Maven Toolchains Plugin – Plugin Documentation
Display help information on maven-toolchains-plugin. Call mvn toolchains:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found