The Artima Developer Community
Sponsored Link

Java Community News
Ant 1.7 Released

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Ant 1.7 Released Posted: Dec 20, 2006 3:03 PM
Reply to this message Reply
Summary
The Apache Ant project released the 1.7 version of its ubiquitous Java build tool. The latest version features a new resource framework, refinements to antlib support for extending Ant, additional tags for integrating scripts with Ant, and initial support for Java 6 features.
Advertisement

The latest version of Apache Ant aims to solve several of the scalability limitations that made it difficult to use earlier Ant versions on complex projects.

According to a presentation [PDF] by Steve Loughran, a member of the Ant development team and author of Manning's Java Development with Ant, one interesting new Ant feature is improved support for scripting. While Ant 1.6 introduced the scriptdef and scriptfilter tags, 1.7 adds more scripting support with the scriptcondition (implement a condition), scriptselector> (select files), and scriptmapper (map file names) tags. According to Loughran, BeanShell, Jython, Groovy, JavaScript, JRuby, Rexx, and other scripting languages can be used with Ant.

In the presentation, Loughran shows how simple defining scripts inside an Ant file is:

<scriptdef name="repeat" language="ruby">
  <attribute name="from"/>
  <attribute name="to"/>
  <attribute name="message"/>

  attr = $bsf.lookupBean("attributes")
  from = attr.get("from")
  to = attr.get("to")
  message = attr.get("message")
  from.upto(to) {|i| print "#{1}:", message, "\n"}
</scriptdef>

<target name="1to5">
  <repeat from="1" to="5" message="hello, world"/>
</target>

Another feature that had support in Ant 1.6 and is now present in 1.7 in a more robust way, is the concept of Antlibs. The Ant documentation notes that Ant uses antlibs to outsource optional tasks to, supplanting the existing optional Ant task framework. In a response to Artima's coverage of Ant 1.7's beta release, Loughran pointed out that:

Antlib support has been in ant1.6.5; we have just been refining things for Ant1.7.

By declaring an xmlns for a library, xmns:ac=antlib://net/sf/antcontrib;, Ant will autoload the library and make its tasks, types and macros available in the new namespace. This does mean that you have to deal with xmlns, but it stops problems with every app server stack providing a task called <deploy>. Now you can have <tomcat:deploy> next to <glassfish:deploy>.

If you are writing third party libraries for Ant, write and ship an antlib today just by adding a new descriptor, antlib.xml. And what is the format of that? It's a subset of Ant's own language, with <taskdef>, <typesef>, <presetdef> and <macrodef> being the current set of allowed tasks.

There's one problem with antlibs right now, is that all this automatic stuff works if the new lib dirs are on the classpath. For ant on the command line, you can use the -lib option, or stick stuff in ~/.ant/lib. For IDEs you need to force it on. Otherwise you need to use a typedef command, something like:

<typdef uri="antlib://net/sf/antcontrib" classpath="../lib/**/*.jar" />

Ant 1.7 introduces a resource framework as well. According to the Ant project documentation,

Some of the core Ant tasks such as <copy/> are now able to process not only file system resources but also zip entries, tar entries, paths, ... Resource collections group resources, and can be further combined with operators such as union and intersection. This can be extended by custom resources and custom tasks using resources.

What have you found to be the biggest previous Ant limitations in your projects?

Topic: JavaScript's Language Features Previous Topic   Next Topic Topic: You Call it Coupling, I Call It Reality

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use