1

我有一个lib.zipmyApp.war我需要发布到artifactory. 最初,我从 开始artifactoryPublish,希望当我运行时 ./gradlew clean release,战争和 zip 被发布到工件。但我只观察到战争被上传了。我必须将这个附加添加到我的 build.gradle 中才能同时上传 zip 和 war

afterReleaseBuild.dependsOn uploadArchives. 为什么我两者都需要?

如果我删除afterReleaseBuild.dependsOn artifactoryPublish,则不会上传/发布到工件。

这是我的 build.gradle

buildscript {
    repositories {
        jcenter()
        mavenLocal()
    }
    dependencies {
        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'

apply plugin: "java"
apply plugin: "maven"
apply plugin: "war"

group 'com.example.services'

sourceCompatibility = '1.7'
targetCompatibility = '1.7'

war {
    archiveName = "myApp.war"
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.11'
}

task buildAssets(type: Zip) {

    baseName = 'lib'
    version = null
    from('libs/') {  
            include '**/*.jar'
}

assemble.dependsOn(buildAssets)

artifacts {
    archives buildAssets
}

release {
    git {
        requireBranch = '' 
    }
}

afterReleaseBuild.dependsOn uploadArchives
afterReleaseBuild.dependsOn artifactoryPublish

artifactory {
    contextUrl = "http://myartifatoryurl"
    publish {
        repository {
            repoKey = 'libs'
            maven = true
            username = "foo"
            password = "bar"
        }
        defaults {
            publishConfigs ('archives')
        }
    }
    resolve {
        repository {
            repoKey = 'releases'
            maven = true
            username = 'foo'
            password = 'bar'
        }
    }
}

//rest of dependencies here 
4

0 回答 0