<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Joint Compilation of Scala and Java Sources</title>
	<atom:link href="http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources</link>
	<description>(permanently in beta)</description>
	<lastBuildDate>Sun, 29 Aug 2010 20:01:44 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dan</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-5114</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Mon, 26 Jul 2010 14:58:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-5114</guid>
		<description>What about joint compilation of scaladoc and javadoc?</description>
		<content:encoded><![CDATA[<p>What about joint compilation of scaladoc and javadoc?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-4866</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Fri, 24 Jul 2009 20:47:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-4866</guid>
		<description>Holy mind-numbing XML, Batman!  I think I&#039;m going to stick with Buildr, considering the fact that something like this (manual control over the build process) is almost trivial.</description>
		<content:encoded><![CDATA[<p>Holy mind-numbing XML, Batman!  I think I&#8217;m going to stick with Buildr, considering the fact that something like this (manual control over the build process) is almost trivial.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Blick</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-4864</link>
		<dc:creator>Dan Blick</dc:creator>
		<pubDate>Fri, 24 Jul 2009 20:40:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-4864</guid>
		<description>As an alternative to maven-scala-plugin, you could also use antrun, which I&#039;m starting to think of as Maven&#039;s escape hatch for tricky problems.  In this situation, if you have Java files that depend on Scala classes, you can prevent compiler:compile from trying to compile them by putting them in src/main/scala instead of src/main/java.  You can then build them as you&#039;ve suggested with antrun.  Here&#039;s a POM snippet that worked for me:

&lt;pre&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
        &lt;version&gt;1.3&lt;/version&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;id&gt;scala-compile&lt;/id&gt;
            &lt;phase&gt;compile&lt;/phase&gt;
            &lt;configuration&gt;
              &lt;tasks&gt;
                &lt;property name=&quot;build.compiler&quot; value=&quot;extJavac&quot;/&gt;
                &lt;taskdef resource=&quot;scala/tools/ant/antlib.xml&quot; classpathref=&quot;maven.compile.classpath&quot;/&gt;
                &lt;mkdir dir=&quot;${project.build.outputDirectory}&quot;/&gt;
                &lt;scalac srcdir=&quot;src/main&quot; destdir=&quot;${project.build.outputDirectory}&quot; classpathref=&quot;maven.compile.classpath&quot;&gt;
                  &lt;include name=&quot;scala/**/*.scala&quot;/&gt;
                  &lt;include name=&quot;scala/**/*.java&quot;/&gt;
                &lt;/scalac&gt;
                &lt;javac srcdir=&quot;src/main&quot; destdir=&quot;${project.build.outputDirectory}&quot; classpathref=&quot;maven.compile.classpath&quot;&gt;
                  &lt;include name=&quot;scala/**/*.java&quot;/&gt;
                &lt;/javac&gt;
              &lt;/tasks&gt;
            &lt;/configuration&gt;
            &lt;goals&gt;
              &lt;goal&gt;run&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
          &lt;execution&gt;
            &lt;id&gt;scala-test-compile&lt;/id&gt;
            &lt;phase&gt;test-compile&lt;/phase&gt;
            &lt;configuration&gt;
              &lt;tasks&gt;
                &lt;property name=&quot;build.compiler&quot; value=&quot;extJavac&quot;/&gt;
                &lt;taskdef resource=&quot;scala/tools/ant/antlib.xml&quot; classpathref=&quot;maven.compile.classpath&quot;/&gt;
                &lt;mkdir dir=&quot;${project.build.testOutputDirectory}&quot;/&gt;
                &lt;scalac srcdir=&quot;src/test&quot; destdir=&quot;${project.build.testOutputDirectory}&quot; classpathref=&quot;maven.test.classpath&quot;&gt;
                  &lt;include name=&quot;scala/**/*.scala&quot;/&gt;
                  &lt;include name=&quot;scala/**/*.java&quot;/&gt;
                &lt;/scalac&gt;
                &lt;javac srcdir=&quot;src/test&quot; destdir=&quot;${project.build.testOutputDirectory}&quot; classpathref=&quot;maven.test.classpath&quot;&gt;
                  &lt;include name=&quot;scala/**/*.java&quot;/&gt;
                &lt;/javac&gt;
              &lt;/tasks&gt;
            &lt;/configuration&gt;
            &lt;goals&gt;
              &lt;goal&gt;run&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
        &lt;dependencies&gt;
          &lt;dependency&gt;
            &lt;groupId&gt;org.scala-lang&lt;/groupId&gt;
            &lt;artifactId&gt;scala-compiler&lt;/artifactId&gt;
            &lt;version&gt;2.7.5&lt;/version&gt;
          &lt;/dependency&gt;
        &lt;/dependencies&gt;
      &lt;/plugin&gt;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>As an alternative to maven-scala-plugin, you could also use antrun, which I&#8217;m starting to think of as Maven&#8217;s escape hatch for tricky problems.  In this situation, if you have Java files that depend on Scala classes, you can prevent compiler:compile from trying to compile them by putting them in src/main/scala instead of src/main/java.  You can then build them as you&#8217;ve suggested with antrun.  Here&#8217;s a POM snippet that worked for me:</p>
<pre>
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
        &lt;version&gt;1.3&lt;/version&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;id&gt;scala-compile&lt;/id&gt;
            &lt;phase&gt;compile&lt;/phase&gt;
            &lt;configuration&gt;
              &lt;tasks&gt;
                &lt;property name="build.compiler" value="extJavac"/&gt;
                &lt;taskdef resource="scala/tools/ant/antlib.xml" classpathref="maven.compile.classpath"/&gt;
                &lt;mkdir dir="${project.build.outputDirectory}"/&gt;
                &lt;scalac srcdir="src/main" destdir="${project.build.outputDirectory}" classpathref="maven.compile.classpath"&gt;
                  &lt;include name="scala/**/*.scala"/&gt;
                  &lt;include name="scala/**/*.java"/&gt;
                &lt;/scalac&gt;
                &lt;javac srcdir="src/main" destdir="${project.build.outputDirectory}" classpathref="maven.compile.classpath"&gt;
                  &lt;include name="scala/**/*.java"/&gt;
                &lt;/javac&gt;
              &lt;/tasks&gt;
            &lt;/configuration&gt;
            &lt;goals&gt;
              &lt;goal&gt;run&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
          &lt;execution&gt;
            &lt;id&gt;scala-test-compile&lt;/id&gt;
            &lt;phase&gt;test-compile&lt;/phase&gt;
            &lt;configuration&gt;
              &lt;tasks&gt;
                &lt;property name="build.compiler" value="extJavac"/&gt;
                &lt;taskdef resource="scala/tools/ant/antlib.xml" classpathref="maven.compile.classpath"/&gt;
                &lt;mkdir dir="${project.build.testOutputDirectory}"/&gt;
                &lt;scalac srcdir="src/test" destdir="${project.build.testOutputDirectory}" classpathref="maven.test.classpath"&gt;
                  &lt;include name="scala/**/*.scala"/&gt;
                  &lt;include name="scala/**/*.java"/&gt;
                &lt;/scalac&gt;
                &lt;javac srcdir="src/test" destdir="${project.build.testOutputDirectory}" classpathref="maven.test.classpath"&gt;
                  &lt;include name="scala/**/*.java"/&gt;
                &lt;/javac&gt;
              &lt;/tasks&gt;
            &lt;/configuration&gt;
            &lt;goals&gt;
              &lt;goal&gt;run&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
        &lt;dependencies&gt;
          &lt;dependency&gt;
            &lt;groupId&gt;org.scala-lang&lt;/groupId&gt;
            &lt;artifactId&gt;scala-compiler&lt;/artifactId&gt;
            &lt;version&gt;2.7.5&lt;/version&gt;
          &lt;/dependency&gt;
        &lt;/dependencies&gt;
      &lt;/plugin&gt;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-4471</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Sun, 11 Jan 2009 21:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-4471</guid>
		<description>@Ilya

Personally, I think that Buildr is really the only way to go for Scala projects.  It&#039;s faster than Maven, far easier to configure, and requires less manual tweaking than Ant.  It especially shines when it comes time to include a dependency that isn&#039;t in a Maven repo.  Its only problem is the fact that it doesn&#039;t have Scala/Java joint compilation in the mainline trunk/ (working on that).</description>
		<content:encoded><![CDATA[<p>@Ilya</p>
<p>Personally, I think that Buildr is really the only way to go for Scala projects.  It&#8217;s faster than Maven, far easier to configure, and requires less manual tweaking than Ant.  It especially shines when it comes time to include a dependency that isn&#8217;t in a Maven repo.  Its only problem is the fact that it doesn&#8217;t have Scala/Java joint compilation in the mainline trunk/ (working on that).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilya Sergey</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-4470</link>
		<dc:creator>Ilya Sergey</dc:creator>
		<pubDate>Sun, 11 Jan 2009 20:35:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-4470</guid>
		<description>BTW, Scala plugin for IntelliJ provides automatic ant script generation by project taking into account these peculiarities of Scala/Java joint compilation. :)</description>
		<content:encoded><![CDATA[<p>BTW, Scala plugin for IntelliJ provides automatic ant script generation by project taking into account these peculiarities of Scala/Java joint compilation. <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-4455</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Wed, 07 Jan 2009 01:29:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-4455</guid>
		<description>Actually, joint compilation in the Scala Eclipse plugin works out of the box.  Try it!  :-)</description>
		<content:encoded><![CDATA[<p>Actually, joint compilation in the Scala Eclipse plugin works out of the box.  Try it!  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James E. Ervin</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-4454</link>
		<dc:creator>James E. Ervin</dc:creator>
		<pubDate>Wed, 07 Jan 2009 00:53:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-4454</guid>
		<description>I would be thrilled to see how the Scala Eclipse plugin ppl would approach this.  I am having the same issue using Groovy&#039;s joint compiler in Groovy Eclipse.</description>
		<content:encoded><![CDATA[<p>I would be thrilled to see how the Scala Eclipse plugin ppl would approach this.  I am having the same issue using Groovy&#8217;s joint compiler in Groovy Eclipse.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danno Ferrin</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-4452</link>
		<dc:creator>Danno Ferrin</dc:creator>
		<pubDate>Mon, 05 Jan 2009 17:18:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-4452</guid>
		<description>A unified joint compiler would be a nice thing, but based on my reading of how to use Scala&#039;s joint compilation, the do it quite different from Groovy.

When Groovy does a joint compile it is really a three step process: Generate Groovy Stubs, call JavaC on the .java files with the stubs as non-compiled source, compile Groovy with the JavaC Results in the classpath.  The clever part from the IntelliJ guys was the stub generation.  A signature equivalent java file is generated from the Groovy source and made available to JavaC  Since the transform is fairly simple and does not vary based on the actual libraries used no external code needs to be referenced, it&#039;s just a text transformation on the AST.  It looks to me Scala is parsing the Java source and just creating data in it&#039;s compiler tables to handle the symbols and verification for the Scala code.

However, if Scala, Jython, JRuby, JavaFX Script, etc. had stub generation code then a grand unified compiler could be written, but it gets messy at n=3 if Groovy calls JRuby for example, the stubs would need to be compiled and segregated so that they don&#039;t get exposed to the Groovy code.  It would be a really neat hack and would help the case for JVM polygot programming a lot.  But, alas, not enough spare time. :(</description>
		<content:encoded><![CDATA[<p>A unified joint compiler would be a nice thing, but based on my reading of how to use Scala&#8217;s joint compilation, the do it quite different from Groovy.</p>
<p>When Groovy does a joint compile it is really a three step process: Generate Groovy Stubs, call JavaC on the .java files with the stubs as non-compiled source, compile Groovy with the JavaC Results in the classpath.  The clever part from the IntelliJ guys was the stub generation.  A signature equivalent java file is generated from the Groovy source and made available to JavaC  Since the transform is fairly simple and does not vary based on the actual libraries used no external code needs to be referenced, it&#8217;s just a text transformation on the AST.  It looks to me Scala is parsing the Java source and just creating data in it&#8217;s compiler tables to handle the symbols and verification for the Scala code.</p>
<p>However, if Scala, Jython, JRuby, JavaFX Script, etc. had stub generation code then a grand unified compiler could be written, but it gets messy at n=3 if Groovy calls JRuby for example, the stubs would need to be compiled and segregated so that they don&#8217;t get exposed to the Groovy code.  It would be a really neat hack and would help the case for JVM polygot programming a lot.  But, alas, not enough spare time. <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jau</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-4451</link>
		<dc:creator>jau</dc:creator>
		<pubDate>Mon, 05 Jan 2009 14:08:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-4451</guid>
		<description>Very useful article. Thanks !</description>
		<content:encoded><![CDATA[<p>Very useful article. Thanks !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Chermside</title>
		<link>http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources/comment-page-1#comment-4450</link>
		<dc:creator>Michael Chermside</dc:creator>
		<pubDate>Mon, 05 Jan 2009 13:05:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources#comment-4450</guid>
		<description>Daniel:

This is great... the fact that Scala now will allow compiling cross-dependencies with pure Java code and also the fact that you provided everyone with a handy writeup and cheatsheet.

What bothers me is that in my mind this solves the wrong problem. The REAL objective is not allowing compilation of projects containing both Scala and Java code, but compilation of projects containing mixed code of various languages that interoperate on the JVM. Jython, Groovy, Scala, and Java should all be able to co-exist. They can effectively all use Java as an inter-language interface, and they can all compile today so long as there are no circular dependencies. But introduce circular dependencies and you are now restricted to Groovy-and-Java, or Scala-and-Java, or basically any combination of languages so long as the &quot;youngest&quot; compiler is aware of all the languages.

Or you can try playing tricks with multiple compilation passes -- compile certain sources in one language, then other sources in another, then back to the first language. I can say from experience that this approach gets unmanageable VERY rapidly.

What IS the ideal solution? Perhaps a standard facility that compilers like Groovy, Scala, Jythonc, and others can implement which would allow them to be invoked just to produce the AST (perhaps in the form of a stub .class file). Does anyone reading this know of any attempts to produce such a thing?</description>
		<content:encoded><![CDATA[<p>Daniel:</p>
<p>This is great&#8230; the fact that Scala now will allow compiling cross-dependencies with pure Java code and also the fact that you provided everyone with a handy writeup and cheatsheet.</p>
<p>What bothers me is that in my mind this solves the wrong problem. The REAL objective is not allowing compilation of projects containing both Scala and Java code, but compilation of projects containing mixed code of various languages that interoperate on the JVM. Jython, Groovy, Scala, and Java should all be able to co-exist. They can effectively all use Java as an inter-language interface, and they can all compile today so long as there are no circular dependencies. But introduce circular dependencies and you are now restricted to Groovy-and-Java, or Scala-and-Java, or basically any combination of languages so long as the &#8220;youngest&#8221; compiler is aware of all the languages.</p>
<p>Or you can try playing tricks with multiple compilation passes &#8212; compile certain sources in one language, then other sources in another, then back to the first language. I can say from experience that this approach gets unmanageable VERY rapidly.</p>
<p>What IS the ideal solution? Perhaps a standard facility that compilers like Groovy, Scala, Jythonc, and others can implement which would allow them to be invoked just to produce the AST (perhaps in the form of a stub .class file). Does anyone reading this know of any attempts to produce such a thing?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
