Skip to content

Commit

Permalink
centralize sdk version ints and version/group names into project-leve…
Browse files Browse the repository at this point in the history
…l build.gradle, isolate bintray deploy gradle code into deploy.gradle
  • Loading branch information
dwillmc committed Jun 28, 2018
1 parent 8a70d02 commit fcaa787
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 117 deletions.
15 changes: 5 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,22 @@ plugins {
}

android {
compileSdkVersion = 28
buildToolsVersion = '28.0.0'
compileSdkVersion = versions.compileSdk
defaultConfig {
applicationId 'com.camerakit.app'
minSdkVersion 15
targetSdkVersion 28
versionName '1.0.0'
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
versionName version
versionCode 1
}
}

repositories {
google()
jcenter()
}

dependencies {
implementation project(':camerakit')
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.50'
implementation 'com.camerakit:jpegkit:0.2.0-alpha1'
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'de.hdodenhof:circleimageview:2.2.0'
}
}
25 changes: 24 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,28 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.50'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1'
}
}
}

subprojects { project ->
group = 'com.camerakit'
version = '1.0.0-beta2'

repositories {
google()
jcenter()
}

ext {
versions = [
minSdk : 15,
targetSdk : 28,
compileSdk : 28,
]
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
110 changes: 4 additions & 106 deletions camerakit/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'com.jfrog.bintray' version '1.7.3'
id 'com.github.dcendents.android-maven' version '1.5'
}

android {
compileSdkVersion 28
compileSdkVersion versions.compileSdk
defaultConfig {
minSdkVersion 15
minSdkVersion versions.minSdk
}
testOptions {
unitTests.returnDefaultValues = true
}
}

repositories {
google()
jcenter()
}

dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.50'
implementation 'com.android.support:support-annotations:27.1.1'
Expand All @@ -28,110 +22,14 @@ dependencies {
testImplementation 'org.mockito:mockito-core:1.10.19'
}

ext.getBintrayUser = { ->
if (System.getenv('BINTRAY_USER')) {
return System.getenv('BINTRAY_USER')
}

if (rootProject.file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
return properties.getProperty('bintray.user')
}
}

ext.getBintrayKey = { ->
if (System.getenv('BINTRAY_KEY')) {
return System.getenv('BINTRAY_KEY')
}

if (rootProject.file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
return properties.getProperty('bintray.key')
}
}

task cleanDeployment {
doLast {
logger.lifecycle('Deployment: Cleaning...')
logger.lifecycle('Deleting: ' + project.buildDir)
delete project.buildDir
}
}

task buildDeployment {
shouldRunAfter(cleanDeployment)
finalizedBy assemble

doFirst {
android.variantFilter { variant ->
if (variant.buildType.name == 'debug') {
variant.setIgnore(true)
}
}
}
}

task deploySnapshot {
shouldRunAfter(buildDeployment)

dependsOn cleanDeployment
dependsOn buildDeployment
finalizedBy bintrayUpload

doLast {
version = version + '-Snapshot'
bintrayUpload.setVersionName(bintrayUpload.getVersionName() + '-Snapshot')
bintrayUpload.setUserOrg('camerakit')
bintrayUpload.setRepoName('camerakit-android-snapshots')
bintrayUpload.setOverride(true)
bintrayUpload.setPublish(true)

logger.lifecycle('Deploying version ' + bintrayUpload.getVersionName() + ' in ' + bintrayUpload.getRepoName())
}
}

task deployRelease {
shouldRunAfter(buildDeployment)

dependsOn cleanDeployment
dependsOn buildDeployment
finalizedBy bintrayUpload

doLast {
bintrayUpload.setUserOrg('camerakit')
bintrayUpload.setRepoName('camerakit-android')

logger.lifecycle('Deploying version ' + bintrayUpload.getVersionName() + ' in ' + bintrayUpload.getRepoName())
}
}

group = 'com.camerakit'
version = '1.0.0-beta2'

install {
repositories.mavenInstaller {
pom.project {
name 'camerakit-android'
groupId 'com.camerakit'
groupId project.group
artifactId 'camerakit'
packaging 'aar'
}
}
}

bintray {
user = getBintrayUser()
key = getBintrayKey()
configurations = ['archives']
pkg {
name = 'camerakit-android'
vcsUrl = 'https://github.com/CameraKit/camerakit-android.git'
licenses = ['MIT']
version {
name = project.version
released = new Date()
}
}
}
apply from : 'deploy.gradle'
98 changes: 98 additions & 0 deletions camerakit/deploy.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
def getBintrayUser() {
if (System.getenv('BINTRAY_USER')) {
return System.getenv('BINTRAY_USER')
}

if (rootProject.file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
return properties.getProperty('bintray.user')
}
}

def getBintrayKey() {
if (System.getenv('BINTRAY_KEY')) {
return System.getenv('BINTRAY_KEY')
}

if (rootProject.file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
return properties.getProperty('bintray.key')
}
}

apply plugin: 'com.jfrog.bintray'

bintray {
user = getBintrayUser()
key = getBintrayKey()
configurations = ['archives']
pkg {
repo = 'camerakit-android'
name = 'camerakit-android'
userOrg = 'camerakit'
vcsUrl = 'https://github.com/CameraKit/camerakit-android.git'
licenses = ['MIT']

version {
name = project.version
released = new Date()
}
}
}

task cleanForDeployment {
doLast {
logger.lifecycle('Deployment: Cleaning...')
logger.lifecycle('Deleting: ' + project.buildDir)
delete project.buildDir
}
}

task buildForDeployment {
shouldRunAfter(cleanForDeployment)
finalizedBy assemble

doFirst {
android.variantFilter { variant ->
if (variant.buildType.name == 'debug') {
variant.setIgnore(true)
}
}
}
}

task deploySnapshot {
shouldRunAfter(buildForDeployment)

dependsOn cleanForDeployment
dependsOn buildForDeployment
finalizedBy bintrayUpload

doLast {
version = version + '-Snapshot'
bintrayUpload.setVersionName(bintrayUpload.getVersionName() + '-Snapshot')
bintrayUpload.setUserOrg('camerakit')
bintrayUpload.setRepoName('camerakit-android-snapshots')
bintrayUpload.setOverride(true)
bintrayUpload.setPublish(true)

logger.lifecycle('Deploying version ' + bintrayUpload.getVersionName() + ' in ' + bintrayUpload.getRepoName())
}
}

task deployRelease {
shouldRunAfter(buildForDeployment)

dependsOn cleanForDeployment
dependsOn buildForDeployment
finalizedBy bintrayUpload

doLast {
bintrayUpload.setUserOrg('camerakit')
bintrayUpload.setRepoName('camerakit-android')

logger.lifecycle('Deploying version ' + bintrayUpload.getVersionName() + ' in ' + bintrayUpload.getRepoName())
}
}

0 comments on commit fcaa787

Please sign in to comment.