0

我正在使用gradle 发布插件将工件推送到工件。我想在发布之前运行以下任务 - 构建,组装

文档说构建任务是在发布任务期间执行的。

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'
        }
    }
}

当我跑步时

4

1 回答 1

0

您可以在插件配置闭包中配置构建任务。

release {
    buildTasks = ['build']
}
于 2016-08-22T20:24:26.033 回答