Skip to content

Commit de26152

Browse files
committed
Added new publish config to mavenCentral
1 parent b9cca38 commit de26152

5 files changed

Lines changed: 177 additions & 47 deletions

File tree

app/build.gradle

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
23

34
android {
4-
compileSdkVersion 28
5+
compileSdkVersion rootProject.ext.compileSdkVersion
56
defaultConfig {
67
applicationId "com.github.nikartm.stripedprocessbutton"
7-
minSdkVersion 21
8-
targetSdkVersion 28
8+
minSdkVersion rootProject.ext.minSdkVersion
9+
targetSdkVersion rootProject.ext.targetSdkVersion
910
versionCode 1
1011
versionName "1.0"
11-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1213
}
14+
1315
buildTypes {
1416
release {
1517
minifyEnabled false
1618
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1719
}
1820
}
21+
22+
kotlinOptions {
23+
jvmTarget = rootProject.ext.javaVersion
24+
}
25+
1926
compileOptions {
20-
targetCompatibility 1.8
21-
sourceCompatibility 1.8
27+
targetCompatibility rootProject.ext.javaVersion
28+
sourceCompatibility rootProject.ext.javaVersion
2229
}
2330
}
2431

2532
dependencies {
2633
implementation fileTree(dir: 'libs', include: ['*.jar'])
27-
testImplementation 'junit:junit:4.12'
28-
androidTestImplementation 'androidx.test:runner:1.1.1'
29-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
30-
31-
implementation 'androidx.appcompat:appcompat:1.0.2'
32-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
33-
34+
testImplementation 'junit:junit:4.13.2'
35+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
36+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
37+
implementation 'androidx.appcompat:appcompat:1.5.1'
38+
implementation rootProject.ext.dependencies.coreKtx
3439
implementation project(':support')
3540
}

build.gradle

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,44 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
4+
ext.kotlin_version = '1.7.20'
5+
56
repositories {
7+
maven { url "https://plugins.gradle.org/m2/" }
68
google()
7-
jcenter()
9+
mavenCentral()
810
}
911
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.4.0'
11-
classpath 'com.novoda:bintray-release:0.9'
12-
12+
classpath 'com.android.tools.build:gradle:7.3.1'
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
1315

1416
// NOTE: Do not place your application dependencies here; they belong
1517
// in the individual module build.gradle files
1618
}
1719
}
1820

21+
apply plugin: 'io.github.gradle-nexus.publish-plugin'
22+
apply from: "${rootDir}/scripts/publish-root.gradle"
23+
1924
allprojects {
2025
repositories {
2126
google()
22-
jcenter()
27+
mavenCentral()
2328
}
2429
}
2530

2631
task clean(type: Delete) {
2732
delete rootProject.buildDir
2833
}
34+
35+
ext {
36+
compileSdkVersion = 33
37+
minSdkVersion = 21
38+
targetSdkVersion = compileSdkVersion
39+
40+
javaVersion = 11
41+
42+
dependencies = [:]
43+
dependencies.coreKtx = 'androidx.core:core-ktx:1.9.0'
44+
}

scripts/publish-module.gradle

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
4+
task androidSourcesJar(type: Jar) {
5+
archiveClassifier.set('sources')
6+
if (project.plugins.findPlugin("com.android.library")) {
7+
from android.sourceSets.main.java.srcDirs
8+
} else {
9+
from sourceSets.main.java.srcDirs
10+
}
11+
}
12+
13+
artifacts {
14+
archives androidSourcesJar
15+
}
16+
17+
group = PUBLISH_GROUP_ID
18+
version = PUBLISH_VERSION
19+
20+
afterEvaluate {
21+
publishing {
22+
publications {
23+
release(MavenPublication) {
24+
25+
groupId PUBLISH_GROUP_ID
26+
artifactId PUBLISH_ARTIFACT_ID
27+
version PUBLISH_VERSION
28+
29+
if (project.plugins.findPlugin("com.android.library")) {
30+
from components.release
31+
} else {
32+
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
33+
}
34+
35+
artifact androidSourcesJar
36+
37+
pom {
38+
name = PUBLISH_ARTIFACT_ID
39+
description = PUBLISH_DESCRIPTION
40+
url = PUBLISH_URL
41+
42+
licenses {
43+
license {
44+
name = PUBLISH_LICENSE_NAME
45+
url = PUBLISH_LICENSE_URL
46+
}
47+
}
48+
49+
developers {
50+
developer {
51+
id = PUBLISH_DEVELOPER_ID
52+
name = PUBLISH_DEVELOPER_NAME
53+
email = PUBLISH_DEVELOPER_EMAIL
54+
}
55+
}
56+
57+
scm {
58+
connection = PUBLISH_SCM_CONNECTION
59+
developerConnection = PUBLISH_SCM_DEVELOPER_CONNECTION
60+
url = PUBLISH_SCM_URL
61+
}
62+
}
63+
}
64+
}
65+
}
66+
}
67+
68+
ext["signing.keyId"] = rootProject.ext["signing.keyId"]
69+
ext["signing.password"] = rootProject.ext["signing.password"]
70+
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]
71+
72+
signing {
73+
sign publishing.publications
74+
}

scripts/publish-root.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
ext["signing.keyId"] = ''
2+
ext["signing.password"] = ''
3+
ext["signing.secretKeyRingFile"] = ''
4+
ext["ossrhUsername"] = ''
5+
ext["ossrhPassword"] = ''
6+
ext["sonatypeStagingProfileId"] = ''
7+
8+
File secretPropsFile = project.rootProject.file('local.properties')
9+
if (secretPropsFile.exists()) {
10+
Properties p = new Properties()
11+
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
12+
p.each { name, value -> ext[name] = value }
13+
} else {
14+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
15+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
16+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
17+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
18+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
19+
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
20+
}
21+
22+
nexusPublishing {
23+
repositories {
24+
sonatype {
25+
stagingProfileId = sonatypeStagingProfileId
26+
username = ossrhUsername
27+
password = ossrhPassword
28+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
29+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
30+
}
31+
}
32+
}

support/build.gradle

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
apply plugin: 'com.android.library'
2-
apply plugin: 'com.novoda.bintray-release'
2+
apply plugin: 'kotlin-android'
33

4-
android {
5-
compileSdkVersion 28
4+
ext {
5+
PUBLISH_GROUP_ID = 'io.github.nikartm'
6+
PUBLISH_VERSION = '3.0.0'
7+
PUBLISH_ARTIFACT_ID = 'process-button'
8+
PUBLISH_DESCRIPTION = 'Android library. Animated striped button to show loading process.'
9+
PUBLISH_URL = 'https://github.com/nikartm/StripedProcessButton'
10+
PUBLISH_LICENSE_NAME = 'The Apache Software License, Version 2.0'
11+
PUBLISH_LICENSE_URL = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
12+
PUBLISH_DEVELOPER_ID = 'ivanv'
13+
PUBLISH_DEVELOPER_NAME = 'Ivan Vodyasov'
14+
PUBLISH_DEVELOPER_EMAIL = 'jvissun@gmail.com'
15+
PUBLISH_SCM_CONNECTION = 'scm:git:github.com/nikartm/StripedProcessButton.git'
16+
PUBLISH_SCM_DEVELOPER_CONNECTION = 'scm:git:ssh://github.com/nikartm/StripedProcessButton.git'
17+
PUBLISH_SCM_URL = 'https://github.com/nikartm/StripedProcessButton/tree/master'
18+
}
19+
20+
apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
621

22+
android {
23+
compileSdkVersion rootProject.ext.compileSdkVersion
724
defaultConfig {
8-
minSdkVersion 21
9-
targetSdkVersion 28
10-
versionCode 1
11-
versionName "2.0.0"
25+
minSdkVersion rootProject.ext.minSdkVersion
26+
targetSdkVersion rootProject.ext.targetSdkVersion
1227
}
1328

1429
buildTypes {
@@ -17,32 +32,20 @@ android {
1732
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1833
}
1934
}
20-
}
2135

22-
allprojects {
23-
tasks.withType(Javadoc).all { enabled = false }
24-
}
25-
if (JavaVersion.current().isJava8Compatible()) {
26-
allprojects {
27-
tasks.withType(Javadoc) {
28-
options.addStringOption('Xdoclint:none', '-quiet')
29-
}
36+
kotlinOptions {
37+
jvmTarget = rootProject.ext.javaVersion
3038
}
31-
}
3239

33-
publish {
34-
userOrg = 'nikart'
35-
groupId = 'com.github.nikartm'
36-
artifactId = 'process-button'
37-
publishVersion = android.defaultConfig.versionName
38-
desc = 'Android library. Animated striped button to show loading process.'
39-
licences = ['Apache-2.0']
40-
uploadName='StripedProcessButton'
41-
website = 'https://github.com/nikartm/StripedProcessButton'
40+
compileOptions {
41+
targetCompatibility rootProject.ext.javaVersion
42+
sourceCompatibility rootProject.ext.javaVersion
43+
}
4244
}
4345

4446
dependencies {
4547
implementation fileTree(dir: 'libs', include: ['*.jar'])
46-
implementation 'androidx.appcompat:appcompat:1.0.2'
47-
testImplementation 'junit:junit:4.12'
48+
testImplementation 'junit:junit:4.13.2'
49+
implementation 'androidx.appcompat:appcompat:1.5.1'
50+
implementation rootProject.ext.dependencies.coreKtx
4851
}

0 commit comments

Comments
 (0)