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
Circumventing the common declaration of addPlugins #1213
Comments
We want to do this, but it's actually pretty hard to do this safely. Ideally we should have a read-only reference to the |
OK, but can we please at least have |
it's not true that sbt always supplies one. e.g. in a project build structure:
project.current should refer to the local directory of the .sbt file. However, we don't have a safe way to do that. Adding a What about a |
|
By the way, officially we're using dot notation or infix? I always write |
Unsure about "officially"... There's nothing in our internal plugin coding guidelines. :-) |
...but you're probably correct - I should use the lazy val root = (project in cwd).addPlugins(SbtWeb) ... is that what you're recommending? |
To me |
Indeed, such a shortcut would be very convenient. |
Yeah, I think there may be a way to do it, but we haven't ironed out the best mechanism. My goal is to avoid having to load settings twice, so when we figure out how to do that and a have a nicer API, it'll be there. |
Thanks Josh. In terms of timing I think we need to have something before Play 2.3-RC1 which is due at the end of April. Do you think that's achievable? I suspect that we will receive too many complaints otherwise. |
@huntc Not sure. We'll see what we can do, it depends on how invasive it is to add. |
We could re-instate Play's playJavaSettings and playScalaSettings or some other alias just for Play, but I'd prefer not to... |
Perhaps Ok... I wanna configure my project...
Right, I want the project in the current working directory
Now I want to add a plugin to it
crap...
Happens to me every time. |
By the way, we could provide this in Play: lazy val root = playScalaRootProject
def playScalaRootProject = (project in cwd).addPlugins(PlayScala) |
We decided against something like that because people might think they can call it twice. Maybe if it were called IN any case, I'm debating adding addPlugins/disablePlugins directly to the build.sbt dsl... |
OK, so I think the current thinking is we can add a hook in the SO, concretely, a ThisProject.enablePlugins(PlayScala) // Assuming we rename add -> enable
ThisProject disablePlugins (LameJoshPlugin) Because no one wants any of my plugins. The DSL grammr would then look sort of like this :
Any expression starting with { ThisProject: Project => <expr> } Then we store these functions for each .sbt file in a sequence and apply them to the appropriate projects after load/discovery of .scala + .sbt build files but before applying settings (and autoplugins). This type of transformation won't be supported in build.scala (nor does it make any sense because in build.scala you already have access to the The reasoning behind |
This looks like the implementation details of sbt leaking through into the UX. I understand that we're trying to attain binary compatibility, but perhaps the version should be 0.14 if it is getting in the way. My problem is that all settings here are w.r.t. to the current project... and then, for one group of declarations, you must use |
It's not a binary compatibility issue necessarily, but how we do loading. The set of enabled plugins is not a setting for the build, because you need its value to determine what settings are used. There's a class of these "thing which are used to determine which settings are loaded" of which
object SomeBuild extends Build {
val foo = project.<thing which helps define how settings are loaded>
} So, even if we were on version 0.14, the issue remains the same. |
is it possible to special case "enablePlugins" and "disablePlugins" so you don't need the |
Yeah, it's possible, just ugly, but Maybe that's what we need to do. |
A problem with ThisProject is that the name doesn't really communicate the difference between things that have ThisProject in front and things that don't. That is, everything in a build.sbt is already scoped to this project automatically... so why do some have ThisProject? It seems confusing to have ThisProject when everything in the file is already for this project. People could easily start to think that regular settings are not for this project. Project.current is a little bit prettier since it conveys (to me anyway) that there's a "project object instance" that I need to get a handle to. And it doesn't look like a key scope; ThisProject looks like the scope syntax, but isn't. Still, Project.current probably doesn't make much sense to people who aren't familiar with the .scala setup. If we want to communicate in the user model that some things are "outside of" settings and happen before we add the settings, then maybe some syntax that better conveys that idea, but I don't know what it would be... maybe a But do we even need to communicate that I wonder? I'm not sure it matters that much to people that we process enablePlugins before we load settings. Mostly things should just work in a way that makes sense.... |
So in future: lazy val root = (project in file(".")).addPlugins(SbtWeb) will become: enablePlugins(SbtWeb) ? |
Note: This required completely redoing the core of the "Load.scala" algorithm for grabbing Once I flush out any extraneous issues, I'll issue a pull request. |
Awesome work guys! |
BTW, |
Given the proposed AutoPlugin mechanism where plugins are required to be added, it'd be nice to have a short cut to the following common expressions in build.sbt:
For example, if the project is a single module then may be sbt's processing of build.sbt can be magical and automatically perform the above. Why else would you call
addSbtPlugin
fromplugins.sbt
if your single module project wasn't going to use it?Further to the above, and orthogonal, perhaps a short cut to the expression could be provided e.g.:
My major concern though is that all build.sbt files will have at least 3 extra lines over what they used to have. It isn't a massive concern, but if we are able to address it then I think it'll make a good UX.
The text was updated successfully, but these errors were encountered: