我正在使用gradle release plugin将工件推送到神器。 我想在发布之前运行以下任务 - build,assemble
文档说明在发布任务期间执行构建任务。
1)我想要包含app.war和assets.zip(下面配置)来发布。我该怎么做?
2)当./gradlew clean release
出现错误
Cannot cast object 'task ':assemble'' with class 'org.gradle.api.DefaultTask_Decorated' to class 'groovy.lang.Closure'
配置有什么问题 - release.dependsOn assemble
?
3)如果我注释掉那一行并执行,我看到执行的发布任务提示我输入版本号。当我退出进程(ctrl + C)时,我没有看到创建的构建目录。发布任务在构建后执行。然后我希望看到一个构建目录。为什么我看不到它?
以下是build.gradle
buildscript {
repositories {
jcenter()
mavenLocal()
maven {
url "http://internal-repo"
}
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:+"
classpath 'net.researchgate:gradle-release:2.+'
}
}
allprojects {
apply plugin: "com.jfrog.artifactory"
apply plugin: 'net.researchgate.release'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "http://internal-external-repo" }
}
apply plugin: "java"
apply plugin: "maven"
apply plugin: "war"
apply plugin: 'tomcat'
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "jacoco"
group 'com.mycompany.services'
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
war {
archiveName = "app.war"
}
task wrapper(type: Wrapper) {
gradleVersion = '2.11'
}
task copyJars(dependsOn: classes, type: Jar) {
//
}
assemble.dependsOn copyJars
task copyAssets(type: Copy) {
//
}
compileJava.dependsOn copyAssets
task makeZips(type: Zip) {
baseName = 'dependencies'
version = null
from('lib/') {
//
}
doLast {
copy {
from "$buildDir/distributions/dependencies.zip"
into "$project.rootProject.rootDir/apps/"
}
}
}
assemble.dependsOn(makeZips)
task archiveZip (type: Zip, dependsOn: makeZip) {
from "$project.rootProject.rootDir/apps/dependencies.zip"
}
artifacts {
archives archiveZip
}
release {
git {
versionPropertyFile = 'version.txt'
}
}
afterReleaseBuild.dependsOn artifactoryPublish
release.dependsOn build
release.dependsOn assemble
dependencies {
//
}
artifactory {
contextUrl = "http:/my-interal-repo"
publish {
repository {
repoKey = 'local'
maven = true
username = "foo"
password = "bar"
}
defaults {
publishConfigs ('archives')
}
}
resolve {
repository {
repoKey = 'release'
maven = true
username = 'foo'
password = 'bar'
}
}
}
当我跑
时答案 0 :(得分:0)
您可以在插件配置闭包中配置构建任务。
release {
buildTasks = ['build']
}