diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-06-30 12:33:07 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-07-01 11:46:29 -0700 |
commit | 8247b8f077c96ba9a017b53de4d8062fe428c4a7 (patch) | |
tree | 52e0fcabfe451bc5e94dbe6183bc039b2ce006c3 /build-ant-macros.xml | |
parent | d2cffb9ad2e431d62c890a7fb9d56520739e07b2 (diff) | |
download | scala-8247b8f077c96ba9a017b53de4d8062fe428c4a7.tar.gz scala-8247b8f077c96ba9a017b53de4d8062fe428c4a7.tar.bz2 scala-8247b8f077c96ba9a017b53de4d8062fe428c4a7.zip |
Prepare build for inclusion of java8-compat
<h1>Allow mixed builds in ant</h1>
The `JFunction` classes depend on the `FunctionN` traits, so the
Java compiler needs the Scala library on the classpath.
At the same time, while compiling the Scala library, the symbols for
`JFunction` classes need to be available to emit indy-lambda closures.
Therefore we pass the `JFunctions` as Java sources while compiling the
Scala library.
<h1>Upgrade versions of osgi tools</h1>
Set the required java version in bnd files (JavaSE-1.8).
Introduce `scala-swing.version.osgi` as a quick hack to
allow manually deriving an osgi-friendly version number
for the `scala-swing.version.number`. The latter is used
to resolve the artifact, the osgi version is just so we
can generate a bundle that osgi will accept.
Bnd 1.50 doesn't work with Java 8 classfiles, so upgrade to 2.4.1.
Also upgrade all other tools to make tests pass.
For `org.eclipse.osgi` we moved to the group ID `org.eclipse.tycho`,
where there's a newer version available. The osgi tests would fail
with the most recent version available in the `org.eclipse.osgi` groupID.
The new version of bnd only copies *classfiles* from the
original into the resulting jar, while the old version also copied
all other files. This caused osgi test failure with a `NoClassDefFound`,
which was really due to a `NumberFormatException` in `ScalaVersion`,
as it couldn't find the properties file to parse the version in...
Include resources from source jar into osgi bundle as follows:
```
Include-Resource: @@SOURCE_JARNAME@
```
This makes bnd copy all resources from the source jar. I ran the
following on the osgi artifacts of this branch, and on 2.11.x:
```
for f in `find build/osgi -name '*.jar' -a -not -name '*src.jar'`; do unzip -l $f | grep -v '\.class' ; done
```
Comparing the two file lists, things look OK:
https://gist.github.com/lrytz/be08db051a53eded192d
Diffstat (limited to 'build-ant-macros.xml')
-rw-r--r-- | build-ant-macros.xml | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/build-ant-macros.xml b/build-ant-macros.xml index d0c9c4d310..868fb41cce 100644 --- a/build-ant-macros.xml +++ b/build-ant-macros.xml @@ -202,7 +202,9 @@ <!-- overrides the output directory; used when building multiple projects into the same directory--> <attribute name="srcdir" default="@{project}"/> <attribute name="java-excludes" default=""/> + <attribute name="mixed" default="NOPE"/> <sequential> + <local name="mixed.true"/><condition property="mixed.true"><equals arg1="@{mixed}" arg2="true"/></condition> <!-- TODO: detect zinc anywhere on PATH use zinc for the quick stage if it's available; would use it for locker but something is iffy in sbt: get a class cast error on global phase --> @@ -220,12 +222,14 @@ <then> <scalacfork taskname="@{stage}.@{project}" jvmargs="${scalacfork.jvmargs}" compilerpathref="@{with}.compiler.path" destdir="${build-@{stage}.dir}/classes/@{destproject}" srcdir="${src.dir}/@{srcdir}" params="${scalac.args.@{stage}} @{args}"> <include name="**/*.scala"/> + <include name="**/*.java" if="mixed.true"/> <compilationpath refid="@{stage}.@{project}.build.path"/> </scalacfork> </then> <else> <scalacfork taskname="@{stage}.@{project}" jvmargs="${scalacfork.jvmargs}" compilerpathref="@{with}.compiler.path" destdir="${build-@{stage}.dir}/classes/@{destproject}" srcdir="${src.dir}/@{srcdir}" srcpath="@{srcpath}" params="${scalac.args.@{stage}} @{args}"> <include name="**/*.scala"/> + <include name="**/*.java" if="mixed.true"/> <compilationpath refid="@{stage}.@{project}.build.path"/> </scalacfork> </else> @@ -270,6 +274,7 @@ <attribute name="includes" default="comp.includes"/> <attribute name="java-excludes" default=""/> <attribute name="version" default=""/> + <attribute name="mixed" default="NOPE"/> <!-- non-empty for scaladoc: use @{version}.version.number in property file--> <sequential> <staged-uptodate stage="@{stage}" project="@{project}"> @@ -279,9 +284,18 @@ <do> <stopwatch name="@{stage}.@{project}.timer"/> <mkdir dir="${build-@{stage}.dir}/classes/@{project}"/> - <staged-javac stage="@{stage}" project="@{project}" excludes="@{java-excludes}"/> - <!-- always compile with javac for simplicity and regularity; it's cheap --> - <staged-scalac with="@{with}" stage="@{stage}" project="@{project}" srcpath="@{srcpath}" args="@{args}" java-excludes="@{java-excludes}"/> + <if> + <equals arg1="@{mixed}" arg2="true"/> + <then> + <staged-scalac with="@{with}" stage="@{stage}" project="@{project}" srcpath="@{srcpath}" args="@{args}" java-excludes="@{java-excludes}" mixed="@{mixed}"/> + <staged-javac stage="@{stage}" project="@{project}" excludes="@{java-excludes}"/> + </then> + <else> + <staged-javac stage="@{stage}" project="@{project}" excludes="@{java-excludes}"/> + <!-- always compile with javac for simplicity and regularity; it's cheap --> + <staged-scalac with="@{with}" stage="@{stage}" project="@{project}" srcpath="@{srcpath}" args="@{args}" java-excludes="@{java-excludes}"/> + </else> + </if> <if> <equals arg1="@{version}" arg2=""/> <then> @@ -474,7 +488,8 @@ <filter token="SCALA_COMPILER_INTERACTIVE_VERSION" value="${scala-compiler-interactive.version.number}"/> <filter token="XML_VERSION" value="${scala-xml.version.number}" /> <filter token="PARSER_COMBINATORS_VERSION" value="${scala-parser-combinators.version.number}" /> - <filter token="SCALA_SWING_VERSION" value="${scala-swing.version.number}" /> + <filter token="SCALA_SWING_VERSION" value="${scala-swing.version.osgi}" /> + <filter token="SOURCE_JARNAME" value="${@{project}.targetjar}"/> </filterset> </copy> <bnd classpath="${@{project}.jar}" eclipse="false" failok="false" exceptions="true" files="${build-osgi.dir}/${@{project}.name}.bnd" output="${build-osgi.dir}"/> |