Eclipse is a very useful development tool, and the kids ' shoes that are familiar with it should know that it is not only the most commonly used Android development tool , but also the most common Java development tool. Since eclipse is so important, the small part of this article will be together with you to pick up the knowledge of building a Scala development environment in Eclipse, interested children shoes can come together to see.
1 , Scala is what
In fact, Scala is a syntax, similar to Java, and SBT is a build tool, similar to maven,gradle,ant. In Eclipse, only the Scala development environment plug-in can build Scala project, but without the SBT plugin, like eclipse without the Maven plugin, you can build and edit Java project only, but not MAVEN project.
2 , Build Steps
1) Build the Scala locale, like Java, in two main steps: Download software, configure home and path.
2) Install SBT tool, download and configure global variables (add Sbt.bat script in Windows environment, can run directly)
3) Use SBT to generate a MAVEN package architecture like Scala project.
3 , actual operation
1) Create a new directory called Test
2) Create a new file in the test directory BUILD.SBT
3) Create a new project directory in the test directory, go to the project directory, and create a new PLUGINS.SBT, where you add
Addsbtplugin ("com.typesafe.sbteclipse"% "sbteclipse-plugin"% "2.4.0")
4) Configure the Name,scala compilation environment, dependencies and so on in BUILD.SBT. Such as:
Import Sbt._
Import Process._
Import Keys._
ECLIPSEKEYS.CREATESRC: = Eclipsecreatesrc.default + Eclipsecreatesrc.resource
Lazy val commonsettings = Seq (
Name: = "Test",
Organization: = "Com.marsyoung",
Version: = "0.0.1-snapshot",
Scalaversion: = "2.11.7"
)
Lazy val root = (Project in file (".")).
Settings (commonsettings: _*).
Settings
Librarydependencies ++= Seq (
"JUnit"% "JUnit"% "4.4",
"Javax.ws.rs"% "Jsr311-api"% "1.1.1"
)
)
5) Enter the corresponding project directory in CMD, which is the test directory. Run SBT.
6) Execute the Eclipse command to convert the corresponding project into a project that can introduce eclipse development tools and a directory structure similar to MAVEN.
7) Open Eclipse, which already has the Scala IDE installed, and import the corresponding project, which will be automatically compiled into Scala peoject.
4 , Tips
The SBT configuration allows it to support local maven and the following:
In the. SBT folder under the user's root directory, create a new repositories file and insert content under Windows c-> user name->.SBT directory:
[Repositories]
Local
activator-launcher-local:file:////${activator.local.repository-${activator.home-${user.home}/.activator}/ Repository}, [organization]/[module]/(scala_[scalaversion]/) (sbt_[sbtversion]/) [Revision]/[type]s/[artifact] (-[ Classifier]). [ext]
activator-local:file:////${activator.local.repository-d:/maven/repo3.3.1}
Sohu-public:http://xxx.com/nexus/content/groups/public
Typesafe-releases:http://repo.typesafe.com/typesafe/releases
Typesafe-ivy-releasez:http://repo.typesafe.com/typesafe/ivy-releases, [organization]/[module]/(scala_[ scalaversion]/) (sbt_[sbtversion]/) [Revision]/[type]s/[artifact] (-[classifier]). [ext]
Sonatype-oss-releases
Sonatype-oss-snapshots
Maven-central
The local MAVEN address is:
d:/maven/repo3.3.1
The Nexus address is:
Http://xxx.com/nexus/content/groups/public
However, it is important to note that if there is a new dependency or the package needs to be introduced, it will not be compiled automatically in eclipse and need to be manually gone to the SBT console to compile and eclipse.
The above is the steps and the actual operation of building the Scala development environment in Eclipse, and you can try to build it in your own environment. Finally, I hope that the sharing of this article can help you better grasp the relevant knowledge.
Related article: "29 common classes, methods and interfaces for Android development"
Steps to build the Scala development environment in eclipse