Squeryl - "CustomTypesMode is not a member of package org.squeryl.customtypes"? - scala

I've built Squeryl framework with SBT and am trying to use it with Scala 2.8 and NetBeans 6.9. I've defined an entity model as it is desctibed in Squeryl intro, but the IDE and compiler complain that "CustomTypesMode is not a member of package org.squeryl.customtypes". What might the reason be?

You don't have to build Squeryl, you can download the jar from http://github.com/max-l/Squeryl/downloads.
If you use sbt, you can drop the jar in the lib directory (I just tried and was able to compile the example using import org.squeryl.customtypes.CustomTypesMode._.)
Alternately you should be able to this line to your sbt project definition:
val squeryl = "org.squeryl" % "squeryl_2.8.0" % "0.9.4beta8"
Then run update:
$ sbt
[info] Recompiling project definition...
[info] Source analysis: 1 new/modified, 0 indirectly invalidated, 0 removed.
[info] Building project test 1.0 against Scala 2.8.0
[info] using MainProject with sbt 0.7.4 and Scala 2.7.7
> update
[info]
[info] == update ==
[info] downloading http://scala-tools.org/repo-releases/org/squeryl/squeryl_2.8.0/0.9.4beta8/squeryl_2.8.0-0.9.4beta8.jar ...
[info] [SUCCESSFUL ] org.squeryl#squeryl_2.8.0;0.9.4beta8!squeryl_2.8.0.jar (1425ms)
[info] downloading http://repo1.maven.org/maven2/cglib/cglib-nodep/2.2/cglib-nodep-2.2.jar ...
[info] [SUCCESSFUL ] cglib#cglib-nodep;2.2!cglib-nodep.jar (909ms)
[info] :: retrieving :: test#test_2.8.0 [sync]
[info] confs: [compile, runtime, test, provided, system, optional, sources, javadoc]
[info] 2 artifacts copied, 0 already retrieved (1268kB/60ms)
[info] == update ==
[success] Successful.

Related

Why can't SBT run a specific main?

My Scala 3 code starts with
#main def primer(): Unit = {
. . .
}
and when I use
% sbt run
It runs fine...
% sbt run
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 11.0.13)
[info] loading global plugins from /Users/eric.kolotyluk/.sbt/1.0/plugins
[info] loading project definition from /Users/eric.kolotyluk/git/autonomous-iam/poc/fp-laboratory/project
[info] loading settings for project root from build.sbt ...
[info] set current project to fp-laboratory (in build file:/Users/eric.kolotyluk/git/autonomous-iam/poc/fp-laboratory/)
[info] running com.forgerock.fp.laboratory.primer
Primer running... with 11.0.13+10-LTS-370
Note: SBT believes it is running com.forgerock.fp.laboratory.primer
But, if I try
% sbt "runMain com.forgerock.fp.laboratory.primer"
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 11.0.13)
[info] loading global plugins from /Users/eric.kolotyluk/.sbt/1.0/plugins
[info] loading project definition from /Users/eric.kolotyluk/git/autonomous-iam/poc/fp-laboratory/project
[info] loading settings for project root from build.sbt ...
[info] set current project to fp-laboratory (in build file:/Users/eric.kolotyluk/git/autonomous-iam/poc/fp-laboratory/)
[info] running com.forgerock.fp.laboratory.primer
Primer running... with 11.0.13+10-LTS-370
Exception in thread "sbt-bg-threads-1" java.lang.NoClassDefFoundError: org/apache/spark/sql/SparkSession
at com.forgerock.fp.laboratory.Primer$package$.primer(Primer.scala:30)
So, clearly, run and runMain do not do the same thing.
Is there a way to make runMain do the right thing?
Is this caused by some weirdness with the Scala 3 #main annotation?

Why does sbt 1.0.2 hang after compilation?

I have installed sbt 1.0.2 and tried building the "hello project", but it hangs after done compilation.
I waited for 2 hours and it does not complete. what am I missing here?
HOSTPC:IdeaProjects XYZ2017$ sbt new sbt/scala-seed.g8
[info] Loading settings from plugins.sbt ...
[info] Loading global plugins from /Users/XYZ2017/.sbt/1.0/plugins
[info] Set current project to ideaprojects (in build file:/Users/XYZ2017/IdeaProjects/)
A minimal Scala project.
name [Scala Seed Project]: hello
Template applied in ./hello
HOSTPC:IdeaProjects XYZ2017$ ls
hello
HOSTPC:IdeaProjects XYZ2017$ cd hello/
HOSTPC:hello XYZ2017$ sbt
[info] Loading settings from plugins.sbt ...
[info] Loading global plugins from /Users/XYZ2017/.sbt/1.0/plugins
[info] Loading project definition from /Users/XYZ2017/IdeaProjects/hello/project
[info] Updating {file:/Users/XYZ2017/IdeaProjects/hello/project/}hello-build...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/XYZ2017/IdeaProjects/hello/project/target/scala-2.12/sbt-1.0/classes ...
[info] Done compiling.

sbt doesn't find class of managed dependency

I try to include the build of jep (https://mvnrepository.com/artifact/jep/jep/2.24) into this scala project using sbt: https://github.com/shadaj/scalapy
So, instead of building jep manually via an unmanaged dependency, I want to include it as a managed dependency. Therefore I just included:
resolvers += "jep" at "https://mvnrepository.com/artifact/"
libraryDependencies += "jep" % "jep" % "2.24"
in the build.sbt
The .jar is getting downloaded and included in my .ivy2 folder but when compiling, sbt seems not to find it:
> compile
[info] Updating {file:/C:/scalapy_indp/scalapy/}scalapy...
[info] Resolving org.sonatype.oss#oss-parent;9 ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.1/scala-library-2.12.1.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-library;2.12.1!scala-library.jar (1406ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.12.1/scala-reflect-2.12.1.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-reflect;2.12.1!scala-reflect.jar (1156ms)
[info] downloading https://repo1.maven.org/maven2/jep/jep/2.24/jep-2.24.jar ...
[info] [SUCCESSFUL ] jep#jep;2.24!jep.jar (188ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.1/scala-compiler-2.12.1.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-compiler;2.12.1!scala-compiler.jar (2469ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_2.12/1.0.6/scala-xml_2.12-1.0.6.jar ...
[info] [SUCCESSFUL ] org.scala-lang.modules#scala-xml_2.12;1.0.6!scala-xml_2.12.jar(bundle) (360ms)
[info] downloading https://repo1.maven.org/maven2/jline/jline/2.14.1/jline-2.14.1.jar ...
[info] [SUCCESSFUL ] jline#jline;2.14.1!jline.jar (250ms)
[info] Done updating.
[info] Compiling 16 Scala sources to C:\scalapy_indp\scalapy\target\scala-2.12\classes...
[info] 'compiler-interface' not yet compiled for Scala 2.12.1. Compiling...
[info] Compilation completed in 15.285 s
[error] C:\scalapy_indp\scalapy\src\gen\scala\me\shadaj\scalapy\py\ObjectTupleReaders.scala:2: not found: object jep
[error] import jep.Jep
[error] ^
The errors of course keep coming for every Jep appearance in the code.
I'm absolutely not familiar with scala or sbt, I'm just trying to get this running without having to use unmanaged dependencies i.e. having it platform independent. Building jep manually seems to be platform dependent regarding the files which are being create:
If the build succeeds it will create a directory jep/build which will
contain a jep.jar and the compiled C library of Jep, typically named
jep.so or jep.dll depending on your platform.
see https://github.com/mrj0/jep/wiki/Getting-Started
The dependency is correctly setup, but the import is wrong.
Try
import org.nfunk.jep.JEP
instead.
--
Actually, I just realized those may be two different projects. The dependencies you included is this one: http://sens.cse.msu.edu/Software/jep-2.23/doc/website/doc/doc_usage.htm

Per-configuration classpath dependencies doesn't work with test->test in SBT?

I've got a multi-project build with scalania main project as well as exercises and answers (sub)projects.
The scalania project is hosted on GitHub.
I'm trying to set up a SBT project configuration where the test classes are part of the exercises project while the answers project provides the solutions.
I read Per-configuration classpath dependencies in the official documentation of SBT and ended up with the following configuration in the scalania main project:
lazy val exercises = project
lazy val answers = project.dependsOn(exercises % "test->test")
It doesn't seem to work and upon test execution I used to get:
> project answers
[info] Set current project to scalania-answers (in build file:/Users/jacek/oss/scalania/)
> test
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] No tests to run for answers/test:test
[success] Total time: 1 s, completed Oct 27, 2013 1:06:51 AM
It was until I changed answers/build.sbt to the following:
scalaSource in Test := (scalaSource in LocalProject("exercises") in Test).value
It works fine now.
> reload
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/oss/scalania/project
[info] Set current project to scalania-answers (in build file:/Users/jacek/oss/scalania/)
> project answers
[info] Set current project to scalania-answers (in build file:/Users/jacek/oss/scalania/)
> testOnly *s99.P01*
[info] Formatting 19 Scala sources {file:/Users/jacek/oss/scalania/}answers(test) ...
[info] Compiling 19 Scala sources to /Users/jacek/oss/scalania/answers/target/scala-2.10/test-classes...
[info] P01Spec
[info]
[info] P01 solution should
[info] + Find the last element of a list
[info]
[info]
[info] Total for specification P01Spec
[info] Finished in 151 ms
[info] 1 example, 0 failure, 0 error
[info] Passed: Total 1, Failed 0, Errors 0, Passed 1
[success] Total time: 74 s, completed Oct 27, 2013 1:09:07 AM
What's wrong with using project.dependsOn(exercises % "test->test") only? Am I missing something in the build configuration?
Declaring a dependency on tests in another project just makes the classpath available. Running its tests doesn't happen by default because otherwise tests would run multiple times in the common situation of just reusing code.
To run tests in another project, add the discovered tests from the other project to those for the current project:
definedTests in Test :=
(definedTests in Test).value ++
(definedTests in exercises in Test).value

SBT does not want to enter my project (using project command)

My build is simple:
lazy val stampleWebProject = play.Project("stample-web", appVersion, appDependencies,path = file("stample-web"))
.dependsOn(stampleCoreProject,stampleSearchProject)
.aggregate(stampleCoreProject,stampleSearchProject)
lazy val stampleCoreProject = Project(id = "stample-core",base = file("stample-core"))
lazy val stampleSearchProject = Project(id = "stample-search",base = file("stample-search"))
All these projects have a build.sbt file with dependencies, without any scala build (which would be ignored as far as I know)
When I start SBT (12.4), I get the following:
[info] Set current project to stample-core (in build file:/home/sebastien/Bureau/Stample/)
> projects
[info] In file:/home/sebastien/Bureau/Stample/
[info] * stample-core
[info] stample-search
[info] stample-web
> project stample-search
[info] Set current project to stample-search (in build file:/home/sebastien/Bureau/Stample/)
> projects
[info] In file:/home/sebastien/Bureau/Stample/
[info] stample-core
[info] * stample-search
[info] stample-web
> project stample-core
[info] Set current project to stample-core (in build file:/home/sebastien/Bureau/Stample/)
> projects
[info] In file:/home/sebastien/Bureau/Stample/
[info] * stample-core
[info] stample-search
[info] stample-web
> project stample-web
[info] Set current project to stample-search (in build file:/home/sebastien/Bureau/Stample/)
[stample-search] $ projects
[info] In file:/home/sebastien/Bureau/Stample/
[info] stample-core
[info] stample-search
[info] * stample-web
[stample-search] $ compile
[info] Updating {file:/home/sebastien/Bureau/Stample/}stample-core...
[info] Resolving org.slf4j#slf4j-api;1.6.6 ...
[info] Done updating.
[info] Updating {file:/home/sebastien/Bureau/Stample/}stample-web...
[error] a module is not authorized to depend on itself: stample-search#stample-search_2.10;1.0
[error] (stample-web/*:update) java.lang.IllegalArgumentException: a module is not authorized to depend on itself: stample-search#stample-search_2.10;1.0
[error] Total time: 1 s, completed 26 août 2013 21:57:45
I do not understand some stuff here:
How is choosen the project in which we are by default. I've seem documentation was added in SBT 13.0 but did not see it in the 12.4 multibuild documentation.
How comes I type project stample-web and it tells me I'm in stample-search
Why is there a special display in my sbt console for the project I'm in (stample-web or stample-search, I don't really know...) (this appears here: [stample-search] $ compile, is this relative to play projects?
Why it can't compile stample-search, since it doesn't depend on itself in my build (I suspect it tries to compile the web project but there's a naming problem or something?
Is this an SBT bug. If so, is it possible to use the new 13.0 version with Play framework?
Eugene Yokota is right: I have a conflict in the stample-web folder, which was set the stample-web name in the scala build, but it has a wrong build.sbt in the folder which has name := stample-search