Scala SBT custom lib managed path - scala

Is it possible set custom "lib_managed" path in build.sbt? I would want that command update the puts jar files to the my web folder web/WEB-INF/lib. If sbt does not allows setup custom folder(google finds nothing), what i must add to the build.sbt to copy files from lib_managet folder to my web/.../lib folder?

lib_managed is only a build-local cache and it contains jars for all configurations, such as Test and Compile. It is not appropriate to list its contents and use it as a classpath. There may be duplicates or libraries that shouldn't be on the classpath of interest.

Related

Specify plugins in Build.scala

If I want to use a build.scala file in order to build my project (instead of build.sbt)
how do I specify the plugins?
I want to use the sbt-assmbly plugin. and I am aware that I can create a plugins.sb file and do a addSbtPlugin there.
But i want to put all my build logic in build.scala instead of the sbt files.
No, you can't. You can put it in project/project/Build.scala, which would let you avoid .sbt files, but probably isn't what you want.
The thing is, project directory is itself an SBT project, and SBT handles project/*.sbt files and project/project/*.scala files in it just the same as it does on the top level; but by the time it's working with project/Build.scala, it's too late to add plugins.

How to access external libraries using Play Framework?

I'm trying to use an external library contained in a .jar file with the Play Framework.
I've added the .jar file to the lib/ directory, to no avail.
I know I could add the dependency to my project/Build.scala file, but I have no idea what the group ID, artifact ID, or version numbers are. Are those found in the .jar file?
You can go to Project Structure
Under Project Setting -> Modules ->
Go to tab Dependencies , under sbt-unmanaged-jars you can edit and add your lib manually.
groupID, artifactID and version are “Maven Coordinates”. These three identifies are needed to find exact jar file in the Maven Repository. When provided, the build system (and Play! uses SBT) can automatically find, download and include the library you want to use (assuming that that library exists in the repository).
As that is a global repository, groupID should uniquely identify the project. groupID is usually the same as the main project's package, e.g. org.apache.commons. artifactID is supposed to identify a particular jar in the project, e.g. commons-io. version, quite obviously, points to the exact version of the jar.
How to use IntelliJ with Play Framework and Scala
see this short tutorial.
but you have to add all necessary jars to lib folder before call create module command idea with-sources=yes
So, again
Create a new application
Create lib folder and copy all jars
Create the IDE module
This is only one way how I can deploy it successfully

Sbt building distribution for a project

Is there an easy way to create a distribution for a SBT project, which collects all dependency jars into a single directory like lib and the main project jar file refers to all its dependencies using manifest entries? It would be nice if one could define a main class.
This answere says how to do part of what you want. Namely get the managed dependencies into lib_managed directory. Basically just add:
retrieveManaged := true
to your build.sbt file.
Alternatively you could look at a One-jar plugin https://github.com/sbt/sbt-onejar It might do a bit more than you want though.

SBT plugin: add resources to resulting jar?

I'm writing an SBT plugin. In this plugin, I need to add files to the resources directory within the resulting jar.
I don't want to change anything from the source directory (otherwise the user/developer may not understand why files appear to directory he's responsible for), but only in the generated jar.
How can I do that, is there a folder in target that correspond to the resource directory?
It seems like this is done by the "package" command, so if I can override the package command I might be able to do what I want.
Seems like I need to add stuff to resourceManaged.

Add folder to classpath for properties file Scala

I am using a java jar dependency that requires a certain property file to be on the classpath. I can't for the life of me figure out how to add this folder/file to the classpath. I am using play 2.0.
I have added the config.properties file to both the /conf directory and have tried to add it to the root of my app source folder. The file does not seem to be recognized by the dependency.
BTW: play 2.0 uses sbt to compile and run the application so maybe something there could help?
Any ideas?
You should be fine if you put the property file where your class files are. When you use SBT you probably use either:
The project root directory as source directory. In this case just put your property file into the root directory.
Or the maven layout, so your normal classes are under src/main/scala In this case put your property file under src/main/resources
Although the answer of Jens Schauder should solve your issue, you may want to try to add the file to the lib folder.
Play 2.0 won't remove files manually added in there (at least it doesn't at the time I'm writting this!) and that folder should be included into the classpath automatically.