我正在使用gradle脚本,我有两个独立的认知列表和其他依赖项列表.
清单1:
cognos:a:10.1.1
cognos:b:10.1.1
cognos:c:10.1.1
cognos:d:10.1.1
com:axis:2.0.3
com:webroot:5.0.3
和清单2:
cognos:a:10.2.2
cognos:b:10.2.2
cognos:c:10.2.2
cognos:d:10.2.2
traven:nt:10.5.0
traven:txtx:5.2.1
我需要首先使用list 1依赖项编译我的源代码,然后列出2个依赖项,并在artifactory中使用以下名称发布工件.
具有列表1和列表2依赖项的工件
abc-1.0.0-cognos10.1.1
abc-1.0.0-cognos10.2.2
我可以用build.gradle来做,但我可以在两个单独的build.gradle脚本中完成.我不知道如何在signle build.gradle脚本中实现这个目标.有人知道如何在单个构建中实现它.gradle
apply plugin: 'java'
version = '1.0'
sourceCompatibility = 1.7
targetCompatibility = 1.7
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'com.mkyong.DateUtils'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
//Get dependencies from Maven central repository
repositories {
mavenCentral()
}
//Project dependencies
dependencies {
compile 'cognos:a:10.1.1
compile 'cognos:b:10.1.1'
compile 'cognos:c:10.1.1'
compile 'cognos:d:10.1.1'
compile 'traven:nt:10.5.0'
compile 'traven:txtx:5.2.1'
}
解决方法:
在build.gradle中,将cognos和app version替换为参数:
version = "1.0.0-cognos${cognosVersion}"
sourceCompatibility = 1.7
targetCompatibility = 1.7
...
dependencies {
compile "cognos:a:${cognosVersion}"
compile "cognos:b:${cognosVersion}"
compile "cognos:c:${cognosVersion}"
compile "cognos:d:${cognosVersion}"
}
然后你可以手动运行几次:
gradle build -PcognosVersion=xxxx
如果您想自动执行此操作,则可以编写第二个gradle驱动程序脚本release.gradle:
defaultTasks 'performRelease'
task performRelease() << {
['10.1.1','10.2.2'].each{
def tempTask = tasks.create(name: "execute_$it", type: GradleBuild)
tempTask.buildFile='build.gradle'
tempTask.tasks = ['build']
tempTask.startParameter.projectProperties = [cognosVersion: it]
tempTask.execute()
}
}
您可以执行以下操作:gradle -b release.gradle
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。