我必须在我的ZIP包装中从存储库(比如本地)复制一个jar。我知道我们可以在依赖项中定义编译/运行时。但是,我无法在ZIP中使用它们。
我可以通过指定文件系统中的路径来复制jar文件。但是,我不知道如何从存储库中执行此操作。
以下是我的代码的样子:
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 ??
}
答案 0 :(得分:3)
假设您的依赖项属于运行时配置,即:
runtime 'org.slf4j:slf4j-log4j12:1.6.2'
你可以这样做:
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' }
}
添加名称为slf4j-log4j12
答案 1 :(得分:0)
要指定一个没有依赖关系的特定jar,请使用&#34; @ jar&#34;来限定它。例如。 &#34;公地BeanUtils的:公地BeanUtils的:1.6@jar" 有关如何使用自定义配置引用一组jar的示例,请参阅Download some dependencies and copy them to a local folder