How to add GeoSlick library in my Playframework scala Application - postgresql

How to add GeoSlick library in my Playframework scala Application. I need to use postgres database postGIS functions in my model. Is it possible to add as jar file? How to convert this project as jar file?

For many SBT projects (which GeoSlick obviously is, because it has the typical SBT files like build.sbt) the following procedure gets you an jar you can import in your project.
Clone the GIT repository with git clone https://github.com/ahinz/GeoSlick
Move into the directory and run sbt. This will download all dependencies defined in the project definitions.
If everything was downloaded correctly, type into the sbt shell package and enter.
This last step will compile a SNAPSHOT-jar file and puts it into the directory target/scala-2.10/
I did this for the project you named and it worked fine, producing a file *geoslick_2.10-0.1.0-SNAPSHOT.jar*.

Related

how to keep jar dependancy while checking in code

I have a scala project built with dependancy on a locally built jar file (java code). Once I need to check in my scala code into a different environment for building and deployment, what's the best way to keep my jar file in the dependancy?
I know that if I use the sbt dependancy from online modules, I don't need to worry, it will download the version and build, but what if I want to use my own jar file for this purpose?
This is in OSX, and code will be checked into linux machines, I am using intellij and sbt to manage my scala project. I also used intellij to build my external java lib into jar file and added dependancy of this specific path.
I hope there should be some generic solution, but I am new in JAVA and SBT
I got it figured out. Add the jar files under the lib directory right under the project will solve the problem. SBT will pick it up automatically and you can certainly check in the jar files like source code.

How to find or add build.sbt file to existing Eclipse project?

I need the ability to parse XML files in Scala for a regression modelling project of mine. It seems that there is no longer a scala.xml package ready form the get-go so we need it externally. Solution seems to be the project scala.xml from GitHub: https://github.com/scala/scala-xml
Thing is, in order for me to get the JAR file to Eclipse it seems I need to use sbt. I have sbt installed but the regression modelling project was originally made in Eclipse by File -> New -> Scala Project.
Last time I used sbt was when I tried to get ScalaFX to work in Eclipse. I then understood why they changed the name from Simple Build Tools to Scala Build Tools. It was pure hell to get the JAR file (which I did not get by using sbt).
The only way to get the library scala.xml in Scala version 2.12 is via sbt. So now the situation is that I need to make modifications to sbt.build file which doesn't (?) exist in the Eclipse project as the project wasn't made using sbt. How do I do this?
Answering to my own question for anyone having this same problem:
You can make a Git project into a JAR file really easily. What you need is git commands and sbt installed. Here's what you do
i) Open up any directory. Preferably make a new directory with descriptive name.
ii) Go to the Git project you want, click the green box "Clone or download" and copy the url.
iii) Open console, go to the directory you want the project and type git clone _ where _ is the url of the project.
iv) Once the project is cloned open it with console.
v) Type sbt and wait until sbt sets everything up.
vi) Depending on the Scala version you want to use you can do it now after compiling.
vii) Type compile and wait for the sbt to compile.
viii) Once compiling is done type package and you have the JAR file in the projects target directory. After compiling path is shown in the console.

Copy file from sbt plugin to project folder

I'm writing an sbt plugin to help with deployment. It depends on sbt-native-packager. Principally it adds a deploy task. However, I also need it to copy a bash script run-class.sh into the /bin folder of the package.
How do I copy a file from the sbt plugin to my project? Presently my only idea is to add the file to src/main/resources/run-class.sh in the plugin and generate a file using sbt. Then I can supply a Universal mapping to put the file in the sbt-native-packager package.
Is there an easier way to get a file from the plugin into my sbt project?
You are on the right track with Generating files, specifically Generate resources. You can keep your original file either as a resource or String, but important thing is that the files are generated into resourceManaged in Compile, which is under target. This folder is typically skipped from version control.

scala sbt cache x eclipse build path

I'm added a dependence to my build.sbt (casbah). I did a sbt update, I did check my ~/.ivy2/cache directory and all jars are there. Do I have to add this ~/.ivy/cache directory to my Build Path and add the casbah as external Jar to my project? If no, probably no because I did try it, what should I do to be able to use this jar in my scala project?
EDIT
I found this instructions that helped me, but still a hack
Establish a simple project (general/project) named "IvyCache"
located at your ".ivy2/cache" folder just for library reference
purposes.
Establish a Scala project located at your "project" folder.
Add the following libraries to the Scala project by means of "Add
JARs" to the "Java Build Path":
3.a) All jars from "/IvyCashe/org.scala-tools.sbt" filterred by
"*2.9.1-0.11.2" or any other Scala/SBT version numbers.
3.b) A single sbinary_*.jar from "/IvyCache/org.scala-tools.sbinary".
3.c) A single test-interface*.jar from "/IvyCache/org.scala-
tools.testing".
Now your build files should compile within Eclipse.
The easiest way to manage this is to use the eclipse plugin for sbt. Then you can just say sbt eclipse on the command line any time you change the dependencies in build.sbt, and the Eclipse files will be automatically updated for you.
Doing it this way means that you will never have to manually configure your Eclipse build path. After all, sbt already knows how to construct the build path, so there's no reason you would have to do it manually.

How do I specify external java source files using SBT?

For example suppose my main Scala project is:
c:\code\mainproject
There is some other java code I need in a separate project
c:\code\secondproject
How can a specify this in the lite version of the configuration file? I have tried
unmanagedClasspath += "C:/code/secondproject"
However it does not even run
If the projects are separate, you should publish the second project locally, add that local repository to the first project (or, more generally, to SBT configuration), and then add the project as a normal dependency.