Compiling scala-compiler
Installing sbt
- Download sbt-0.13.15 to a specified directory (for example, /opt/tools/installed) and decompress it.
1 2 3
wget https://github.com/sbt/sbt/releases/download/v0.13.15/sbt-0.13.15.tgz tar -zxf sbt-0.13.15.tgz mv sbt /opt/tools/installed
- Create the .sbt folder in the root directory of the current user and copy the repositories file to the .sbt folder.
The repositories section defines the sequence in which the Maven repositories are used during sbt compilation.
1 2
mkdir ~/.sbt cp repositories ~/.sbt
The content of the repositories file is as follows:
1 2 3 4 5 6
[repositories] local kunpeng-maven: https://mirrors.huaweicloud.com/kunpeng/maven/ huawei-maven: https://mirrors.huaweicloud.com/repository/maven/ sbt-releases-repo: https://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext] sbt-plugins-repo: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
- Configure the SBT_HOME environment variable.
- Open the /etc/profile file.
1vi /etc/profile - Press i to enter the insert mode and add the following content to the profile file:
1 2
export SBT_HOME=/opt/tools/installed/sbt export PATH=${SBT_HOME}/bin:${PATH}
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the /etc/profile file.
- Make the environment variable take effect.
1source /etc/profile
Compiling scala-compiler-2.11.8
- Scala compilation depends on Jline 2.12.1. Copy the compiled jline-2.12.1.jar file to the ~/.ivy2/cache/jline/jline/jars/ directory. For details, see Jline Porting Guide (CentOS & openEuler).
- Download the scala-2.11.8 source code.
1git clone https://github.com/scala/scala.git
- Go to the source code directory and switch to the version fork.
1 2 3
cd scala git checkout v2.11.8 sed -i "48,48s%)%),\n\ \ \ \ Keys.\`package\`\ := bundle.value%g" project/Osgi.scala
- Compile the source code.
1sbt packageThe scala-compiler.jar file is generated in the build-sbt/pack/lib directory.

Compiling scala-compiler-2.11.12
- Scala compilation depends on Jline 2.14.3. Copy the compiled jline-2.14.3.jar file to the ~/.ivy2/cache/jline/jline/jars/ directory. For details, see Jline Porting Guide (CentOS & openEuler).
- Download the scala-2.11.12 source code.
1git clone https://github.com/scala/scala.git
- Go to the source code directory and switch to the version fork.
1 2 3
cd scala git checkout v2.11.12 sed -i "50,50s%)%),\n\ \ \ \ Keys.\`package\`\ := bundle.value%g" project/Osgi.scala
- Compile the source code.
1sbt packageThe scala-compiler.jar file is generated in the build/pack/lib directory.

Compiling scala-compiler-2.12.7
- Scala compilation depends on Jline 2.14.6. Copy the compiled jline-2.14.6.jar file to the ~/.ivy2/cache/jline/jline/jars/ directory. For details, see Jline Porting Guide (CentOS & openEuler).
- Download the scala-2.12.7 source code.
1git clone https://github.com/scala/scala.git
- Go to the source code directory and switch to the version fork.
1 2
cd scala git checkout v2.12.7
- Change http in the repositories file to https.
1vi ~/.sbt/repositories
- Compile the source code.
1sbt packageThe scala-compiler.jar file is generated in the build/pack/lib directory.

Parent topic: Scala-compiler Porting Guide (CentOS&openEuler)