GithubHelp home page GithubHelp logo

sbt-bower's Introduction

sbt-bower: SBT Bower Plugin

Simple Build Tool plugin for using bower to manage frontend dependencies.

NOTE

This library is no longer maintained, since the Webjars bower project provides a far superior method of using bower dependencies for Scala projects. Would highly recommend checking it out/converting.

Installation

First make sure you have bower installed, do this by using node.js npm. The artifacts are hosted on Sonatype, so you shouldn't need to add any repositories

Then simply place this in your project/build.sbt file

addSbtPlugin("org.mdedetrich" %% "sbt-bower" % "0.2.1")

In your build.sbt file, put

seq(bowerSettings : _*)

Now we need to simply setup our dependencies in build.sbt which follow a similar format to then bower.json format. Here is an example of such a configuration

BowerKeys.frontendDependencies ++= Seq(
  "angular" %%% "=1.2.0-rc.2",
  "angular-scenario" %%% "=1.2.0-rc.2",
  "angular-route" %%% "=1.2.0-rc.2",
  "angular-mocks" %%% "=1.2.0-rc.2",
  "angular-animate" %%% "=1.2.0-rc.2",
  "angular-cookies" %%% "=1.2.0-rc.2",
  "angular-resource" %%% "=1.2.0-rc.2",
  "angular-sanitize" %%% "=1.2.0-rc.2",
  "angular-touch" %%% "=1.2.0-rc.2",
  "requirejs" %%% "=2.1.8",
  "requirejs-text" %%% "2.0.10"
)

Note that since we use the official bower binary, the versioning will follow the exact same semantics documented on the bower page.

The last thing we need to do is to setup the bower source directories and installation directory. By default the source directory is sourceDirectory (_ / "main" / "webapp" ) which implies you have a project which uses the xbst-web-plugin. The installation directory defaults to (sourceDirectory in Bower) (_ / "js" / "lib"). These directories can be changed in build.sbt by doing the following

BowerKeys.sourceDirectory <<= sourceDirectory (_ / "main" / "assets" )
BowerKeys.installDirectory <<=  (sourceDirectory in Bower) (_ / "js" / "myStuffGoesHere")

That's it, we now have now setup the plugin!

Automatically check dependencies

We can set up SBT to automatically check our frontend dependencies when SBT starts in the exact same way it checks for our scala/java dependencies. To do this, we just modify the update task. Place the following in your build.sbt

update <<= update dependsOn (installTask dependsOn(pruneTask))

This will run the bower:prune and bower:install tasks when SBT starts which checks if you currently have your frontend dependencies installed and update them should they have changed. It will also cleanup any removed dependencies

Note that the source directory is just the directory where this plugin will execute bower, it just needs to exist and its often just the generic "assets" folder for your web application (which if you are using xbst-web-plugin happens to be sourceDirectory (_ / "main" / "webapp" ))

Notes

sbt-bower uses the PATH environment variable to locate the bower binary. If you run SBT from a shell/command prompt it should work fine (assuming [node]/npm and bower are properly set up), however if you happen to be using the IntelliJ SBT Plugin, due to this bug then you need to resort to using a proper terminal

sbt-bower's People

Contributors

mdedetrich avatar masseguillaume avatar

Stargazers

Kiwon, Seok. avatar SwhGo_oN avatar Adriano Machado avatar Dario A Lencina-Talarico avatar Jani Halinen avatar Vitaliy V. Shopov avatar Alessandro avatar Ugur Adigüzel avatar Francois Dang Ngoc avatar Rogério da Silva Yokomizo avatar Moritz Platt avatar Mike Aizatsky avatar Erik Bakker avatar Kane Rogers-Wong avatar Carlos Saltos avatar  avatar

Watchers

kenji yoshida avatar James Cloos avatar  avatar  avatar

sbt-bower's Issues

Can't find the bower executable on windows

Running on windows generates this error:

[info] Pruning frontendDependencies
java.io.IOException: Cannot run program "bower" (in directory "C:\Users\Nathan\Meta\meta\src\main\resources\gui\www"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at sbt.SimpleProcessBuilder.run(ProcessImpl.scala:388)
at sbt.AbstractProcessBuilder.run(ProcessImpl.scala:140)
at sbt.AbstractProcessBuilder$$anonfun$runBuffered$1.apply(ProcessImpl.scala:171)
at sbt.AbstractProcessBuilder$$anonfun$runBuffered$1.apply(ProcessImpl.scala:171)
at sbt.BufferedLogger.buffer(BufferedLogger.scala:25)
at sbt.AbstractProcessBuilder.runBuffered(ProcessImpl.scala:171)
at sbt.AbstractProcessBuilder.$bang(ProcessImpl.scala:168)
at SbtBowerPlugin$$anonfun$pruneTask$1.apply(SbtBowerPlugin.scala:64)
at SbtBowerPlugin$$anonfun$pruneTask$1.apply(SbtBowerPlugin.scala:60)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
at sbt.std.Transform$$anon$4.work(System.scala:64)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:244)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at sbt.SimpleProcessBuilder.run(ProcessImpl.scala:388)
at sbt.AbstractProcessBuilder.run(ProcessImpl.scala:140)
at sbt.AbstractProcessBuilder$$anonfun$runBuffered$1.apply(ProcessImpl.scala:171)
at sbt.AbstractProcessBuilder$$anonfun$runBuffered$1.apply(ProcessImpl.scala:171)
at sbt.BufferedLogger.buffer(BufferedLogger.scala:25)
at sbt.AbstractProcessBuilder.runBuffered(ProcessImpl.scala:171)
at sbt.AbstractProcessBuilder.$bang(ProcessImpl.scala:168)
at SbtBowerPlugin$$anonfun$pruneTask$1.apply(SbtBowerPlugin.scala:64)
at SbtBowerPlugin$$anonfun$pruneTask$1.apply(SbtBowerPlugin.scala:60)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
at sbt.std.Transform$$anon$4.work(System.scala:64)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:244)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
error java.io.IOException: Cannot run program "bower" (in directory "C:\Users\Nathan\Meta\meta\src\main\resources\gui\www"): CreateProcess error=2, The system cannot find the file specified

Using sbt version 13.5.

Looks like a quick and dirty fix would be to have the bower executable location be a setting key.

Cannot find 'bower'

I am getting an error when I am trying to go through the tutorial saying that sbt cannot find bower on the following line of code:

web/build.sbt:28: error: not found: value Bower
BowerKeys.installDirectory <<= (sourceDirectory in Bower) (_ / "js" / "myStuffGoesHere")

I ran 'sudo npm install bower' in my application directory before running 'sbt compile', so I am not sure why I am getting this error.

Unable to resolve

Following the doc, I have added the following to my project/plugins.sbt:

addSbtPlugin("com.mdedetrich" %% "sbt-bower" % "0.2.0-SNAPSHOT")

But here is the result:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.mdedetrich#sbt-bower;0.2.0-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      com.mdedetrich:sbt-bower:0.2.0-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)

Specifically, according to the build of the project I was expecting the following to succeed but sonatype doesn't know about the mdedetrich dir:

[warn] ==== Sonatype snapshots: tried
[warn]   http://oss.sonatype.org/content/repositories/snapshots/com/mdedetrich/sbt-bower_2.10_0.13/0.2.0-SNAPSHOT/sbt-bower-0.2.0-SNAPSHOT.pom

Thanks for your work on that, can't wait to try it!

Resolve %%% conflict with ScalaJS

%%% is also in use by ScalaJS. Even though they came later, my sense is they are going to prevail.

Any thoughts on resolving this? %^4?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.