From 28e23d2c43ab167a59ec76deeb0be8cfcdc5b9b8 Mon Sep 17 00:00:00 2001 From: Adib Faramarzi Date: Tue, 28 Aug 2018 09:49:05 +0430 Subject: [PATCH] Add new publish system for maven - clean up versioning. --- .gitignore | 2 +- build.gradle | 8 ++- gradle/wrapper/gradle-wrapper.properties | 4 +- livedataextensions/build.gradle | 80 ++++-------------------- publish.gradle | 31 +++++++++ versions.gradle | 27 ++++++++ 6 files changed, 78 insertions(+), 74 deletions(-) create mode 100644 publish.gradle create mode 100644 versions.gradle diff --git a/.gitignore b/.gitignore index 5edb4ee..16444f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ *.iml .gradle /local.properties -/.idea/libraries +/.idea /.idea/modules.xml /.idea/workspace.xml .DS_Store diff --git a/build.gradle b/build.gradle index 6e40aef..36eda68 100644 --- a/build.gradle +++ b/build.gradle @@ -6,11 +6,12 @@ buildscript { google() jcenter() } - ext.kotlin_version = '1.2.31' + ext.kotlin_version = '1.2.61' dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.android.tools.build:gradle:3.1.0' - + classpath 'com.android.tools.build:gradle:3.3.0-alpha06' + classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5' + // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -24,6 +25,7 @@ allprojects { } } +subprojects { project -> apply from: rootProject.file('versions.gradle') } task clean(type: Delete) { delete rootProject.buildDir } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8b6e82a..6088507 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Apr 01 19:13:46 IRDT 2018 +#Tue Aug 28 07:38:07 IRDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip diff --git a/livedataextensions/build.gradle b/livedataextensions/build.gradle index a20e0a7..a9572f3 100644 --- a/livedataextensions/build.gradle +++ b/livedataextensions/build.gradle @@ -1,23 +1,18 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' - +apply from: rootProject.file('publish.gradle') android { compileSdkVersion 27 - - - defaultConfig { - minSdkVersion 16 - targetSdkVersion 27 - versionCode 1 - versionName "1.0" + minSdkVersion versionNumbers.minSdk + targetSdkVersion versionNumbers.targetSdk + versionCode versionNumbers.versionCode + versionName versionNumbers.versionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testApplicationId "com.test.foo" // Specifies the fully-qualified class name of the test instrumentation runner. testInstrumentationRunner "android.test.InstrumentationTestRunner" - - } sourceSets { @@ -39,73 +34,22 @@ android { afterEvaluate { android.sourceSets.all { sourceSet -> - if (!sourceSet.name.startsWith("test")) - { + if (!sourceSet.name.startsWith("test")) { sourceSet.kotlin.setSrcDirs([]) } } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - testImplementation 'junit:junit:4.12' - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - - testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" - implementation 'android.arch.lifecycle:extensions:1.1.1' - testImplementation 'org.mockito:mockito-core:2.8.9' - testImplementation("android.arch.core:core-testing:1.1.1", { + testImplementation libraries.junit + implementation libraries.kotlinSTDLib + testImplementation libraries.kotlinTestJunit + implementation libraries.archLifeCycle + testImplementation libraries.mockito + testImplementation(libraries.archCoreTesting, { exclude group: 'com.android.support', module: 'support-compat' exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-core-utils' }) } - -apply plugin: 'maven' - -group = 'com.snakydesign.livedataextensions' -version = '1.0' - -ext { - //Specify your maven repository url here - repositoryUrl = 'ftp://your.maven.repository.com/maven2' - //Or you can use 'file:\\\\C:\\Temp' or 'maven-temp' for a local maven repository -} -configurations { - deployerJars -} -task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - destinationDir = file("../javadoc/") - failOnError false -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -//Creating sources with comments -task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.srcDirs -} - -//Put the androidSources and javadoc to the artifacts -artifacts { - archives androidSourcesJar - archives javadocJar -} - -uploadArchives { - repositories { - mavenDeployer { - configuration = configurations.deployerJars - repository(url: repositoryUrl) { - //if your repository needs authentication - authentication(userName: "username", password: "password") - } - } - } -} \ No newline at end of file diff --git a/publish.gradle b/publish.gradle new file mode 100644 index 0000000..7e52a90 --- /dev/null +++ b/publish.gradle @@ -0,0 +1,31 @@ +apply plugin: "com.jfrog.artifactory" +apply plugin: 'maven-publish' +def artifactoryUrl = "https://api.bintray.com/maven/adibfara/lives/" +apply from: rootProject.file('versions.gradle') + +publishing.publications { + aar(MavenPublication) { + groupId "com.snakydesign.livedataextensions" + version = versionNumbers.versionName + artifactId = 'lives' + artifact("$buildDir/outputs/aar/$archivesBaseName-release.aar") + } +} + +artifactory { + contextUrl = artifactoryUrl + publish { + repository { + Properties properties = new Properties() + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + repoKey = 'lives/' + username = properties.getProperty('bintray.user') + password = properties.getProperty('bintray.apiKey') + } + + defaults { + publishArtifacts = true + publications('aar') + } + } +} diff --git a/versions.gradle b/versions.gradle new file mode 100644 index 0000000..bbc3b70 --- /dev/null +++ b/versions.gradle @@ -0,0 +1,27 @@ +ext.versionNumbers = [ + gradle : '3.3.0-alpha06', + jfrog : '4.7.5', + + kotlin : '1.2.60', + mockito : '2.8.9', + arch : '1.1.1', + junit : '4.12', + + minSdk : 16, + targetSdk : 26, + versionCode: 2, + versionName: '1.1', +] + +ext.libraries = [ + gradle : "com.android.tools.build:gradle:$versionNumbers.gradle", + jfrog : "org.jfrog.buildinfo:build-info-extractor-gradle:$versionNumbers.jfrog", + kotlinGradle : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versionNumbers.kotlin", + + kotlinSTDLib : "org.jetbrains.kotlin:kotlin-stdlib:$versionNumbers.kotlin", + kotlinTestJunit : "org.jetbrains.kotlin:kotlin-test-junit:$versionNumbers.kotlin", + mockito : "org.mockito:mockito-core:$versionNumbers.mockito", + archLifeCycle : "android.arch.lifecycle:extensions:$versionNumbers.arch", + archCoreTesting : "android.arch.core:core-testing:$versionNumbers.arch", + junit : "junit:junit:$versionNumbers.junit", +] \ No newline at end of file