Gradle压缩包装:从存储库复制Jar文件 [英] Gradle zip packaging: copy Jar file from repository

查看:159
本文介绍了Gradle压缩包装:从存储库复制Jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在我的ZIP包装中从存储库(比如本地)复制一个jar。我明白我们可以在依赖关系中定义编译/运行时。但是,我无法在ZIP中使用它们。

我可以通过在文件系统中指定路径来复制jar文件。但是,我不知道如何从存储库中执行它。



以下是我的代码的样子:



< pre $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $'$($ (src / main),{
includeprjName / css / **
includeprjName / images / **
includeprjName / javascript / **
包含prjName / WEB-INF / **
排除prjName / WEB-INF / web.xml
})

from file(< Absolute -path-to-jar-file-in-my-filesystem>)//这工作
//如何从存储库复制同一个jar文件?


解决方案

假设您的依赖关系在运行时配置:即:

  runtime'org.slf4j:slf4j-log4j12:1.6.2'



你可以这样做: {
baseName'xyz'
from fileTree(src / main),{
includeprjName / css / **
includeprjName / images / **
includeprjName / javascript / **
includeprjName / WEB-INF / **
excludeprjName / WEB-INF / web.xml
}

from configurations.runtime.files {it.name =='slf4j-log4j12'}
}
code>

使用名称 slf4j-log4j12 添加为依赖项下载的所有jar文件,

I have to copy a jar from the repository (say local) in my ZIP packaging. I understand that we can define compile/runtime in dependencies. However, I could not use it them in ZIP.

I'm able to copy the jar file by specifying the path in my filesystem. However, I don't know how to do it from repository.

Here is how my code looks like:

task createZipFile (type: Zip, dependsOn: [...]) {

    baseName 'xyz'

    from(fileTree("src/main"), {
        include "prjName/css/**"
        include "prjName/images/**"
        include "prjName/javascript/**"
        include "prjName/WEB-INF/**"
        exclude "prjName/WEB-INF/web.xml"
    })

    from file("<Absolute-path-to-jar-file-in-my-filesystem>") //this works
    // how to copy the same jar file from repository ??
}

解决方案

Assuming your dependencies are in the runtime configuration ie:

runtime 'org.slf4j:slf4j-log4j12:1.6.2'

you can do:

task createZipFile( type: Zip, dependsOn: [...] ) {
    baseName 'xyz'
    from fileTree("src/main"), {
        include "prjName/css/**"
        include "prjName/images/**"
        include "prjName/javascript/**"
        include "prjName/WEB-INF/**"
        exclude "prjName/WEB-INF/web.xml"
    }

    from configurations.runtime.files { it.name == 'slf4j-log4j12' }
}

To add all jars downloaded for the dependency with the name slf4j-log4j12

这篇关于Gradle压缩包装:从存储库复制Jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆