forked from getsentry/sentry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
171 lines (148 loc) · 5.69 KB
/
build.gradle.kts
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
161
162
163
164
165
166
167
168
169
170
171
import com.diffplug.spotless.LineEnding
import com.vanniktech.maven.publish.MavenPublishPlugin
import com.vanniktech.maven.publish.MavenPublishPluginExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
`java-library`
id(Config.QualityPlugins.spotless) version Config.QualityPlugins.spotlessVersion apply true
jacoco
id(Config.QualityPlugins.detekt) version Config.QualityPlugins.detektVersion
`maven-publish`
}
buildscript {
repositories {
google()
}
dependencies {
classpath(Config.BuildPlugins.androidGradle)
classpath(kotlin(Config.BuildPlugins.kotlinGradlePlugin, version = Config.kotlinVersion))
classpath(Config.BuildPlugins.gradleMavenPublishPlugin)
// dokka is required by gradle-maven-publish-plugin.
classpath(Config.BuildPlugins.dokkaPlugin)
classpath(Config.QualityPlugins.errorpronePlugin)
classpath(Config.QualityPlugins.gradleVersionsPlugin)
// add classpath of androidNativeBundle
// com.ydq.android.gradle.build.tool:nativeBundle:{version}}
classpath(Config.NativePlugins.nativeBundlePlugin)
// add classpath of sentry android gradle plugin
// classpath("io.sentry:sentry-android-gradle-plugin:{version}")
classpath(Config.QualityPlugins.binaryCompatibilityValidatorPlugin)
}
}
apply(plugin = Config.QualityPlugins.binaryCompatibilityValidator)
allprojects {
repositories {
google()
mavenCentral()
}
group = Config.Sentry.group
version = properties[Config.Sentry.versionNameProp].toString()
description = Config.Sentry.description
tasks {
withType<Test> {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = TestExceptionFormat.FULL
testLogging.events = setOf(
TestLogEvent.SKIPPED,
TestLogEvent.PASSED,
TestLogEvent.FAILED)
dependsOn("cleanTest")
}
withType<JavaCompile> {
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing"))
}
}
}
subprojects {
if (!this.name.contains("sample") && this.name != "sentry-test-support") {
apply<DistributionPlugin>()
val sep = File.separator
configure<DistributionContainer> {
this.getByName("main").contents {
// non android modules
from("build${sep}libs")
from("build${sep}publications${sep}maven")
// android modules
from("build${sep}outputs${sep}aar")
from("build${sep}publications${sep}release")
}
}
val rootDir = this.project.rootProject.projectDir
val distDir = File("${rootDir}${sep}distributions")
// create dir if it does not exist
distDir.mkdirs()
tasks.named("distZip").configure {
this.dependsOn("publishToMavenLocal")
this.doLast {
val distributionFilePath = "${this.project.buildDir}${sep}distributions${sep}${this.project.name}-${this.project.version}.zip"
val file = File(distributionFilePath)
if (!file.exists()) throw IllegalStateException("Distribution file: $distributionFilePath does not exist")
if (file.length() == 0L) throw IllegalStateException("Distribution file: $distributionFilePath is empty")
val newFile = File("${distDir}${sep}${file.name}")
file.copyTo(newFile, overwrite = true)
UnzipUtils.unzip(newFile, distDir.path)
newFile.delete()
}
}
afterEvaluate {
apply<MavenPublishPlugin>()
configure<MavenPublishPluginExtension> {
// signing is done when uploading files to MC
// via gpg:sign-and-deploy-file (release.kts)
releaseSigningEnabled = false
}
// maven central info go to:
// ~/.gradle/gradle.properties
// maven central info:
// mavenCentralUsername=user name
// mavenCentralPassword=password
}
}
}
spotless {
lineEndings = LineEnding.UNIX
java {
target("**/*.java")
removeUnusedImports()
googleJavaFormat()
targetExclude("**/generated/**")
}
kotlin {
target("**/*.kt")
ktlint()
}
kotlinGradle {
target("**/*.kts")
ktlint()
}
}
tasks.named("build") {
dependsOn(":spotlessApply")
}
gradle.projectsEvaluated {
tasks.create("aggregateJavadocs", Javadoc::class.java) {
setDestinationDir(file("$buildDir/docs/javadoc"))
title = "${project.name} $version API"
val opts = options as StandardJavadocDocletOptions
opts.quiet()
opts.encoding = "UTF-8"
opts.memberLevel = JavadocMemberLevel.PROTECTED
opts.stylesheetFile(file("$projectDir/docs/stylesheet.css"))
opts.links = listOf(
"https://docs.oracle.com/javase/8/docs/api/",
"https://docs.spring.io/spring-framework/docs/current/javadoc-api/",
"https://docs.spring.io/spring-boot/docs/current/api/"
)
subprojects
.filter { !it.name.contains("sample") }
.forEach { proj ->
proj.tasks.withType<Javadoc>().forEach { javadocTask ->
source += javadocTask.source
classpath += javadocTask.classpath
excludes += javadocTask.excludes
includes += javadocTask.includes
}
}
}
}