Skip to content

Commit ce48fc8

Browse files
authored
added plugin for bintray (getsentry/sentry-android#129)
1 parent c880d1d commit ce48fc8

8 files changed

Lines changed: 311 additions & 22 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ git config core.hooksPath hooks/
1313
To run the build and tests:
1414

1515
```shell
16-
./gradlew build
16+
./gradlew clean build
1717
```
1818

1919
Build and tests are automatically run against branches and pull requests

build.gradle.kts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
44

55
plugins {
66
`java-library`
7-
id("com.diffplug.gradle.spotless") version Config.QualityPlugins.spotlessVersion apply true
7+
id(Config.QualityPlugins.spotless) version Config.QualityPlugins.spotlessVersion apply true
88
jacoco
99
}
1010

@@ -15,25 +15,28 @@ configure<JavaPluginConvention> {
1515

1616
buildscript {
1717
repositories {
18+
mavenLocal()
1819
google()
1920
jcenter()
2021
}
2122
dependencies {
2223
classpath(Config.BuildPlugins.androidGradle)
2324
classpath(kotlin(Config.BuildPlugins.kotlinGradlePlugin, version = Config.kotlinVersion))
2425
classpath(Config.QualityPlugins.errorpronePlugin)
25-
// classpath("io.sentry:sentry-android-gradle-plugin:$version") how to add sentry gradle plugin
26+
classpath(Config.Deploy.novodaBintray)
2627
}
2728
}
2829

2930
allprojects {
3031
repositories {
32+
mavenLocal()
3133
google()
3234
jcenter()
3335
mavenCentral()
3436
}
35-
group = "io.sentry"
36-
version = "2.0.0-SNAPSHOT"
37+
group = Config.Sentry.group
38+
version = Config.Sentry.version
39+
description = Config.Sentry.description
3740
tasks {
3841
withType<Test> {
3942
testLogging.showStandardStreams = true

buildSrc/src/main/java/Config.kt

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,47 @@ object Config {
4040

4141
object QualityPlugins {
4242
val jacocoVersion = "0.8.5"
43+
val spotless = "com.diffplug.gradle.spotless"
4344
val spotlessVersion = "3.25.0"
4445
val errorpronePlugin = "net.ltgt.gradle:gradle-errorprone-plugin:1.1.1"
4546
}
4647

4748
object Sentry {
4849
val SENTRY_CLIENT_NAME = "sentry.java.android"
50+
val group = "io.sentry"
51+
// TODO: change version to publish new version
52+
val version = "2.0.0-alpha04"
53+
val description = "SDK for sentry.io"
54+
// TODO: change version code to publish new version, follow the pattern of `version`
55+
val buildVersionCode = 20004
56+
val website = "https://sentry.io"
57+
val userOrg = "getsentry"
58+
val repoName = "sentry-android"
59+
val licence = "MIT"
60+
val issueTracker = "https://github.com/getsentry/sentry-android/issues"
61+
val repository = "https://github.com/getsentry/sentry-android"
62+
val devName = "Sentry Team and Contributers"
63+
val devEmail = "accounts@sentry.io"
64+
val devUser = "getsentry"
4965
}
5066

5167
object CompileOnly {
5268
private val nopenVersion = "1.0.1"
5369

54-
val annotations = "org.jetbrains:annotations:18.0.0"
55-
val noopen = "com.jakewharton.nopen:nopen-annotations:$nopenVersion"
56-
val noopenProne = "com.jakewharton.nopen:nopen-checker:$nopenVersion"
70+
val jetbrainsAnnotations = "org.jetbrains:annotations:18.0.0"
71+
val nopen = "com.jakewharton.nopen:nopen-annotations:$nopenVersion"
72+
val nopenChecker = "com.jakewharton.nopen:nopen-checker:$nopenVersion"
5773
val errorprone = "com.google.errorprone:error_prone_core:2.3.3"
58-
val errorProneJavac = "com.google.errorprone:javac:9+181-r4173-1"
74+
val errorProneJavac8 = "com.google.errorprone:javac:9+181-r4173-1"
75+
}
76+
77+
object Deploy {
78+
// TODO: change version to 0.9.2 to publish new version, which supports `sign` field
79+
// lets wait a bit for PR to be reviewed or we publish ourselves https://github.com/novoda/bintray-release/issues/301
80+
val novodaBintray = "com.novoda:bintray-release:0.9.1"
81+
val novodaBintrayId = "com.novoda.bintray-release"
82+
val dryRun = true // If set to true this will run everything but it won't upload the package to bintray. If false then it will upload normally.
83+
val override = true
84+
val sign = true
5985
}
6086
}

sentry-android-core/build.gradle.kts

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import org.jetbrains.kotlin.config.KotlinCompilerVersion
2+
import com.novoda.gradle.release.PublishExtension
23

34
plugins {
45
id("com.android.library")
56
kotlin("android")
67
jacoco
78
id("net.ltgt.errorprone")
9+
maven
10+
id(Config.Deploy.novodaBintrayId)
11+
signing
812
}
913

1014
android {
@@ -23,7 +27,8 @@ android {
2327

2428
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2529

26-
versionName = "$version"
30+
versionName = project.version.toString()
31+
versionCode = Config.Sentry.buildVersionCode
2732

2833
buildConfigField("String", "SENTRY_CLIENT_NAME", "\"${Config.Sentry.SENTRY_CLIENT_NAME}\"")
2934
}
@@ -74,11 +79,11 @@ dependencies {
7479
// libs
7580
implementation(Config.Libs.gson)
7681

77-
compileOnly(Config.CompileOnly.noopen)
78-
errorprone(Config.CompileOnly.noopenProne)
82+
compileOnly(Config.CompileOnly.nopen)
83+
errorprone(Config.CompileOnly.nopenChecker)
7984
errorprone(Config.CompileOnly.errorprone)
80-
errorproneJavac(Config.CompileOnly.errorProneJavac)
81-
compileOnly(Config.CompileOnly.annotations)
85+
errorproneJavac(Config.CompileOnly.errorProneJavac8)
86+
compileOnly(Config.CompileOnly.jetbrainsAnnotations)
8287

8388
// tests
8489
testImplementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))
@@ -89,3 +94,64 @@ dependencies {
8994
testImplementation(Config.TestLibs.androidxJunit)
9095
testImplementation(Config.TestLibs.mockitoKotlin)
9196
}
97+
98+
//TODO: move thse blocks to parent gradle file, DRY
99+
configure<PublishExtension> {
100+
userOrg = Config.Sentry.userOrg
101+
groupId = project.group.toString()
102+
publishVersion = project.version.toString()
103+
desc = Config.Sentry.description
104+
website = Config.Sentry.website
105+
repoName = Config.Sentry.repoName
106+
setLicences(Config.Sentry.licence)
107+
issueTracker = Config.Sentry.issueTracker
108+
repository = Config.Sentry.repository
109+
dryRun = Config.Deploy.dryRun
110+
override = Config.Deploy.override
111+
// TODO: uncomment it to publish new version, waiting PR to be merged
112+
// sign = Config.Deploy.sign
113+
artifactId = "sentry-android-core"
114+
}
115+
116+
gradle.taskGraph.whenReady {
117+
allTasks.find {
118+
it.path == ":${project.name}::generatePomFileForReleasePublication"
119+
}?.doLast {
120+
println("delete file: " + file("build/publications/release/pom-default.xml").delete())
121+
println("Overriding pom-file to make sure we can sync to maven central!")
122+
123+
maven.pom {
124+
withGroovyBuilder {
125+
"project" {
126+
"name"(project.name)
127+
"artifactId"("sentry-android-core")
128+
"packaging"("aar")
129+
"description"(Config.Sentry.description)
130+
"url"(Config.Sentry.website)
131+
"version"(project.version.toString())
132+
133+
"scm" {
134+
"url"(Config.Sentry.repository)
135+
"connection"(Config.Sentry.repository)
136+
"developerConnection"(Config.Sentry.repository)
137+
}
138+
139+
"licenses" {
140+
"license" {
141+
"name"(Config.Sentry.licence)
142+
}
143+
}
144+
145+
"developers" {
146+
"developer" {
147+
"id"(Config.Sentry.devUser)
148+
"name"(Config.Sentry.devName)
149+
"email"(Config.Sentry.devEmail)
150+
}
151+
}
152+
}
153+
}
154+
155+
}.writeTo("build/publications/release/pom-default.xml")
156+
}
157+
}

sentry-android-ndk/build.gradle.kts

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import com.novoda.gradle.release.PublishExtension
12

23
plugins {
34
id("com.android.library")
45
kotlin("android")
56
jacoco
7+
maven
8+
id(Config.Deploy.novodaBintrayId)
69
}
710

811
android {
@@ -21,7 +24,8 @@ android {
2124

2225
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2326

24-
versionName = "$version"
27+
versionName = project.version.toString()
28+
versionCode = Config.Sentry.buildVersionCode
2529

2630
externalNativeBuild {
2731
val sentryNativeSrc = if (File("${project.projectDir}/sentry-native-local").exists()) {
@@ -105,7 +109,7 @@ dependencies {
105109
api(project(":sentry-core"))
106110
api(project(":sentry-android-core"))
107111

108-
compileOnly(Config.CompileOnly.annotations)
112+
compileOnly(Config.CompileOnly.jetbrainsAnnotations)
109113
}
110114

111115
val initNative = tasks.register<Exec>("initNative") {
@@ -116,3 +120,63 @@ val initNative = tasks.register<Exec>("initNative") {
116120
tasks.named("preBuild") {
117121
dependsOn(initNative)
118122
}
123+
124+
//TODO: move thse blocks to parent gradle file, DRY
125+
configure<PublishExtension> {
126+
userOrg = Config.Sentry.userOrg
127+
groupId = project.group.toString()
128+
publishVersion = project.version.toString()
129+
desc = Config.Sentry.description
130+
website = Config.Sentry.website
131+
repoName = Config.Sentry.repoName
132+
setLicences(Config.Sentry.licence)
133+
issueTracker = Config.Sentry.issueTracker
134+
repository = Config.Sentry.repository
135+
dryRun = Config.Deploy.dryRun
136+
override = Config.Deploy.override
137+
// TODO: uncomment it to publish new version, waiting PR to be merged
138+
// sign = Config.Deploy.sign
139+
artifactId = "sentry-android-ndk"
140+
}
141+
142+
gradle.taskGraph.whenReady {
143+
allTasks.find {
144+
it.path == ":${project.name}::generatePomFileForReleasePublication"
145+
}?.doLast {
146+
println("delete file: " + file("build/publications/release/pom-default.xml").delete())
147+
println("Overriding pom-file to make sure we can sync to maven central!")
148+
149+
maven.pom {
150+
withGroovyBuilder {
151+
"project" {
152+
"name"(project.name)
153+
"artifactId"("sentry-android-ndk")
154+
"packaging"("aar")
155+
"description"(Config.Sentry.description)
156+
"url"(Config.Sentry.website)
157+
"version"(project.version.toString())
158+
159+
"scm" {
160+
"url"(Config.Sentry.repository)
161+
"connection"(Config.Sentry.repository)
162+
"developerConnection"(Config.Sentry.repository)
163+
}
164+
165+
"licenses" {
166+
"license" {
167+
"name"(Config.Sentry.licence)
168+
}
169+
}
170+
171+
"developers" {
172+
"developer" {
173+
"id"(Config.Sentry.devUser)
174+
"name"(Config.Sentry.devName)
175+
"email"(Config.Sentry.devEmail)
176+
}
177+
}
178+
}
179+
}
180+
}.writeTo("build/publications/release/pom-default.xml")
181+
}
182+
}

sentry-android/build.gradle.kts

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import com.novoda.gradle.release.PublishExtension
2+
13
plugins {
24
id("com.android.library")
5+
kotlin("android")
6+
maven
7+
id(Config.Deploy.novodaBintrayId)
38
}
49

510
android {
@@ -10,7 +15,8 @@ android {
1015
targetSdkVersion(Config.Android.targetSdkVersion)
1116
minSdkVersion(Config.Android.minSdkVersionNdk)
1217

13-
versionName = "$version"
18+
versionName = project.version.toString()
19+
versionCode = Config.Sentry.buildVersionCode
1420
}
1521

1622
compileOptions {
@@ -30,3 +36,63 @@ dependencies {
3036
api(project(":sentry-android-core"))
3137
api(project(":sentry-android-ndk"))
3238
}
39+
40+
//TODO: move thse blocks to parent gradle file, DRY
41+
configure<PublishExtension> {
42+
userOrg = Config.Sentry.userOrg
43+
groupId = project.group.toString()
44+
publishVersion = project.version.toString()
45+
desc = Config.Sentry.description
46+
website = Config.Sentry.website
47+
repoName = Config.Sentry.repoName
48+
setLicences(Config.Sentry.licence)
49+
issueTracker = Config.Sentry.issueTracker
50+
repository = Config.Sentry.repository
51+
dryRun = Config.Deploy.dryRun
52+
override = Config.Deploy.override
53+
// TODO: uncomment it to publish new version, waiting PR to be merged
54+
// sign = Config.Deploy.sign
55+
artifactId = "sentry-android"
56+
}
57+
58+
gradle.taskGraph.whenReady {
59+
allTasks.find {
60+
it.path == ":${project.name}::generatePomFileForReleasePublication"
61+
}?.doLast {
62+
println("delete file: " + file("build/publications/release/pom-default.xml").delete())
63+
println("Overriding pom-file to make sure we can sync to maven central!")
64+
65+
maven.pom {
66+
withGroovyBuilder {
67+
"project" {
68+
"name"(project.name)
69+
"artifactId"("sentry-android")
70+
"packaging"("aar")
71+
"description"(Config.Sentry.description)
72+
"url"(Config.Sentry.website)
73+
"version"(project.version.toString())
74+
75+
"scm" {
76+
"url"(Config.Sentry.repository)
77+
"connection"(Config.Sentry.repository)
78+
"developerConnection"(Config.Sentry.repository)
79+
}
80+
81+
"licenses" {
82+
"license" {
83+
"name"(Config.Sentry.licence)
84+
}
85+
}
86+
87+
"developers" {
88+
"developer" {
89+
"id"(Config.Sentry.devUser)
90+
"name"(Config.Sentry.devName)
91+
"email"(Config.Sentry.devEmail)
92+
}
93+
}
94+
}
95+
}
96+
}.writeTo("build/publications/release/pom-default.xml")
97+
}
98+
}

0 commit comments

Comments
 (0)