I have a lib.zip
and myApp.war
that I need to publish to artifactory
.
Initially, I started with artifactoryPublish
, hoping that when I run
./gradlew clean release
, the war and zip gets published to artifactory. But I observed only that the war gets uploaded. I had to add the include this additional to my build.gradle to get both zip and war upload
afterReleaseBuild.dependsOn uploadArchives
. why do I need both?
If I remove afterReleaseBuild.dependsOn artifactoryPublish
, nothing gets uploaded/published to artifactory.
Here is my 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