Rate This Document
Findability
Accuracy
Completeness
Readability

Compiling scala-compiler

Installing sbt

  1. 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
    
  2. 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]
    
  3. Configure the SBT_HOME environment variable.
    1. Open the /etc/profile file.
      1
      vi /etc/profile
      
    2. 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}
      
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Make the environment variable take effect.
    1
    source /etc/profile
    

Compiling scala-compiler-2.11.8

  1. 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).
  2. Download the scala-2.11.8 source code.
    1
    git clone https://github.com/scala/scala.git
    
  3. 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
    
  4. Compile the source code.
    1
    sbt package
    

    The scala-compiler.jar file is generated in the build-sbt/pack/lib directory.

Compiling scala-compiler-2.11.12

  1. 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).
  2. Download the scala-2.11.12 source code.
    1
    git clone https://github.com/scala/scala.git
    
  3. 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
    
  4. Compile the source code.
    1
    sbt package
    

    The scala-compiler.jar file is generated in the build/pack/lib directory.

Compiling scala-compiler-2.12.7

  1. 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).
  2. Download the scala-2.12.7 source code.
    1
    git clone https://github.com/scala/scala.git
    
  3. Go to the source code directory and switch to the version fork.
    1
    2
    cd scala
    git checkout v2.12.7
    
  4. Change http in the repositories file to https.
    1
    vi ~/.sbt/repositories
    

  5. Compile the source code.
    1
    sbt package
    

    The scala-compiler.jar file is generated in the build/pack/lib directory.