Home > OS >  Is there a way to build Scala 2.10.3 from source code?
Is there a way to build Scala 2.10.3 from source code?

Time:08-31

I know it's a very old thing now, but I need it. I download scala-sources from the link, unpacking on Ubuntu 20.04. Also I download Ant 1.7.0 and install it. Also I download Apache maven 2.2.1 (or I tried maven 3.5.0) and install it.I also use jdk1.8.0.

I am trying to run "ant" or "ant build" from the scala directory, and something happens, but the build failed for the following reasons:

failed to create task or type scalacfork

Build failed

2

The following messages also appear at the top:

[taskdef] java.util.zip.ZipException: zip file is empty
(several times)
...
[WARNING] POM for 'biz.aQute:bndlib:pom:1.43.0:compile' is invalid.
...
[taskdef] Could not load definitions from resource scala/tools/ant/sabbus/antlib.xml. It could not be found.

I understand that many things are no longer available now and are definitely not supported, but maybe someone will tell me a way to get the result.
Maybe I can download the necessary data and manually build scala? I'm new to this and don't quite understand what and where I can change. And I can't use a newer version of scala because of work.

I hope for any help. Thank you in advance.

CodePudding user response:

Yes, it is possible. Although it requires some patches in the build process and a few workarounds.

  • Read the README.rst, it contains some information on how builds are structured
  • Run git init, git add ., git commit as the build uses some git info (commit hash, etc) during build. It may be not needed for release, but I have not tried.
  • You need either JDK 1.6 or JDK 1.7. It can't be built on the 1.8 JDK (compilation fails if you remove checks from build.xml). And on 1.7 it says it can't build swing library so you won't be able to build distribution.
  • Fix the tools/binary-repo-lib.sh and change URLs to https otherwise fetching artifacts will fail. Maybe you have to remove some of the curl arguments to see what happens, maybe it won't be required.
  • Run pull-binary-libs.sh
  • Fix build.xml to use https protocol. This is based on the Official usage documentation. You have to define repository before the first artifact:dependencies task in the file (I did that in the same block).
      <artifact:remoteRepository id="central" url="https://repo1.maven.org/maven2" />

Then you have to tell every artifact:dependency task to use that repo by adding the remoteRepository element, the tasks should look like

      <artifact:dependencies pathId="extra.tasks.classpath" filesetId="extra.tasks.fileset">
        <dependency groupId="biz.aQute" artifactId="bnd" version="1.50.0"/>
        <remoteRepository refid="central"/>
      </artifact:dependencies>

I think this was enough for me to build it using ant build on JDK 1.7 (apparently, swing libs were not built).

But probably the easier way would be to just download prebuild Scala version or tell your build tool to use the Scala version you want.

  • Related