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

Modifying resourceManaged doesn't appear to impact the plugin #1

Closed
sroebuck opened this issue Oct 2, 2011 · 2 comments
Closed

Modifying resourceManaged doesn't appear to impact the plugin #1

sroebuck opened this issue Oct 2, 2011 · 2 comments

Comments

@sroebuck
Copy link

sroebuck commented Oct 2, 2011

I'm trying to change where the css files are compiled to in my build.sbt file. For the CoffeeScriptedSbt plugin I can do this with a line like:

(targetDirectory in Coffee) <<= (crossTarget in Compile)(t => t / "webapp_managed" / "js")

This works fine.

With less-sbt I appear to have to write:

(targetDirectory in LessKeys.less) <<= (crossTarget in Compile)(t => t / "webapp_managed" / "css")

whilst this seems to change the setting, in that target-directory(for less) from the sbt prompt gives the right result, the less command nevertheless appears to compile to the same place as it did before.

On the other hand, I find configuration in sbt to be a process of trail and error so I could be doing completely the wrong thing here.

@softprops
Copy link
Owner

Hi @sroebuck. Thanks for trying out the plugin. You are almost there :)

First, a quick note on best practices.

You should be noticing a change in how newer sbt plugins are developed and how keys are exposed. The collective plugin community and (with Marks input) have decided on a new design based on best practices.

The old design used configs for namespaces which was kind of bastardizing what configs are for. So you should see less of this

myplugin:mykey

and more of

 somekey(for someTaskKey)

While I agree thats less than ideal you should start seeing a new repl syntax for task dependent keys in upcoming sbt releases.

Another part of the best practices doc is on reusing exisiting keys. There is no targetDirectory in the less plugin but there is a resourceManaged key defined by sbt but scoped to the less task. Checkout the readme for a full list of keys I use.

Keys are also used within provided scopes rather than custom scopes now. Below is want you want to use

In your build file, add

 (resourceManaged in (Compile, LessKeys.less)) <<= (crossTarget in Compile)(_ / "webapp_managed" / "css")

which should result in the following repl behavior

 > compile:resource-managed(for less)
 [info] /Users/dougtangren/Desktop/tests/lesstest/target/scala-2.9.1/webapp_managed/css
 > less
 [info] Compiling 2 less files to /Users/dougtangren/Desktop/tests/lesstest/target/scala-2.9.1/webapp_managed/css
 [success] Total time: 1 s, completed Oct 2, 2011 7:46:36 PM

Since changing the default location or where less css files are written to is probably a common question I'll add that to the readme as well.

Have fun!

@melezov
Copy link
Contributor

melezov commented Oct 3, 2011

Just wanted to thank for the explanation, and confirm that the following combo is now working perfectly:

 temporaryWarPath <<= (sourceDirectory in Compile)(_ / "webapp"),
(resourceManaged in (Compile, LessKeys.less)) <<= webappResources(_.get.head / "static" / "less")

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