自定义Gradle任务无法解压战争

时间:2019-12-27 23:01:13

标签: gradle

无法展开ZIP'/Users/XXXXX/Documents/XXXX/XXXX/internal-tools/build/libs/internal-tools-195.0-SNAPSHOT.war'。

internal-tools.gradle

description = 'Internal Tools'

ext {
    grailsVersion = "3.3.3"
}
apply plugin: "org.grails.grails-web"
apply plugin: "war"
apply plugin:"org.grails.grails-gsp"

grails {
    grailsVersion = "3.3.3"
    //springLoadedVersion = '1.2.4.RELEASE'
}

configurations.all {
    // already provided by the JVM, Grails complains if classes show up twice in the classpath
    exclude group: 'xml-apis', module: 'xml-apis'

    exclude module: 'grails-plugin-log4j'

    //provided servlet container
    exclude group: 'javax.el', module: 'el-api'
    exclude group: 'org.glassfish.web', module: 'el-impl'
}

dependencies {
    compile project(':business-logic')
    //test(project(path: ':business-logic', configuration: 'testArtifacts'))

    def slf4jVersion = '1.7.2'
    compile "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
    compile "org.slf4j:jul-to-slf4j:${slf4jVersion}"
    compile "org.slf4j:slf4j-api:${slf4jVersion}"


    // We force a newer version of Ant to work around a bug in the Oracle JRE.  This can be removed when Grails upgrades Ant
    // See Ant 'Bug 54641' for more details
    runtime "org.apache.ant:ant:1.9.2"
    runtime "org.apache.ant:ant-junit:1.9.2"

    // Grails
    runtime "org.grails:grails-dependencies:$grailsVersion"

    compile "org.grails:grails-plugin-validation:3.3.3"
    compile 'org.grails.plugins:converters:4.0.0'

    compile 'org.grails.plugins:gorm-tools:6.1.11-v.12'

    compile "org.grails:grails-plugin-databinding"



    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-web-boot"





    compile "org.grails:grails-core"

    // Grails plugins
    compile "org.grails.plugins:hibernate4:4.3.6.1"
    compile "org.grails.plugins:tomcat:7.0.55"
    compile "org.grails.plugins:export:1.6"
    compile "org.grails.plugins:webflow:2.1.0"
    compile 'org.grails.plugins:logback:0.3.1'
    runtime "org.grails:grails-plugin-validation:$grailsVersion"

    //test "org.grails:grails-test:$grailsVersion"
   // test "org.grails:grails-plugin-testing:$grailsVersion"
   // test 'org.hamcrest:hamcrest-all:1.1'
    //test 'org.mockito:mockito-all:1.8.0'
   // test 'nekohtml:nekohtml:1.9.6.2'

   // bootstrap 'ch.qos.logback:logback-classic:1.1.3'
}

test {
    doFirst {
        tasks.getByPath(':dbTestCreate').ext.testDatabase.create()
    }

    dependsOn(':configProperties')
    jvmArgs '-XX:MaxMetaspaceSize=256m'
    systemProperty 'XXXX.conf.file', "$configOutputDir/XXXX_test.properties"
    String protocol = "file:"
    systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}

bootRun {
    dependsOn(':configProperties', ':dbValidate')
    jvmArgs '-XX:MaxMetaspaceSize=256m'
    systemProperty 'XXXX.conf.file', "$configOutputDir/XXXX_dev.properties"
    String protocol = "file:"
    systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}

war {
    String protocol = "file:"
    //systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}

// We re-package the war so it will include the extra GradleCM meta-info.
// We use a zip task rather than a war task because the war task adds extra files such as a second web.xml
task reWar(type: Zip, dependsOn: ['war']) {
    destinationDir = file("$buildDir/libs")

    extension = 'war'
    // HACK: the input needs to be wrapped in a closure so it is evaluated lazily. This is because the 'war' task output
    // file changes once the version is set
    from { zipTree(war.archivePath) }

    //
    // Build info file
    //
    from (rootProject.buildinfo.filedir) {
        include rootProject.buildinfo.filename
        into 'META-INF'
    }
}

artifacts {
    archives reWar
}

// Ensure tests are run for uploadArchives
uploadArchives.dependsOn('check')

buildscript {
    repositories {
        maven { url "https://repo1.maven.org/maven2/" }
        maven { url "https://dl.bintray.com/jfrog/jfrog-jars/" }
        maven { url "https://repo.gradle.org/gradle/libs-releases-local/" }
        //maven { url "https://repo.spring.io/plugins-release/" }
        maven { url "https://repo.maven.apache.org/maven2/" }
        maven { url "https://repo.grails.org/grails/core" }
        mavenCentral()
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:3.3.3"
        classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+"
        classpath "org.gradle:gradle-tooling-api:5.+"
        classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.+"
        //classpath "org.grails.plugins:hibernate4:${gormVersion-".RELEASE"}"
    }
}

我正在尝试创建一个自定义gradle任务,该任务将使用一些额外的元信息来重新包装战争。 现在我得到的错误是archive is not a ZIP archive

我正在使用gradle 3.5,并且现在已经与该版本结婚。

有人知道如何在gradle中解压缩战争文件吗?我是新手,是从其他人那里继承下来的。

0 个答案:

没有答案