3.05 KB
Newer Older
1 2 3
# SBT:
1. To install sbt:
2. To use sbt, place yourself at the root of the project (where there is the build.sbt file) and enter "sbt" in the command line. It will start sbt. Then enter "compile" to compile the files that changed since the last compiling, or "run" to do the same job than "compile" + run the project.

5 6 7 8 9 10 11 12 13
* The code has to be in the "java" (for java code) and "scala" (for scala code) folders, located in src/main/java and src/main/scala respectively.
* Each group has two dedicated folders, one in the java folder and one in the scala folder. There are minimal examples of files in both folders.
* Each group has a "package". A package is an annotation ("package <package_name>;" in java | "package <package_name>" in scala) that has to be put at the beginning of your files, to indicate in which package they are. A package defines a scope of visibility for the code. It means that different files from the same package are able to see each other. In order to "see" the code from a different package, a file has to "import" the said package ("import <package_name>.*;" for java files | "import <package_name>._" for scala files).
* Each group has a Main class located in its scala folder (it's not in the java one because sbt wasn't able to detect these main classes nicely). When using the "run" command in sbt, you will have to choose which main class you want to use for the execution. These classes are there for test purposes only, they should disappear from the final software. Their purpose is to allow the different groups to test their code by executing it without involving other groups in the process.
* One thing to note is that these test main classes are in the scala groups folders for sbt to see them, not to prevent groups from using java. Groups may even code entirely in java if they want to. In this case, the scala main class can be defined to only call a java function defined by the group, containing the actual main code.
* There is a GlobalMain class, in the core group folder, which is intended to be the final main class of the project.
* The "resources" folder that is on the same level of the scala and java folders should contains things like images and so on as far as I understand it.
* The "target" folders located throughout the project contains in particular the compiled files that sbt generates. I can't think of any reason you could have to interact with them.

15 16 17 18
## Library dependencies can be added in two ways:
1. unmanaged dependencies are jars dropped into the lib directory
2. managed dependencies are configured in the build definition (build.sbt) and downloaded automatically from repositories

20 21 22
* An interesting document on the subject:
* An example can be found in the scalaJava_interopExample package (which shows how the code from both the java and scala folder from the scalaJava_interopExample package can cooperate). Just run the project using the ScalaMain_InteropExample Class