Skip to content

Commit

Permalink
Add publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
SerialVelocity committed Jan 30, 2017
1 parent cc6604f commit 2398425
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ apply plugin: 'com.palantir.baseline-idea'
apply plugin: 'nebula.dependency-recommender'
apply plugin: 'org.inferred.processors'

apply from: "${rootDir}/gradle/publish.gradle"

dependencyRecommendations {
strategy OverrideTransitives
propertiesFile file: project.rootProject.file('versions.props')
Expand Down
6 changes: 6 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ dependencies:
test:
override:
- ./scripts/time-cmd.sh ./gradlew --stacktrace --profile --parallel --continue check

deployment:
release:
tag: /[0-9]+\.[0-9]+\.[0-9]+/
commands:
- ./gradlew -i bintrayUpload
75 changes: 75 additions & 0 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.jfrog.artifactory'

task sourceJar(type: Jar) {
from sourceSets.main.allSource
classifier 'sources'
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
destinationDir rootProject.file("${buildDir}/libs")
}

tasks.build.dependsOn sourceJar, javadocJar

publishing {
publications {
bintray(MavenPublication) {
from components.java
artifact(sourceJar)
artifact(javadocJar)
version project.version.toString().replaceAll(/-.*/, '-SNAPSHOT')
}
}
}

artifactory {
publish {
contextUrl = 'https://oss.jfrog.org/artifactory'
repository {
repoKey = (project.version =~ /-/ ? 'oss-snapshot-local' : 'oss-release-local')
username = System.env.BINTRAY_USER
password = System.env.BINTRAY_KEY
maven = true
}
defaults {
publications (publishing.publications.bintray)
properties = ['git': project.version.toString()]
}
}
}
artifactoryPublish.dependsOn 'generatePomFileForBintrayPublication', 'build'

bintray {
user = System.env.BINTRAY_USERNAME
key = System.env.BINTRAY_PASSWORD

publish = true

pkg {
userOrg = 'palantir'
repo = 'releases'
name = 'docker-proxy-rule'
licenses = ['Apache-2.0']
publications = ['bintray']
}
}

bintrayUpload.onlyIf {
println "Attempting to publish with project version: " + project.version.toString()

def versionIsInCorrectFormat = project.version.toString() ==~ /\d+\.\d+\.\d+/

if (!versionIsInCorrectFormat) {
println "Cannot publish project with version " +
project.version.toString() +
"; it must be in form 'major.minor.patch'"
}

System.env.BINTRAY_USERNAME && System.env.BINTRAY_PASSWORD && versionIsInCorrectFormat
}

bintrayUpload.dependsOn 'generatePomFileForBintrayPublication', 'build'

0 comments on commit 2398425

Please sign in to comment.