You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Caleb Land <ca...@gmail.com> on 2008/02/04 04:15:57 UTC
Groovy integration
I'm writing a project with Java and Groovy, and I was looking to use buildr.
I see that there is Scala integration, but none for Groovy.
I'm looking to build a buildr task for Groovy.
The difference (as I see it) from using Groovy and Scala is that Groovy has
what's called a joint compiler, which allows you to compile java and groovy
code in one swoop, allowing your groovy to depend on java classes and vice
versa.
So, basically, I would like to call my groovy compiler for .java and .groovy
files and skip buildr's default javac compilation. Is it possible to do
this?
--
Caleb Land
Re: Groovy integration
Posted by Victor Hugo Borja <vi...@gmail.com>.
Caleb,
On Wed, Feb 13, 2008 at 6:17 PM, Assaf Arkin <ar...@intalio.com> wrote:
> On 2/4/08, Caleb Land <ca...@gmail.com> wrote
> > Well, I was thinking that it would be turned on automatically if .groovy
> > files were detected, and so if you didn't have any .groovy files, the
> > groovy
> > compiler wouldn't be used.
>
> You're right. If the project contains a .groovy file then it's a Groovy
> project, in which case no problem if it also picks up and compiles .java
> files.
>
Buildr trunk includes a groovyc compiler.
It's not loaded by default because doing so would add the groovy jars into
the classpath, downloading them even if you never use groovy.
If you want to use it, you need to require it on your buildfile
require 'java/grovyc'
Once loaded, the Groovy compiler is automatically selected if it find any
.groovy source files in src/main/groovy. If your project has java sources,
they will get compiled by groovyc.
--
vic
Quaerendo invenietis.
Re: Groovy integration
Posted by Assaf Arkin <ar...@intalio.com>.
On 2/4/08, Caleb Land <ca...@gmail.com> wrote:
>
> On Feb 4, 2008 7:10 PM, Assaf Arkin <ar...@intalio.com> wrote:
>
> > On 2/4/08, Caleb Land <re...@gmail.com> wrote:
> > >
> > >
> > > On Feb 4, 2008, at 3:15 PM, Assaf Arkin wrote:
> > >
> > > > On 2/3/08, Caleb Land <ca...@gmail.com> wrote:
> > > >
> > > > 1.2.10 has a task specific for Scala, but that approach doesn't work
> > > > well,
> > > > it doesn't integrate with test, IDE and other tasks. In 1.3 we
> > > > added a
> > > > framework that can use multiple compilers from the compile task, and
> > > > currently we have Java and Scala. Adding Groovy wouldn't be a big
> > > > deal, see
> > > > lib/java/compilers.rb.
> > > >
> > > Great! I looked at lib/java/compilers.rb and it looks dead simple
> > > (compared to the scala compiler from 1.2.10)
> > >
> > > I think having a groovy compiler installed as the first compiler would
> > > be a good thing to include in core buildr (if the user has .groovy
> > > files that is) since the groovy compiler can joint compile java as
> well.
> > >
> > > What do you think?
> >
> >
> > I won't be a good idea to ask people who are building Java apps to use
> > Groovy, Scala or any other JVM compiler that can cross compile .java
> > files.
> >
>
> Well, I was thinking that it would be turned on automatically if .groovy
> files were detected, and so if you didn't have any .groovy files, the
> groovy
> compiler wouldn't be used.
You're right. If the project contains a .groovy file then it's a Groovy
project, in which case no problem if it also picks up and compiles .java
files.
Assaf
--
> Caleb Land
>
Re: Groovy integration
Posted by Caleb Land <ca...@gmail.com>.
On Feb 4, 2008 7:10 PM, Assaf Arkin <ar...@intalio.com> wrote:
> On 2/4/08, Caleb Land <re...@gmail.com> wrote:
> >
> >
> > On Feb 4, 2008, at 3:15 PM, Assaf Arkin wrote:
> >
> > > On 2/3/08, Caleb Land <ca...@gmail.com> wrote:
> > >
> > > 1.2.10 has a task specific for Scala, but that approach doesn't work
> > > well,
> > > it doesn't integrate with test, IDE and other tasks. In 1.3 we
> > > added a
> > > framework that can use multiple compilers from the compile task, and
> > > currently we have Java and Scala. Adding Groovy wouldn't be a big
> > > deal, see
> > > lib/java/compilers.rb.
> > >
> > Great! I looked at lib/java/compilers.rb and it looks dead simple
> > (compared to the scala compiler from 1.2.10)
> >
> > I think having a groovy compiler installed as the first compiler would
> > be a good thing to include in core buildr (if the user has .groovy
> > files that is) since the groovy compiler can joint compile java as well.
> >
> > What do you think?
>
>
> I won't be a good idea to ask people who are building Java apps to use
> Groovy, Scala or any other JVM compiler that can cross compile .java
> files.
>
Well, I was thinking that it would be turned on automatically if .groovy
files were detected, and so if you didn't have any .groovy files, the groovy
compiler wouldn't be used.
--
Caleb Land
Re: Groovy integration
Posted by Assaf Arkin <ar...@intalio.com>.
On 2/4/08, Caleb Land <re...@gmail.com> wrote:
>
>
> On Feb 4, 2008, at 3:15 PM, Assaf Arkin wrote:
>
> > On 2/3/08, Caleb Land <ca...@gmail.com> wrote:
> >
> > 1.2.10 has a task specific for Scala, but that approach doesn't work
> > well,
> > it doesn't integrate with test, IDE and other tasks. In 1.3 we
> > added a
> > framework that can use multiple compilers from the compile task, and
> > currently we have Java and Scala. Adding Groovy wouldn't be a big
> > deal, see
> > lib/java/compilers.rb.
> >
> Great! I looked at lib/java/compilers.rb and it looks dead simple
> (compared to the scala compiler from 1.2.10)
>
> I think having a groovy compiler installed as the first compiler would
> be a good thing to include in core buildr (if the user has .groovy
> files that is) since the groovy compiler can joint compile java as well.
>
> What do you think?
I won't be a good idea to ask people who are building Java apps to use
Groovy, Scala or any other JVM compiler that can cross compile .java files.
Assaf
> After a lot of playing around, the simplest approach I could find
> > was to go
> > with one-language-per-project. You can use multiple languages in
> > the same
> > build, but each project configures itself to one compiler, by
> > looking for
> > available source files. So if the project has .java files, the Javac
> > compiler will kick in, since it's first on the list. Next on the
> > list is
> > Scalac, which only kicks in if it sees .scala files, etc.
> >
> > You can work around it by writing a Groovy compiler that looks for
> > either
> > Java or Groovy sources (see applies_to in Compiler::Base), by
> > placing it
> > first in the list of available compilers (unshift instead of <<).
> >
> > Assaf
> >
> > --
> >> Caleb Land
> >>
> >
> >
> >
> > --
> > CTO, Intalio
> > http://www.intalio.com
>
>
Re: Groovy integration
Posted by Alex Boisvert <bo...@intalio.com>.
On 2/4/08, Caleb Land <re...@gmail.com> wrote:
>
> Great! I looked at lib/java/compilers.rb and it looks dead simple
> (compared to the scala compiler from 1.2.10)
>
> I think having a groovy compiler installed as the first compiler would
> be a good thing to include in core buildr (if the user has .groovy
> files that is) since the groovy compiler can joint compile java as well.
>
> What do you think?
I think it's a great idea to add support for Groovy.
Similarly to Java/Scala, the Groovy compiler could automatically kick in
with the presence of "src/main/groovy" and compile everything that's under
"src/main/java" and "src/main/groovy" in one swoop. This is a case where
you have one project language (:groovy) that can implicitly handle two
languages transparently.
alex
Re: Groovy integration
Posted by Caleb Land <re...@gmail.com>.
On Feb 4, 2008, at 3:15 PM, Assaf Arkin wrote:
> On 2/3/08, Caleb Land <ca...@gmail.com> wrote:
>
> 1.2.10 has a task specific for Scala, but that approach doesn't work
> well,
> it doesn't integrate with test, IDE and other tasks. In 1.3 we
> added a
> framework that can use multiple compilers from the compile task, and
> currently we have Java and Scala. Adding Groovy wouldn't be a big
> deal, see
> lib/java/compilers.rb.
>
Great! I looked at lib/java/compilers.rb and it looks dead simple
(compared to the scala compiler from 1.2.10)
I think having a groovy compiler installed as the first compiler would
be a good thing to include in core buildr (if the user has .groovy
files that is) since the groovy compiler can joint compile java as well.
What do you think?
> After a lot of playing around, the simplest approach I could find
> was to go
> with one-language-per-project. You can use multiple languages in
> the same
> build, but each project configures itself to one compiler, by
> looking for
> available source files. So if the project has .java files, the Javac
> compiler will kick in, since it's first on the list. Next on the
> list is
> Scalac, which only kicks in if it sees .scala files, etc.
>
> You can work around it by writing a Groovy compiler that looks for
> either
> Java or Groovy sources (see applies_to in Compiler::Base), by
> placing it
> first in the list of available compilers (unshift instead of <<).
>
> Assaf
>
> --
>> Caleb Land
>>
>
>
>
> --
> CTO, Intalio
> http://www.intalio.com
Re: Groovy integration
Posted by Assaf Arkin <ar...@intalio.com>.
On 2/3/08, Caleb Land <ca...@gmail.com> wrote:
>
> I'm writing a project with Java and Groovy, and I was looking to use
> buildr.
> I see that there is Scala integration, but none for Groovy.
> I'm looking to build a buildr task for Groovy.
>
> The difference (as I see it) from using Groovy and Scala is that Groovy
> has
> what's called a joint compiler, which allows you to compile java and
> groovy
> code in one swoop, allowing your groovy to depend on java classes and vice
> versa.
>
> So, basically, I would like to call my groovy compiler for .java and
> .groovy
> files and skip buildr's default javac compilation. Is it possible to do
> this?
1.2.10 has a task specific for Scala, but that approach doesn't work well,
it doesn't integrate with test, IDE and other tasks. In 1.3 we added a
framework that can use multiple compilers from the compile task, and
currently we have Java and Scala. Adding Groovy wouldn't be a big deal, see
lib/java/compilers.rb.
After a lot of playing around, the simplest approach I could find was to go
with one-language-per-project. You can use multiple languages in the same
build, but each project configures itself to one compiler, by looking for
available source files. So if the project has .java files, the Javac
compiler will kick in, since it's first on the list. Next on the list is
Scalac, which only kicks in if it sees .scala files, etc.
You can work around it by writing a Groovy compiler that looks for either
Java or Groovy sources (see applies_to in Compiler::Base), by placing it
first in the list of available compilers (unshift instead of <<).
Assaf
--
> Caleb Land
>
--
CTO, Intalio
http://www.intalio.com
Re: Groovy integration
Posted by Matthieu Riou <ma...@offthelip.org>.
On Feb 4, 2008 1:19 AM, Victor Hugo Borja <vi...@gmail.com> wrote:
> Caleb,
>
> So, basically, I would like to call my groovy compiler for .java and
> > .groovy
> > files and skip buildr's default javac compilation. Is it possible to do
> > this?
> >
>
> I've written a simple project to test the groovy joint compiler. Indeed
> all you have to do is call
> the groovyc ant task as documented on
> http://groovy.codehaus.org/The+groovyc+Ant+Task
>
> I've attached the project containing a sample buildfile for you, and a
> basic Groovy compiler for Buildr
>
> Hope this can be of help.
>
Attachments sometimes get removed when posted to the mailing-list. A jira
attachment is the way to go.
Matthieu
>
> --
> vic
>
> Quaerendo invenietis.
Re: Groovy integration
Posted by Victor Hugo Borja <vi...@gmail.com>.
On Feb 4, 2008 2:18 PM, Caleb Land <re...@gmail.com> wrote:
> Thanks for the help Vic, but I didn't get your attachment.
>
> Ultimately I think it would be good for buildr to have a plugin that
> compiles groovy. This would be a good starting point for developing
> that plugin (as well for getting my project up and running).
>
I've created a JIRA issue, and attached sample buildfile and groovyc.rb
https://issues.apache.org/jira/browse/BUILDR-37
--
vic
Quaerendo invenietis.
Re: Groovy integration
Posted by Caleb Land <re...@gmail.com>.
Thanks for the help Vic, but I didn't get your attachment.
Ultimately I think it would be good for buildr to have a plugin that
compiles groovy. This would be a good starting point for developing
that plugin (as well for getting my project up and running).
On Feb 4, 2008, at 4:19 AM, Victor Hugo Borja wrote:
> Caleb,
>
> So, basically, I would like to call my groovy compiler for .java
> and .groovy
> files and skip buildr's default javac compilation. Is it possible to
> do
> this?
>
> I've written a simple project to test the groovy joint compiler.
> Indeed all you have to do is call
> the groovyc ant task as documented on http://groovy.codehaus.org/The+groovyc+Ant+Task
>
> I've attached the project containing a sample buildfile for you, and
> a basic Groovy compiler for Buildr
>
> Hope this can be of help.
>
> --
> vic
>
> Quaerendo invenietis.
Re: Groovy integration
Posted by Victor Hugo Borja <vi...@gmail.com>.
Caleb,
So, basically, I would like to call my groovy compiler for .java and .groovy
> files and skip buildr's default javac compilation. Is it possible to do
> this?
>
I've written a simple project to test the groovy joint compiler. Indeed all
you have to do is call
the groovyc ant task as documented on
http://groovy.codehaus.org/The+groovyc+Ant+Task
I've attached the project containing a sample buildfile for you, and a basic
Groovy compiler for Buildr
Hope this can be of help.
--
vic
Quaerendo invenietis.