Play: bower webjars not loaded into target folder - playframework-2.4

I have a play 2.4 subproject that uses sbt-sassify. It works fine, but I want to pull a bower dependency into the project so that my scss files can make use of it. I followed the sbt-sassify instructions for this and added the following dependency to my build.sbt.
"org.webjars.bower" % "bootstrap-sass" % "3.3.6"
However, when I run the project, none of the scss from bootstrap-sass is in the target folder so that I'm able to import it into my scss. If I use a dependency to a classic webjar such as
"org.webjars" % "bootstrap" % "3.3.6"
I will be able to see the bootstrap code in target/public/main/lib.
When I run the sbt-dist command, the bower jars will show up in my universal tar ball.
Is there anything else I need to configure?

activator dist will only package your project in several jars. The contents of all assets can be found in:
target/scala_<scala_version>/<prefix>-web-assets.jar/public/lib/bootstrap-sass
However, none of this makes sense when you're only trying to import the scss files into your own scss files. As of sbt-sassify version 1.4.0+ you can include web-jarred assets into your own files (without relying on the folder structure of your application).
I'm not sure which of the bootstrap files you're trying to import, but for instance if you'd want to the root of the bootstrap code you could use
#import "lib/bootstrap-sass/assets/stylesheets/bootstrap";
P.S.
I'm the author of sbt-sassify and I've tested this with play 2.4.6 and sbt-sassify version 1.4.2. In case this does not solve things for you, can you create a repo on github exhibiting the faulty behaviour?

Related

Enable my-own AutoPlugin

How can I run my sbt-plugin from a repository after it works from a relative dependsOn(...) path?
Background
I made an AutoPlugin following mukis.de's instructions with no problems
I published said plugin to my own Maven repository (no problems or warnings)
I can use addSbtPlugin in my project/plugins.sbt (again - no problems or warnings)
BUT I can't enablePlugins(MyPlugin) in build.sbt
I receive the message
... build.sbt:5: error: not found: value MyPlugin
Links
Link to failing-version with maven repositories
Link to working-version with relative paths
This sounds like a missing import. Did you make sure to import the class in the build.sbt file?
I've now tried it on two different computers. I had an old not-a-plugin copy on my computer which didn't have any tasks / plugin / whatnot in it
I tried clean update and reload plugins commands before noticing that ~/.ivy2/cache/scala_2.10/sbt_0.13 wasn't being changed
"Works for me" on all three computers

How to setup SBT dependency for scala code that is located in same directory as Build.scala

Our project features a kind of adhoc "plugin" that reads csv files and stuffs the contents into a database.
This code is defined in /project/DataMigrate.scala
We had our own poorly implemented version of a CSV parser that isn't up to the task anymore so I tried to add this https://github.com/tototoshi/scala-csv to the libraryDependencies in /project/Build.scala but that did not make it importable from DataMigrate.scala. I also tried putting the library dependency in /project/build.sbt as I read something about "Build definition of a build definition", but that did not seem to help either.
Is it at all possible to add dependencies for code that lives in /project?
SBT is recursive, so just as you can define dependencies and settings of the actual project in [something].sbt or project/[something].scala you can define dependencies and settings of the projects project (any ad hoc plugins etc) in project/[something].sbt or project/project/[something].scala

How to create standalone jar file for elastic4s from sources?

I'm trying to create a standalone jar file from the elastic4s sources on github. I've used sbt compile as detailed on the github page, but I can't find the jar file.
How do I use sbt to create the jar file so I can import it into my projects as a dependency?
The compile task will only compile the project.
> help compile
Compiles sources.
If you want to create a jar file and use it as a dependency in your project, you have two ways of doing that.
Unmanaged dependency (not recommended)
Unmanaged dependency run +package, which will create a jar file for each supported scala version, which you can use in your projects as an unmanaged dependency. Copy the package-generated jar to lib folder in your project.
The jar files will be located in target/scala-2.11 and target/scala-2.10, depending on the Scala version you want to use it with.
Publish to Local Repository (recommended yet imperfect)
If you want to include your custom-built elastic4s, as a managed dependency, you have to run +publishLocal. This will do the same as above, but additionally it will publish the artifact to your local repository. Assuming you've built it with version := "1.2.1.1-SNAPSHOT", you can include it in your project by just adding:
libraryDependencies += "com.sksamuel.elastic4s" %% "elastic4s" % "1.2.1.1-SNAPSHOT"
What makes the approach imperfect is that once you shared the project on GitHub (or any other project sharing platform), people will have to do publishLocal themselves to be able to build your project. The dependency should therefore go to one of the official binary repositories so when a dependency is needed, it's downloaded from Internet. Consult Publishing.
What is the + character in front of the commands
The + in the commands is for cross-building, if you don't use it the command will be executed only using scalaVersion declared in the build.sbt of the project.

sbt ignoring library dependency

I have a library dependency
libraryDependencies += "mygroup" % "myartifact" % "myversion"
This is properly retrieved, and found in lib_managed. It contains some XML files (resources), and using jar tf I can see that the jar file is complete.
Ok. But—although this had always been working before—it is not ending up on my classpath any more. When I do show full-classpath, I see all libraries but this one. Consequently the program fails because it cannot read these resources. This also effects bundling the program as a standalone.
This library has no dependencies itself, nor does any other library of the project depend on it. What could cause this problem, and how to fix it? sbt version is 0.12.4.
This is a variant of this problem. Although other than in the linked question the .jar file does end up in lib_managed, it still isn't somehow "considered important" by sbt.
The solution is the same.
$ rm -r ~/.ivy2/cache/mygroup/myartifact

How to build a jar file out of github project in sbt to be used in a scala program

I am trying to use scala to access Amazon's DynamoDB and found this great package on github https://github.com/piotrga/async-dynamo
so I downloaded the code as a zip file , unzipped it and then did "sbt clean test" and getting the following error
error sbt.ResolveException: unresolved dependency: asyncdynamo#async-dynamo;1.6.0: not found
Questions : is this the correct way to generate a jar file that I can include in my Scala program or is there a better way?
thanks in advance.
EDIT:
just for the benefit of others, the SCALA SBT documentation provides lots of information regarding the build process.
Instead of generating a jar file, you can just run 'sbt publish-local' and then include the lines for the managed dependency in the other project.
Sbt/ivy will see you have the artifact that way you don't need to add the jar to the other project which is much cleaner.
Then for example if you need to update the other project you don't need to replace the jar again - just publish-local again and clean and run your other project!
You are not the only one to have problems with this it seems, see github issues page:
https://github.com/piotrga/async-dynamo/issues
The command 'sbt clean test' will run the tests sbt detects. If you want a .jar file you could use 'sbt clean package', which produces a .jar in the target/ folder.
I cloned the repo and was able to run sbt package after changing release.sbt a bit. I had to change the 'publishTo'-variable as it seemed to depend on the repository creators local environment variable, so I just commented it away.
I did not get the dependency problem, so I suppose it is correctly declared. The tests it tries to run do fail though, but sbt package compiles produces the .jar just fine.
EDIT: As Matthias Schlaipfer pointed out in the comments, the more elegant way(and much easier) would just be to add this as an depency in your build.sbt. From the readme, this is what you need to add:
resolvers += "piotrga" at
"https://github.com/piotrga/piotrga.github.com/tree/master/maven-repo"
libraryDependencies += "asyncdynamo" % "async-dynamo" % "1.6"