我想在gradle中创建zip / war / jar工件,该工件只包含少数几个类,并且仅包含必需的依赖项
我有一个简单的zip任务,如下所示:
task myZip(type: Zip) {
from sourceSets.main.output
include 'com/mypackage/*'
archiveName 'myzip.zip'
}
现在我要包括一些编译依赖项 示例build.gradle骨架:
apply plugin : 'java'
apply plugin : 'eclipse'
apply plugin: 'maven-publish'
repositories{
}
configurations
{
}
dependencies
{
compile <dependency1>
compile <dependency2>
compile <dependency3>
...
compile <dependency20>
myzipjar <dependency3>
myzipjar <dependency6>
myzipjar <dependency13>
}
然后执行我的zip任务:
task myZip(type: Zip) {
from sourceSets.main.output
include 'com/mypackage/*'
**into 'lib'
from configurations.myzipjar**
archiveName 'myzip.zip'
}
答案 0 :(得分:0)
解决方案取决于所需的选择标准。
您可以将Configuration
视为常规FileCollection
,从中可以查询create procedure usp_UpatePriv
@screen tblScreen Readonly
as
declare @username nvarchar(50)
declare @prev bit
declare @idscreen bigint
declare privlange cursor for
(select username, idScren, Prev from @screen)
open privlange
fetch next from privlange into @username, @idscreen, @prev
while @@FETCH_STATUS = 0
begin
update tblScreenPriv
set Prev = @prev
where Username = @username and idScreen = @idscreen
fetch next from privlange into @username, @idscreen, @prev
end
close privlange;
deallocate privlange;
实例:
File
...或者您可以使用其getResolvedConfiguration()
方法通过发起Dependency
实例来过滤分辨率结果:
configurations.compile.findAll
{
it.name.startsWith == "required-prefix" // it is an instance of File
}
或者也许您应该考虑使用单独的配置,该配置将同时包含在configurations.compile.resolvedConfiguration.getFiles
{
it.group == "target-group" // it is an instance of Dependency
}
配置和您的zip任务中:
compile
P。 S.从Gradle 3.4开始,configurations
{
zippableCompile
compile.extendsFrom zippableCompile
}
dependencies
{
zippableCompile <...>
}
配置已被弃用,请改用compile
。