Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 959402

Pages: 1
JavaWorld
addict


Reged: 06/20/03
Posts: 482
Build scripts with Groovy and Ant
      #12056 - 10/03/04 12:23 AM

Build scripts with Groovy and Ant

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Build scripts with Groovy and Ant [Re: JavaWorld]
      #12076 - 10/04/04 06:05 AM

I am wondering what is the real gain of doing this?

./the_mindstorm


Post Extras: Print Post   Remind Me!   Notify Moderator  
EricPugh
Unregistered




Re: Build scripts with Groovy and Ant
      #12155 - 10/06/04 07:46 AM

One reason in favor of Groovy is that it's still just java under the covers. Which means you can write unit tests for it.. writing unit tests of complex ant tasks is hard. also, you can directly interface with any java code without writing wrappers around it to expose it to and.

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Build scripts with Groovy and Ant [Re: EricPugh]
      #12224 - 10/07/04 10:02 PM

It seems like you may as well just write your build scipt in Java then. Just make groovy a Java API to access and be done with it. Although, it kind of defeats the purpose of creating a build file that may be maintained by non-java programers (we have dedicated builders at my work).

But hey, reinventing the wheel is fun. Next thing you know we'll be writing config files for the groovy script when they get really complicated. We should probably do those in xml, maybe someone can come up with a standard for that.


Post Extras: Print Post   Remind Me!   Notify Moderator  
dserodio
Unregistered




What about build.properties? [Re: JavaWorld]
      #12243 - 10/08/04 10:14 AM

What about build.properties, which may be different from developer to developer?
Usually, there's a "default" build.properties in the project's root, and the user may override the defaults by placing a build.properties in his home directory.

Code:
<property file="${user.home}/build.properties" />
<property file="build.properties" />


How can I do it with a Groovy Builder?


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Build scripts with Groovy and Ant [Re: Anonymous]
      #12270 - 10/09/04 07:59 AM

For a good build script you need a good language. XML is a bad choice, because it is good for describing data but not procedures. But a language like Java is overkill. I think a scripting language like Groovy could be a good approach. On the other hand, the ant xml has a strong base and IDE's like eclipse support ant nicely. Still I think gravy deserves a chance.

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Build scripts with Groovy and Ant [Re: Anonymous]
      #12428 - 10/13/04 06:36 AM

What about a visual interface to the build XML files?

I'd like to assemble the workflow of a build.xml file using something a visual version of lego bricks. The GUI could
use the ant DTD to allow or prevent bricks clicking together.

Let the machine think about XML, people like pictures.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Nicolas Mayeur
Unregistered




Re: Build scripts with Groovy and Ant [Re: Anonymous]
      #12433 - 10/13/04 07:57 AM

Rewriting build scripts in plain language is probably a bad think imho. Maintainance will be awfull. I know Ant is not easy for complex build procedures, but the best approach I know is maven. It's just an evolution of ant, supports scripting only if necessary (jelly, and other languages in the near future), is more and more recognized by the community, and enforces the use of best practices.

Post Extras: Print Post   Remind Me!   Notify Moderator  
Roach
Unregistered




Re: Build scripts with Groovy and Ant [Re: Nicolas Mayeur]
      #13045 - 11/02/04 07:27 AM

The problem with Ant is that it is fine for simple things but as soon as your build process starts to rely on the "contents" of your source code whether that be XML or whatever you run into problems.

Having logic within an Ant build is not pretty you can either use the extension library to use <if> XML tags or you can embed a scripting language.. both are ugly and confusing in my opinion.

Groovy allows you to use logic within your build but still harness the power of the Ant using a simple expression language. IMO the AntBuilder syntax is very simple and just as easy to read as an ant XML script. You can use groovy to compile and run the scripts as it is a dynamic language so you still have the build scripts as plain text.

Plus if you want to use third party libraries in your build you can. For example we use the Java/ActiveX bridge jacob as part of our build to communicate with Office and automate some Word/Excel tasks. To do this in ant I would have had to write a new tag and add it to ant.

Ant libs may help with this in Ant 1.6 but the fact remains that if you have a simple build process Ant is a great choice, but if your build process has complicated requirements but you still want to automate and you want a dynamic language to do it for you Groovy with Ant works great.


Post Extras: Print Post   Remind Me!   Notify Moderator  
hamy
stranger


Reged: 02/19/07
Posts: 1
Re: What about build.properties? [Re: dserodio]
      #43732 - 02/19/07 02:44 PM

After some sifting through the Ant API doc, I found the following solution: Use the "property" node to define the file that shall be included. In Gant, you might refer a property from this file via the path
Ant -> project -> getProperty(name), in "pure" Groovy, start the traversal at the
Ant builder instance.

Gant example:

task ( init : 'The initialization' ) {
Ant.property ( file:'build.properties' )
fooDirectory = new File( Ant.project.getProperty('foo.dir'))
}


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 8833

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5