JetBrains / sbt-ide-settings

SBT plugin for tweaking various IDE settings
Apache License 2.0
62 stars 8 forks source link

SBT 1.4.x does not seems to honor settings #10

Open fooblahblah opened 3 years ago

fooblahblah commented 3 years ago

I'm using SBT 1.4.5 with sbt-ide-settings 1.1.0 and now see the message:

[warn] there are 3 keys that are not used by any other settings/tasks:
[warn]  
[warn] * homebay / Compile / ideOutputDirectory
[warn]   +- /home/jsimpson/workspace/homebay/build.sbt:293
[warn] * homebay / Test / ideOutputDirectory
[warn]   +- /home/jsimpson/workspace/homebay/build.sbt:294
[warn] * homebay / ideExcludedDirectories
[warn]   +- /home/jsimpson/workspace/homebay/build.sbt:292

The settings I have, which haven't been changed on my end are:

ideExcludedDirectories := List(new File("node_modules"), new File("target"))
ideOutputDirectory in Compile := Some(new File("target/idea/classes"))
ideOutputDirectory in Test := Some(new File("target/idea/test-classes"))

Any ideas?

jastice commented 3 years ago

These settings are only used by IDE import, and not relevant to sbt operation by itself. Maybe the warning is new in a recent sbt version?

jtjeferreira commented 3 years ago

@fooblahblah you need to add a tag to the keys:

SettingKey[Seq[File]]("ide-excluded-directories").withRank(KeyRanks.Invisible)
ches commented 3 years ago

@jastice This is from the new key linting added in sbt 1.4.0.

Since the plugin doesn't include any tasks that use the settings—it's expected that they are unused out of the box—I think the plugin should silence the lint noise automatically. But the .withRank(KeyRanks.Invisible) trick @jtjeferreira referred to might not be best because sbt uses Invisible for "implementation details" so they may be hidden from help listings and such, possibly tab completion (?).

It's probably better to do

excludeLintKeys in Global ++= Set(idePackagePrefix, /* etc. */)

but a difficultly with that is that the excludeLintKeys key is only defined since sbt 1.4.0, whereas .withRank(KeyRanks.Invisible) has been around longer… so I'm not sure how to use excludeLintKeys in a plugin backward compatible for sbt 1.x 🤔

jastice commented 3 years ago

Thanks! I think by using the string key of the setting or by making it conditional on sbt version it can be added in a backwards-compatible way.

fooblahblah commented 3 years ago

Regardless of those warnings, I do not see different output settings being used by Idea after project import.

I did forget to mention I'm using bloop instead of sbt from Idea. Could that be related? I was using the Idea internal Scala compiler prior along with the sbt-ide-settings plugin and it would work just fine when I ran our Play app (via sbt from Idea), I'd see separate target outputs as configured with my settings in the first post. As of now I never see the target/idea/classes or target/idea/test-classes.

If I get some extra time I'll try importing as an sbt project to rule out the bloop thing.