This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
androidLib.gradle
126 lines (110 loc) · 4.02 KB
/
androidLib.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply from: "${project.rootDir}/version.gradle"
android {
compileSdkVersion parent.ext.compileSdkVersion
buildToolsVersion parent.ext.buildToolsVersion
defaultConfig {
minSdkVersion parent.ext.minSdkVersion
targetSdkVersion parent.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.pro'
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
// Reduce META-INF file conflicts
kotlinOptions.freeCompilerArgs += ['-module-name', "${parent.ext.groupId}.${project.getName()}"]
}
kotlinOptions {
jvmTarget = '1.8'
}
libraryVariants.all { variant ->
variant.outputs.all {
outputFileName = "${project.getName()}-${project.version}.aar"
}
}
}
afterEvaluate {
publishing {
publications {
lib(MavenPublication) {
from components.release
version = project.version
groupId parent.ext.groupId // from parent root.gradle ext
artifactId project.getName()
// Add sources too
afterEvaluate {
artifact(sourcesJar) {
classifier = 'sources'
extension = 'jar'
}
pom {
name = project.getName()
description = "${name} Android extensions"
url = 'https://github.com/tunjid/Android-Extensions'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/tunjid/tunjid/Android-Extensions/develop/license.txt'
}
}
developers {
developer {
id = 'tunjid'
name = 'Adetunji Dahunsi'
email = 'tjdah100@gmail.com'
}
}
scm {
connection = 'scm:git:github.com/tunjid/Android-Extensions.git'
developerConnection = 'scm:git:ssh://github.com/tunjid/Android-Extensions.git'
url = 'https://github.com/tunjid/Android-Extensions/tree/main'
}
}
}
}
}
repositories {
parent.ext.publishRepositories.each { repo ->
def props = (repo as ConfigObject).toProperties()
maven {
name = props['name']
url = props['publishUrl']
credentials {
username = props['credentials.username']
password = props['credentials.password']
}
}
}
}
}
signing {
if (parent.ext.publishInfo['signArtifacts']) {
def signingKey = parent.ext.publishInfo['signingKey']
def signingPassword = parent.ext.publishInfo['signingPassword']
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications
}
}
}
// Gradle task to generate sources after building a release aar
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease') {
task.dependsOn 'sourcesJar'
}
}