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

Mention val autoImport inside AutoPlugin in the docs #7479

Open
unkarjedy opened this issue Jan 22, 2024 · 4 comments
Open

Mention val autoImport inside AutoPlugin in the docs #7479

unkarjedy opened this issue Jan 22, 2024 · 4 comments

Comments

@unkarjedy
Copy link
Contributor

In AutoPlugin you can use val autoImport: Keys.type = sbtidea.Keys. (see example)
However, it's not mentioned in the documentation https://www.scala-sbt.org/1.x/docs/Plugins.html
Related: #1314

@unkarjedy
Copy link
Contributor Author

@adpi2
Copy link
Member

adpi2 commented Jan 22, 2024

It is mentioned here: https://www.scala-sbt.org/1.x/docs/Plugins.html#Controlling+the+import+with+autoImport

More specificaly:

When an auto plugin provides a stable field such as val or object named autoImport, the contents of the field are wildcard imported in set, eval, and .sbt files.

@unkarjedy
Copy link
Contributor Author

It is mentioned here:

Indeed!
I haven't noticed it.
I saw the example with object, but when I text-searched val autoImport I couldn't find any example.

I think it would be nice to have at least 1 example with val autoImport.
Examples with val and obj are quite different.
And this part of the documentation:

the contents of the field

is some undefined SBT magic.
(AFAIU with obejct it analyses declared fields and with val it just uses the value)

@eed3si9n
Copy link
Member

As the name auto import suggests, it injects the following statement:

import x.y.SomePlugin.autoImport.*

From Scala or sbt's point of view if the term autoImport is a val or object doesn't really affect the behavior. We'd be happy to make a note of this in the doc to clarify this.

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

No branches or pull requests

3 participants