2017-08-28 93 views
1

我正尝试使用groovy创建我的项目的Ant Build。我越来越“抓住::jar在试图在groovy中使用AntBuilder创建jar时不支持”destdir“属性”错误。无法在groovy中使用AntBuilder创建jar

我的常规文件如下

build.groovy

包com.groovy.core.utils

进口groovy.util.AntBuilder

类构建{

def ant = new groovy.util.AntBuilder() 

def base_dir = "C:/Users/abc/neon/GroovyAntDateUtils/" 
def src_dir = base_dir + "src" 
def lib_dir = "C:/Jars/groovy-2.4.12/lib" 
def build_dir = base_dir + "com/groovy/core/utils" 
def dist_dir = base_dir + "dist" 
def file_name = "DateUtils" 
/*, includeantruntime : "false"*/ 

static void main(args){ 
    println("hi welcome to groovy"); 
    def b = new build() 
    b.jar() 
    //b.run(args) 


} 
    def classpath = ant.path { 
    fileset(dir: "${lib_dir}"){ 
    include(name: "*.jar") 
    } 
    pathelement(path: "${build_dir}") 
    } 


    def clean(){ 
    ant.delete(dir : "${build_dir}") 
    ant.delete(dir : "${dist_dir}") 
    } 

    def jar(){ 
    clean() 
    buildFolder() 
    ant.mkdir(dir: "${dist_dir}") 
    ant.jar(destdir: "${dist_dir}/${file_name}.jar", basedir: "${build_dir}") 
    } 

    def compile(){ 
     ant.javac(destdir: "${build_dir}", srcdir: "${src_dir}", classpath: "${classpath}") 
    } 

    def buildFolder(){ 
    ant.mkdir(dir: "${build_dir}") 
    compile() 
    } 

}

JDK - 1.8.0_121 蚂蚁蚂蚁&发射器 - 1.9.0 常规 - 2.4.12

回答