-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathKitPlugin.groovy
More file actions
161 lines (147 loc) · 7.6 KB
/
Copy pathKitPlugin.groovy
File metadata and controls
161 lines (147 loc) · 7.6 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package com.mparticle.kits
import com.android.build.gradle.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.plugins.signing.SigningExtension
class KitPlugin implements Plugin<Project> {
void apply(Project target) {
//formerly in kit-common.gradle
target.apply(plugin: 'com.android.library')
target.group = 'com.mparticle'
target.buildscript.repositories.add(target.repositories.mavenLocal())
target.buildscript.repositories.add(target.repositories.google())
target.buildscript.repositories.add(target.repositories.mavenCentral())
target.repositories.add(target.repositories.mavenLocal())
target.repositories.add(target.repositories.google())
target.repositories.add(target.repositories.mavenCentral())
target.configurations.create('deployerJars')
target.dependencies.add('api', 'com.mparticle:android-kit-base:' + target.version)
target.dependencies.add('testImplementation', 'junit:junit:4.13.2')
target.dependencies.add('testImplementation', 'org.mockito:mockito-core:1.10.19')
target.dependencies.add('testImplementation', 'androidx.annotation:annotation:[1.0.0,)')
target.dependencies.add('compileOnly', 'androidx.annotation:annotation:[1.0.0,)')
target.extensions.create("mparticle", MParticlePluginExtension)
LibraryExtension androidLib = target.android
androidLib.compileSdk 33
int dateInt = Integer.parseInt(new Date().format('yyyyMMdd'))
androidLib.defaultConfig.versionCode = dateInt
androidLib.defaultConfig.minSdk 16
androidLib.defaultConfig.targetSdk 33
androidLib.defaultConfig.buildConfigField("String", "VERSION_CODE", '\"' + dateInt + '\"')
androidLib.buildTypes.release.minifyEnabled false
androidLib.buildTypes.release.consumerProguardFiles 'consumer-proguard.pro'
androidLib.lintOptions.abortOnError true
androidLib.testOptions.unitTests.all { jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED']
jvmArgs += ['--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED']
jvmArgs += ['--add-opens', 'java.base/java.util=ALL-UNNAMED']
jvmArgs += ['--add-opens', 'java.base/java.text=ALL-UNNAMED']
jvmArgs += ['--add-opens', 'java.desktop/java.awt.font=ALL-UNNAMED']
jvmArgs += ['--add-opens', 'java.base/java.util.concurrent=ALL-UNNAMED'] }
//formerly in maven.gradle
target.apply(plugin: 'maven-publish')
target.apply(plugin: 'signing')
target.afterEvaluate {
PublishingExtension publishing = target.extensions.findByName('publishing')
publishing.publications.create("release", MavenPublication.class) {
groupId = "com.mparticle"
artifactId = target.name
version = target.version
if (target.plugins.findPlugin("com.android.library")) {
from target.components.release
} else {
from target.components.java
}
pom {
artifactId = target.name
packaging = 'aar'
name = target.name
if (target.mparticle.kitDescription == null) {
description = target.name + ' for the mParticle SDK'
} else {
description = target.mparticle.kitDescription
}
url = 'https://github.com/mparticle/mparticle-sdk-android'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'https://www.apache.org/license/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'mParticle'
name = 'mParticle Inc.'
email = 'developers@mparticle.com'
}
}
scm {
url = 'https://github.com/mparticle/mparticle-android-sdk'
connection = 'scm:git:https://github.com/mparticle/mparticle-android-sdk'
developerConnection = 'scm:git:git@github.com:mparticle/mparticle-android-sdk.git'
}
}
}
publishing.publications.register("debug", MavenPublication.class) {
groupId = "com.mparticle"
artifactId = target.name
version = target.version
if (target.plugins.findPlugin("com.android.library")) {
from target.components.debug
} else {
from target.components.java
}
pom {
artifactId = target.name
packaging = 'aar'
name = target.name
if (target.mparticle.kitDescription == null) {
description = target.name + ' for the mParticle SDK'
} else {
description = target.mparticle.kitDescription
}
url = 'https://github.com/mparticle/mparticle-sdk-android'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'https://www.apache.org/license/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'mParticle'
name = 'mParticle Inc.'
email = 'developers@mparticle.com'
}
}
scm {
url = 'https://github.com/mparticle/mparticle-android-sdk'
connection = 'scm:git:https://github.com/mparticle/mparticle-android-sdk'
developerConnection = 'scm:git:git@github.com:mparticle/mparticle-android-sdk.git'
}
}
}
publishing.repositories.maven {
credentials {
username System.getenv('sonatypeUsername') ?: ""
password System.getenv('sonatypePassword') ?: ""
}
url = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
}
def signingKey = System.getenv("mavenSigningKeyId")
def signingPassword = System.getenv("mavenSigningKeyPassword")
if (signingKey != null) {
target.extensions.add('signing.keyId', signingKey)
target.extensions.add('signing.password', signingPassword)
SigningExtension signing = new SigningExtension(target)
signing.required = { target.gradle.taskGraph.hasTask("publishReleasePublicationToMavenRepository") }
signing.useInMemoryPgpKeys(signingKey, signingPassword)
signing.sign publishing.publications.findByName("release")
}
}
//Publishing task aliases for simpler local development
target.task("publishLocal") { dependsOn "publishDebugPublicationToMavenLocal" }
target.task("publishReleaseLocal") { dependsOn "publishReleasePublicationToMavenLocal" }
}
}