VirtusLab / scala-cli

Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code (and more!)
https://scala-cli.virtuslab.org
Apache License 2.0
551 stars 129 forks source link

Toolkit to support compiler plugins #3134

Open soronpo opened 2 months ago

soronpo commented 2 months ago

Is your feature request related to a problem? Please describe. My library is dependent on a compiler plugin. I would like to define a toolkit to house both library and compiler plugin dependencies to simplify the user experience. It's a great general feature that enables library authors that depend on compile plugins to define tiny toolkits to house both definitions.

Describe the solution you'd like The toolkit feature currently does not support compiler plugins. It would be great if we can have it. Hopefully within the next minor release of official Scala 3.6.0

Describe alternatives you've considered Automatic mechanism for libraries to declare dependency on compiler plugins and have those automatically enabled.

Additional context Currently when publishing the toolkit I get:

Skipping unused scalacOptions: -Xplugin
Setting -Xplugin is currently not supported.
Gedochao commented 2 months ago

Hopefully within the next minor release of official Scala 3.6.0

No promises. If you care about delivering this in a timely manner, external contribution would be welcome.

Additionally, this is a rather large feature, as it'd introduce compiler plugin flags via a toolkit dependency... which would potentially affect the whole tooling ecosystem. When we have a PoC (which I don't think we'd have the resources to work on in the coming months on the maintenance team's side), we can discuss whether this would require going through SIP or not (I personally think it might need to).

soronpo commented 2 months ago

No promises. If you care about delivering this in a timely manner, external contribution would be welcome.

That's perfectly valid. I'll try to help out.

we can discuss whether this would require going through SIP or not (I personally think it might need to).

Under --power it does not, IMO. To have it out of the box without --power it does.

Gedochao commented 2 months ago

Under --power it does not, IMO. To have it out of the box without --power it does.

This would mean a separate flag for enabling compiler plugins with custom toolkits would be necessary until it goes through SIP.

soronpo commented 2 months ago

Under --power it does not, IMO. To have it out of the box without --power it does.

This would mean a separate flag for enabling compiler plugins with custom toolkits would be necessary until it goes through SIP.

I do not think so. SIP46 defined the default scala behavior for everything without --power. Everything under --power is outside the scope of the SIP and language control, meaning that it can change as VirtusLabs wishes and without being considered a regression from a Scala perspective. So as long as --power is required for toolkits to also enable compiler plugins, this is not a change that requires a SIP.

Gedochao commented 2 months ago

That's true, but I'd still rather have it behind an experimental opt-in flag, rather than have everyone get those by just enabling --power mode (which some users may have enabled implicitly via global configuration or an environment variable).

Having this behind a flag would also make users get the experimental warning.