Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.regex.Pattern
- apply plugin: 'com.android.library'
- buildscript {
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
- }
- }
- repositories {
- jcenter()
- }
- apply plugin: 'com.jfrog.bintray'
- apply plugin: 'com.github.dcendents.android-maven'
- apply plugin: 'maven'
- apply plugin: 'maven-publish'
- //apply plugin: 'java'
- group = '<group_id>'
- version = versionName
- def siteUrl = '<siteUrl>' // Homepage URL of the library
- def gitUrl = '<gitUrl>' // Git repository URL
- android {
- compileSdkVersion 24
- buildToolsVersion "23.0.3"
- defaultConfig {
- minSdkVersion 16
- targetSdkVersion 23
- versionCode versionCode
- versionName versionName
- renderscriptTargetApi 19
- renderscriptSupportModeEnabled true
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
- publishing {
- publications {
- AndroidUtilities(MavenPublication) {
- //from components.java
- groupId group
- artifactId 'androidutilities'
- version versionName
- }
- }
- }
- task incrementVersionCode << {
- println(":incrementVersionCode - Incrementing Version Code...")
- def manifestFile = file("src/main/AndroidManifest.xml")
- def propertiesFile = file("gradle.properties")
- def patternVersionCode = Pattern.compile("versionCode=\"?(\\d+)\"?")
- def manifestText = manifestFile.getText()
- def propertiesText = propertiesFile.getText()
- def manifestMatcherVersionCode = patternVersionCode.matcher(manifestText)
- def propertiesMatcherVersionCode = patternVersionCode.matcher(propertiesText)
- def mVersionCode = 0
- if (propertiesMatcherVersionCode.find()) {
- mVersionCode = Integer.parseInt(propertiesMatcherVersionCode.group(1))
- }
- def mNextVersionCode = mVersionCode + 1
- def manifestContent = manifestMatcherVersionCode.replaceAll("versionName=\"" + mNextVersionName + "\"")
- def propertiesContent = propertiesMatcherVersionCode.replaceAll("versionName=" + mNextVersionName)
- println(":incrementVersionCode - current versionCode=" + mVersionCode);
- println(":incrementVersionCode - next versionCode=" + mNextVersionCode);
- manifestFile.write(manifestContent)
- propertiesFile.write(propertiesContent)
- }
- task incrementVersionName << {
- println(":incrementVersionName - Incrementing Version Name...")
- def manifestFile = file("src/main/AndroidManifest.xml")
- def propertiesFile = file("gradle.properties")
- def patternVersionNumber = Pattern.compile("versionName=\"?(\\d+)\\.(\\d+)\\.(\\d+)\"?")
- def manifestText = manifestFile.getText()
- def propertiesText = propertiesFile.getText()
- def manifestMatcherVersionNumber = patternVersionNumber.matcher(manifestText)
- def propertiesMatcherVersionNumber = patternVersionNumber.matcher(propertiesText)
- def majorVersion = 0
- def minorVersion = 0
- def pointVersion = 0
- if (propertiesMatcherVersionNumber.find()) {
- majorVersion = Integer.parseInt(propertiesMatcherVersionNumber.group(1))
- minorVersion = Integer.parseInt(propertiesMatcherVersionNumber.group(2))
- pointVersion = Integer.parseInt(propertiesMatcherVersionNumber.group(3))
- }
- def mVersionName = majorVersion + "." + minorVersion + "." + pointVersion
- def mNextVersionName = majorVersion + "." + minorVersion + "." + (pointVersion + 1)
- def manifestContent = manifestMatcherVersionNumber.replaceAll("versionName=\"" + mNextVersionName + "\"")
- def propertiesContent = propertiesMatcherVersionNumber.replaceAll("versionName=" + mNextVersionName)
- println(":incrementVersionName - current versionName=" + mVersionName);
- println(":incrementVersionName - new versionName=" + mNextVersionName);
- manifestFile.write(manifestContent)
- propertiesFile.write(propertiesContent)
- }
- task release << {
- println(":release - Build and Version Increment")
- }
- task debug << {
- println(":debug - Build")
- }
- tasks.whenTaskAdded { task ->
- //println("- " + task.name)
- if (task.name == 'bundleRelease'){
- task.dependsOn 'generateDebugBuildConfig'
- }
- if (task.name == 'generateDebugBuildConfig'){
- //task.dependsOn 'incrementVersionName'
- }
- if (task.name == 'generatePomFileForAndroidUtilitiesPublication'){
- //task.dependsOn 'generateDebugBuildConfig'
- //task.dependsOn 'incrementVersionName'
- }
- }
- dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.google.api-client:google-api-client-android:1.18.0-rc' exclude module: 'httpclient'
- compile 'com.android.support:appcompat-v7:24.0.0-beta1'
- compile 'com.android.support:recyclerview-v7:24.0.0-beta1'
- compile 'com.squareup.okhttp3:okhttp:3.2.0'
- compile 'com.github.franmontiel:PersistentCookieJar:v0.9.3'
- compile 'com.github.bumptech.glide:glide:3.7.0'
- compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
- compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
- compile 'de.greenrobot:greendao:1.3.7'
- compile 'de.greenrobot:eventbus:2.4.0'
- compile 'org.lucasr.twowayview:twowayview:0.1.4'
- compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
- compile 'com.baoyz.swipemenulistview:library:1.3.0'
- compile 'com.eftimoff:android-viewpager-transformers:1.0.1@aar'
- compile 'net.danlew:android.joda:2.9.3'
- compile 'com.jeremyfeinstein.slidingmenu:library:1.3@aar'
- compile 'com.google.android.gms:play-services:9.4.0'
- compile 'com.google.android.gms:play-services-ads:9.4.0'
- compile 'com.google.android.gms:play-services-auth:9.4.0'
- compile 'org.jsoup:jsoup:1.9.2'
- compile "com.google.firebase:firebase-messaging:9.0.0"
- }
- install {
- repositories.mavenInstaller {
- // This generates POM.xml with proper parameters
- pom {
- project {
- packaging 'aar'
- // Add your description here
- name 'Android-Utilities' // TODO
- description = 'Collection of common Android Utilities to help create new project' // TODO
- url siteUrl
- // Set your license
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- }
- }
- developers {
- developer {
- id '<userid>' // TODO
- name '<name>' // TODO
- email '<email>' // TODO
- }
- }
- scm {
- connection gitUrl
- developerConnection gitUrl
- url siteUrl
- }
- }
- }
- }
- }
- task sourcesJar(type: Jar) {
- from android.sourceSets.main.java.srcDirs
- classifier = 'sources'
- }
- task javadoc(type: Javadoc) {
- source = android.sourceSets.main.java.srcDirs
- classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
- }
- task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
- }
- artifacts {
- archives javadocJar
- archives sourcesJar
- }
- Properties project_properties = new Properties()
- project_properties.load(project.rootProject.file('local.properties').newDataInputStream())
- bintray {
- user = project_properties.getProperty('bintray.user');
- key = project_properties.getProperty('bintray.apikey');
- //publications = ['AndroidUtilities'] //When uploading configuration files
- // - OR -
- configurations = ['archives'] //When uploading configuration files
- // - AND/OR -
- //filesSpec { //When uploading any arbitrary files ('filesSpec' is a standard Gradle CopySpec)
- // from 'arbitrary-files'
- // into 'standalone_files/level1'
- // rename '(.+)\\.(.+)', '$1-suffix.$2'
- //}
- dryRun = false //[Default: false] Whether to run this as dry-run, without deploying
- publish = true //[Default: false] Whether version should be auto published after an upload
- override = false //[Default: false] Whether to override version artifacts already published
- //Package configuration. The plugin will use the repo and name properties to check if the package already exists. In that case, there's no need to configure the other package properties (like userOrg, desc, etc).
- pkg {
- repo = 'androidutilities'
- name = 'Android-Utilities'
- userOrg = user
- licenses = ['Apache-2.0']
- websiteUrl = siteUrl
- issueTrackerUrl = siteUrl + '/issues'
- vcsUrl = gitUrl
- labels = ['android', 'utilities']
- publicDownloadNumbers = true
- attributes= ['a': ['ay1', 'ay2'], 'b': ['bee'], c: 'cee'] //Optional package-level attributes
- githubRepo = '<repo>' //Optional Github repository
- githubReleaseNotesFile = 'README.md' //Optional Github readme file
- dryRun = false //[Default: false] Whether to run this as dry-run, without deploying
- publish = true //[Default: false] Whether version should be auto published after an upload
- override = true //[Default: false] Whether to override version artifacts already published
- version {
- name = versionName //Bintray logical version name
- desc = versionName //Optional - Version-specific description'
- released = new java.util.Date() //Optional - Date of the version release. 2 possible values: date in the format of 'yyyy-MM-dd'T'HH:mm:ss.SSSZZ' OR a java.util.Date instance
- vcsTag = versionName
- attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin'] //Optional version-level attributes
- //Optional configuration for GPG signing
- gpg {
- sign = true //Determines whether to GPG sign the files. The default is false
- passphrase = '<passphrase>' //Optional. The passphrase for GPG signing'
- }
- //Optional configuration for Maven Central sync of the version
- mavenCentralSync {
- sync = true //[Default: true] Determines whether to sync the version to Maven Central.
- user = '<user>' //OSS user token: mandatory
- password = '<passphrase>' //OSS user password: mandatory
- close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
- }
- }
- }
- }
- task wrapper(type: Wrapper) {
- gradleVersion = '2.4'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement