简体   繁体   中英

How to make a war file with ant in groovy?

I have following script which is aim to make a war file.

 def ant = new AntBuilder()
 ant.ant(antfile:'build.xml', dir:APP_ROOT, target:'war')

unfortunately I am getting following error when groovy try to run ant.ant(... line

Error executing script War: [Lorg/codehaus/groovy/runtime/callsite/CallSite;

 [exec] java.lang.NoClassDefFoundError: [Lorg/codehaus/groovy/runtime/callsite/CallSite;
 [exec]     at java.lang.Class.getDeclaredMethods0(Native Method)
 [exec]     at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
 [exec]     at java.lang.Class.getDeclaredMethods(Class.java:1791)
 [exec]     at org.codehaus.groovy.reflection.CachedClass$1.run(CachedClass.java:134)
 [exec]     at java.security.AccessController.doPrivileged(Native Method)
 [exec]     at org.codehaus.groovy.reflection.CachedClass.getMethods(CachedClass.java:131)

I was wondering is there an other way to make war file with antbuilder in groovy?

It seems the problem occurs if the groovy dependency of your grails is different than the groovy version installed on your local. I could reproduce the same issue when I tried to call grails war for a grails version dependent to Groovy 1.5 with Groovy 1.6 already installed. (BTW, Grails-1.0-RC3 is dependent to Groovy 1.5.0 and CallSite is introduced in Groovy-1.6.) When you call grails war , grails compiles its scripts by a wrong groovy version and fills the script cache.

To resolve this kind of issues, what I did is:

  1. Removed all the files in ~/.grails/YOUR_GRAILS_VERSION/scriptCache/ folder.
  2. Remove Groovy bin from path or use the correct groovy version in your local

Whenever you called, Grails will compile the scripts with the correct groovy version. I hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM