简体   繁体   English

无法在Groovy中使用AntBuilder创建jar

[英]Unable to create jar using AntBuilder in groovy

I am trying to create Ant Build of my project using groovy. 我正在尝试使用groovy创建我的项目的Ant Build。 I am getting "Caught: : jar doesn't support the "destdir" attribute" error while trying to create jar using AntBuilder in groovy. 尝试在Groovy中使用AntBuilder创建jar时,出现“ Caught::jar不支持“ destdir”属性”错误。

My groovy file is as follows 我的常规文件如下

build.groovy 构建

package com.groovy.core.utils 软件包com.groovy.core.utils

import groovy.util.AntBuilder 导入groovy.util.AntBuilder

class build { 类构建{

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 ant & ant launcher - 1.9.0 groovy - 2.4.12 JDK-1.8.0_121蚂蚁和蚂蚁发射器-1.9.0 Groovy-2.4.12

there is no destdir attribute for jar task jar任务没有destdir属性

https://ant.apache.org/manual/Tasks/jar.html https://ant.apache.org/manual/Tasks/jar.html

probably you want destfile ? 可能您想要destfile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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