Skip to content

Commit

Permalink
Add publishing scripts and RELEASING.md file
Browse files Browse the repository at this point in the history
Fixes linkedin#22 by properly configuring transitive dependencies in
the published pom files.
  • Loading branch information
Drew Hannay committed Dec 5, 2016
1 parent e74716f commit 7ed304c
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Converted tests to run as Android tests rather than in Vogar
- Fixed monitorExit instructions being added as monitorEnter
- Updated Mockito dependency to version 1.10.19
- Fixed transitive dependency configuration [#22](https://github.com/linkedin/dexmaker/issues/22)

## Version 1.4 (2015-07-23

Expand Down
22 changes: 22 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Releasing
========

1. Change the version in `gradle.properties` to a non-SNAPSHOT version.
2. Update the `CHANGELOG.md` for the impending release.
3. Update the `README.md` with the new version.
4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version)
5. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version)
6. `./gradlew clean artifactory distributeBuild`
7. Update the `gradle.properties` to the next SNAPSHOT version.
8. `git commit -am "Prepare next development version."`
9. `git push && git push --tags`
10. Create a new release in the releases tab on GitHub


Prerequisites
-------------

Set the following environment variables:

* `ARTIFACTORY_USER` - LinkedIn Artifactory username for releasing to `com.linkedin.dexmaker`.
* `ARTIFACTORY_KEY` - LinkedIn Artifactory API key for releasing to `com.linkedin.dexmaker`.
33 changes: 33 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
import com.linkedin.gradle.DistributeTask

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.0"
}
}

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

allprojects {
group = GROUP_ID
}

artifactoryPublish.skip = true
artifactory {
contextUrl = 'https://linkedin.jfrog.io/linkedin'
publish {
repoKey = 'dexmaker'
username = System.getenv('ARTIFACTORY_USER') ?: ""
password = System.getenv('ARTIFACTORY_KEY') ?: ""

defaults {
publications 'lib'
}

publishArtifacts = true
}
clientConfig.setIncludeEnvVars(false)
}

task distributeBuild(type: DistributeTask) {
dependsOn ':artifactoryPublish', 'dexmaker:artifactoryPublish', 'dexmaker-mockito:artifactoryPublish'
}
19 changes: 19 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'groovy'
}

repositories {
mavenLocal()
jcenter()
}

dependencies {
compile gradleApi()
compile localGroovy()

compile 'org.ajoberstar:gradle-git:1.2.0'
compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.5.2'
compile('org.jfrog.buildinfo:build-info-extractor-gradle:4.4.0') {
exclude module: 'groovy-all'
}
}
39 changes: 39 additions & 0 deletions buildSrc/src/main/groovy/com/linked/gradle/DistributeTask.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.linkedin.gradle

import groovy.json.JsonBuilder
import org.apache.http.client.fluent.Request
import org.apache.http.entity.ContentType
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention

class DistributeTask extends DefaultTask {

@TaskAction
public void distributeBuild() {
ArtifactoryPluginConvention convention = project.convention.plugins.artifactory
def buildNumber = convention.clientConfig.info.buildNumber
def buildName = convention.clientConfig.info.buildName
def context = convention.clientConfig.publisher.contextUrl
def password = convention.clientConfig.publisher.password

def body = [
"publish" : "true",
"overrideExistingFiles": "false",
"async" : "true",
"targetRepo" : "maven",
"sourceRepos" : ["test-butler"],
"dryRun" : "false"
]

def bodyString = new JsonBuilder(body).toString()

def content = Request.Post("$context/api/build/distribute/$buildName/$buildNumber")
.bodyString(bodyString, ContentType.APPLICATION_JSON)
.addHeader("X-JFrog-Art-Api", password)
.execute()
.returnContent()

logger.lifecycle("Distribute Response: {}", content.asString())
}
}
67 changes: 67 additions & 0 deletions dexmaker-mockito/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,75 @@
apply plugin: 'java'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

version = VERSION_NAME

targetCompatibility = '1.7'
sourceCompatibility = '1.7'

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

// TODO: fix javadoc errors and then remove this
javadoc.failOnError = false

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

publishing {
publications {
lib(MavenPublication) {
from components.java

artifact sourcesJar
artifact javadocJar

pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
description = "Implementation of the Mockito API for use on the Android Dalvik VM"
url 'https://github.com/linkedin/dexmaker'
scm {
url 'https://github.com/linkedin/dexmaker'
connection 'scm:git:git://github.com/linkedin/dexmaker.git'
developerConnection 'https://github.com/linkedin/dexmaker.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/license/LICENSE-2.0.txt'
distribution 'repo'
}
}

developers {
developer {
id 'com.linkedin'
name 'LinkedIn Corp'
email ''
}
}

dependencies {
configurations.compile.allDependencies.each { ModuleDependency dp ->
dependency {
resolveStrategy = Closure.DELEGATE_ONLY
groupId dp.group
artifactId dp.name
version dp.version
}
}
}
}
}
}
}
}

repositories {
jcenter()
}
Expand Down
67 changes: 67 additions & 0 deletions dexmaker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,75 @@
apply plugin: 'java'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

version = VERSION_NAME

targetCompatibility = '1.7'
sourceCompatibility = '1.7'

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

// TODO: fix javadoc errors and then remove this
javadoc.failOnError = false

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

publishing {
publications {
lib(MavenPublication) {
from components.java

artifact sourcesJar
artifact javadocJar

pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
description = "A utility for doing compile or runtime code generation targeting Android's Dalvik VM"
url 'https://github.com/linkedin/dexmaker'
scm {
url 'https://github.com/linkedin/dexmaker'
connection 'scm:git:git://github.com/linkedin/dexmaker.git'
developerConnection 'https://github.com/linkedin/dexmaker.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/license/LICENSE-2.0.txt'
distribution 'repo'
}
}

developers {
developer {
id 'com.linkedin'
name 'LinkedIn Corp'
email ''
}
}

dependencies {
configurations.compile.allDependencies.each { ModuleDependency dp ->
dependency {
resolveStrategy = Closure.DELEGATE_ONLY
groupId dp.group
artifactId dp.name
version dp.version
}
}
}
}
}
}
}
}

repositories {
jcenter()
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ org.gradle.jvmargs=-Djava.awt.headless=true
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

GROUP_ID=com.linkedin.dexmaker
VERSION_NAME=1.5.0-SNAPSHOT

0 comments on commit 7ed304c

Please sign in to comment.