How to add scalax.io as dependency in SBT? - sbt

I want to use scalax.io._ to manipulate file operations with SBT.
When I ran it, I got the error message showing scalax is not found.
>sbt run
import scalax.io._
[error] ^
[error] iotest.scala:49: not found: object scalax
How to find the library dependency for this particular one?
A more general question, how to obtain the library dependency information for any library?
For example, if I need use actor in scala, I need specify a library dependency. How to find the library dependency?

"the library dependency information for any library" is part of the library's documentation and the author(s) is supposed to publish the info for different project management tools, sbt including. After all, what would be the purpose of developing a library that's hard to use?
Use http://search.maven.org/ to search for a library, and when you search for scala-io you'll get a list of available scala-io libraries.
Since I've never worked with the library I copied the ScalaIOExample example from Scala IO Documentation to have a working example. It needs the scalax.io and scalax.file packages that are distributed as scala-io-file artifact. Searching for the artifact leads to Artifact Details For com.github.scala-incubator.io:scala-io-file_2.10:0.4.2 with information on how to use it with Scala SBT in Dependency Information section.
With this, I created the following build.sbt in a sbt project:
scalaVersion := "2.10.3"
libraryDependencies += "com.github.scala-incubator.io" %% "scala-io-file" % "0.4.2"
It will add scala-io-file_2.10-0.4.2.jar to classpath and executing run in the project gives the following results:
$ sbt run
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/stackoverflow/sbt-scala-io/project
[info] Set current project to sbt-scala-io (in build file:/Users/jacek/sandbox/stackoverflow/sbt-scala-io/)
[info] Running ScalaIOExample
Not interrupting system thread Thread[Keep-Alive-Timer,8,system]
Not interrupting system thread Thread[Keep-Alive-SocketCleaner,8,system]
[success] Total time: 5 s, completed Dec 31, 2013 11:16:42 PM

Related

How can I build a fat jar to build my Chisel code with sbt-assembly?

I would like to build a fat JAR that can build my Chisel code. I have built these previously using Maven assembly:
https://github.com/hutch31/ChiselCodeGenerator
But I would like to get this working with chisel 3.5 and sbt-assembly, which I have done this branch:
https://github.com/hutch31/ChiselCodeGenerator/tree/chisel3.5
Per the docs I simply add the dependency and go, but it's unable to resolve the dependency when I do so:
not found: /home/guy/.ivy2/localcom.eed3si9n/sbt-assembly/scala_2.13/sbt_1.0/1.2.0/ivys/ivy.xml
not found: https://repo1.maven.org/maven2/com/eed3si9n/sbt-assembly_2.13_1.0/1.2.0/sbt-assembly-1.2.0.pom
(ssExtractDependencies) sbt.librarymanagement.ResolveException: Error downloading com.eed3si9n:sbt-assembly;sbtVersion=1.0;scalaVersion=2.13:1.2.0

OPAL-How to build code in Docker in local machine (faced compile error)?

I access code in Docker($docker pull mreif/fse2016:evaluation), the code could be compiled and run without errors in remote server. While i download it to local machine, i suffered some errors in compiling(using: sbt compile):
[error] (*:update) sbt.ResolveException: unresolved dependency: de.opal-project#abstract-interpretation-framework_2.11;0.9.0-SNAPSHOT: not
[What i have done] I added follow lines into "build.sbt":
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
[error] evaluation/src/main/scala/org/opalj/evaluation/EntryPointAndCallEdgeCountAnalysis.scala:90: not found:
[What i have done] I added follow lines into "build.sbt":
libraryDependencies += "de.opal-project" % "fixpoint-computations-framework-analyses_2.11" % "0.9.0- SNAPSHOT"
3.[error] /src/main/scala/org/opalj/evaluation/EntryPointAndCallEdgeCountAnalysis.scala:130: not found: value LibraryEntryPointsAnalysis
I have checked the related code, LibraryEntryPointsAnalysis has been actually imported but doesn't work.
Could you please help me to confirm is there any operations i missed for compile the source code?
Thank you very much!
Jiang
The reason why it is not working is a version mismatch of the OPAL framework. The reason why it doesn't find the "LibraryEntryPointAnalysis" is, that it has been renamed.
You have to options:
Use the version of OPAL that is used in the Docker container
make a check out of OPAL at from version tag "ArtifactEvaluationFSE2016"
copy OPAl from the container like you did with the evaluation project
Adapt the Evaluation Project to the new API
the LibraryEntryPointsAnalysis is now called EntryPointAnalysis
there are probably other breaking changes that you have to fix
If you want to go with option one you have to build OPAL on your own because the eval version is not published on maven.

sbt-proguard issue with Java 1.8

I'm trying to get smaller scalar executable jar file with sbt-proguard.
I added project/plugin.sbt these two lines of code:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-proguard" % "0.2.2")
The first one is to get uberjar file, and I could get uberjar with sbt assembly that works fine.
Then, I executed sbt proguard:proguard to get this error message.
[error] Error: Can't read [/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar] (Can't process class [apple/applescript/AppleScriptEngine.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)))
java.lang.RuntimeException: Proguard failed with exit code [1]
at scala.sys.package$.error(package.scala:27)
...
at java.lang.Thread.run(Thread.java:745)
[error] (proguard:proguard) Proguard failed with exit code [1]
From the hint from this post: ProGuard says Unsupported class version number [52.0] (maximum 51.0, Java 1.7) with sbt-proguard,
I switched to both Java 1.7 and Java 1.6 with export JAVA_HOME=/usr/libexec/java_home -v '1.6*' command to run proguard to get the slim-lined jar file, but this doesn't run.
Invalid or corrupt jarfile target/scala-2.11/proguard/myproject_2.11-1.0.jar
What might be wrong? These are the lines that are added to build.sbt.
proguardSettings
ProguardKeys.options in Proguard ++= Seq("-dontnote", "-dontwarn", "-ignorewarnings")
ProguardKeys.options in Proguard += ProguardOptions.keepMain("core.HelloWorld")
I believe this is documented in the pro guard docs.
Running your application with java -classpath <jarpath> --class classname <program-arguments> should work.
This happens because pro guard by default removes all MANIFEST files from the jar hence the java runtime cannot find the jar class entries. Another way to do this would be to keep the MANIFEST.md file and run it using the java -jar option but I have never tried that.
Define a recent Proguard version that supports Java 1.8
ProguardKeys.proguardVersion in Proguard := "5.3.3"
Also a couple of useful ones if you run out of mem are
javaOptions in (Proguard, ProguardKeys.proguard) := Seq("-Xmx2G")
javaOptions in (Proguard, ProguardKeys.proguard) += "-Xss1G"

Specifying a relative source directory

I have just recently forked an outdated SBT project (which you can find here https://github.com/mdedetrich/sbt-bower) that was last working with an outdated version of SBT 0.11.0. I am trying to get the sbt plugin to work with SBT versions 0.12.3 and 0.13.0, however I am getting an issue on this line
https://github.com/mdedetrich/sbt-bower/blob/master/src/main/scala/SbtBowerPlugin.scala#L37
When I run sbt compile, I get the following error
[error] /Users/mdedetrich/github/sbt-bower/src/main/scala/SbtBowerPlugin.scala:37: value / is not a member of java.io.File
[error] sourceDirectory in Bower <<= (sourceDirectory).apply (_ / "main" / "webapp" )
Does anyone know what is causing this issue?
Thanks to Mark Harrah, this is actually due to this https://groups.google.com/forum/#!topic/simple-build-tool/0k1No2kfvm8/discussion
I had to remove the import Path._ in the SbtBowerPlugin.scala file and it now compiles fine!

Maven build(with Flexmojos) for multi module project throwing an error

I am trying to setup a Flex/Java multi module project in Eclipse. Using Maven to run the build and generate the war file. The details of the versions I am using are as follows:
Flexmojos : 3.5.0
Flex framework/compiler : 4.5.1.21328
Target player : 10.2.0
And the playerglobal dependency in my pom file uses classifier as 10.2 with version 4.5.1.21328
Now when I run the build using 'mvn install', I get the following error:
[ERROR] Failed to execute goal
org.sonatype.flexmojos:flexmojos-maven-plugin:3.5.0:compile-swf
(default-compile-swf) on project client: TargetPlayer and
playerglobal dependency version doesn't match! Target player: 10.2.0,
player global: 10.2 -> [Help 1]
Any ideas why this might be happening?
I tried just playing around changing those version numbers, but still couldn't make it work for Flex 4.5.1. Please let me know how to go about this (and if you need more information). Thanks.
Regards
Basith
Have you tried simply referencing "10.2" instead of "10.2.0"? I think there was only one Flash player deployed with a 3-segment version number.

Resources