从reps下载jar,然后unzip test jar,再执行junit测试

gradle脚本如下:

dependencies {
    compile 'com.test.attachment:attachment:1.0-SNAPSHOT'
    compile group:'org.eclipse.emf.commonj', name:'sdo', version:'2.3+', ext:'jar'
    compile group:'org.eclipse.emf.ecore', name:'sdo', version:'2.3+', ext:'jar'
    
}

task unzip(type: Copy) {
    def zipPath = project.configurations.compile.find {it.name.startsWith("attachment")}
    println zipPath
    def zipFile = file(zipPath)
    def outputDir = file("${buildDir}/unpacked/dist")
    
    from zipTree(zipFile)
    into outputDir

    doLast {
        copy {
            from "${buildDir}/unpacked/dist/config.properties"
            into "."
        }
    }
}

sourceSets {
    test {
        java {
            srcDirs = ["${buildDir}/unpacked/dist"]
        }
    }
}

 

执行gradle unzip 从reps下载测试包attachment.jar以及依赖的包,然后unzip attachment.jar到build/unpackaged/dist目录,最后把执行junit时需要用到的config.properties拷贝到根目录。

执行gradle test 会执行unzip后的目录下的junit test,在build目录下生成junit report。

 

参考:https://stackoverflow.com/questions/23023069/gradle-download-and-unzip-file-from-url?newreg=3ae627393e9b47e09b97ddbd99785e8d

posted on 2017-09-11 15:10  熊gg  阅读(151)  评论(0编辑  收藏  举报