On Jan 24, 2012, at 5:19 PM, Christopher Tiwald wrote:
> Using Buildr.ant I get the following error -- "BuildException : import only 
> allowed as a top-level task." 

Ended up getting around this by writing the catalina-tasks taskdefs into the 
module directly, and setting a CATALINA_HOME global variable. Works like a 
charm, but I'm still curious about the original question if anyone has any 
thoughts. Code below.

Buildr.ant("myProject") do |antProject|                                         
         
  antProject.taskdef(:resource => "org/apache/catalina/ant/catalina.tasks") { 
|antProject|   
    antProject.classpath { |antProject|                                         
    
      antProject.fileset(:file => "#{CATALINA_HOME}/bin/tomcat-juli.jar")       
    
      antProject.fileset(:file => "#{CATALINA_HOME}/lib/tomcat-api.jar")        
    
      antProject.fileset(:file => "#{CATALINA_HOME}/lib/tomcat-util.jar")
      antProject.fileset(:file => "#{CATALINA_HOME}/lib/jasper.jar")            
    
      antProject.fileset(:file => "#{CATALINA_HOME}/lib/jasper-el.jar")         
    
      antProject.fileset(:file => "#{CATALINA_HOME}/lib/el-api.jar")
      antProject.fileset(:file => "#{CATALINA_HOME}/lib/jsp-api.jar")           
    
      antProject.fileset(:file => "#{CATALINA_HOME}/lib/servlet-api.jar")       
    
      antProject.fileset(:file => "#{CATALINA_HOME}/lib/catalina-ant.jar")
   } 
  }
  #other tasks
end


--
Christopher Tiwald

Reliability Architect
Salsa Labs, Inc.


> Apologies if this is the wrong forum for Antwrap questions, but as I'm 
> attempting to run it using Buildr.ant, I figured it was worth a shot.
> 
> I'm attempting to write an extension that uses Tomcat's 
> $CATLALINA_BASE/bin/catalina-tasks.xml. In a normal build.xml, I'd write an 
> include task, which would look something like the following:
> 
> <project name="myProject" basedir="." />
>     <import file="${tomcat.home}/bin/catalina-tasks.xml"/>
>     …
> </project>
> 
> Tracing back through the atoulme-antwrap source, it looks like the issue 
> arises in ant_task.rb, line 56 in v0.7.2:
> 
> element.setOwningTarget(ApacheAnt::Target.new())
> 
> If I'm reading this correctly, it seems like every instance of AntTask is 
> given an owner Target, which then causes top-level tasks like `import` to 
> fail. I've got a few workarounds, specified at 
> http://markmail.org/message/bwxpucyzpv7rhwh5. All the same, I'm curious if 
> there is a way to run top-level tasks in Buildr.ant I'm just missing.
> 
> Thanks,
> 
> Christopher Tiwald
> 
> Reliability Architect
> Salsa Labs, Inc.

Reply via email to