1
1
import com.diffplug.spotless.LineEnding
2
+ import com.vanniktech.maven.publish.JavaLibrary
3
+ import com.vanniktech.maven.publish.JavadocJar
2
4
import com.vanniktech.maven.publish.MavenPublishBaseExtension
3
- import com.vanniktech.maven.publish.MavenPublishPlugin
4
- import com.vanniktech.maven.publish.MavenPublishPluginExtension
5
5
import groovy.util.Node
6
6
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
7
7
import kotlinx.kover.gradle.plugin.dsl.KoverReportExtension
@@ -17,6 +17,7 @@ plugins {
17
17
id(Config .QualityPlugins .binaryCompatibilityValidator) version Config .QualityPlugins .binaryCompatibilityValidatorVersion
18
18
id(Config .QualityPlugins .jacocoAndroid) version Config .QualityPlugins .jacocoAndroidVersion apply false
19
19
id(Config .QualityPlugins .kover) version Config .QualityPlugins .koverVersion apply false
20
+ id(Config .BuildPlugins .gradleMavenPublishPlugin) version Config .BuildPlugins .gradleMavenPublishPluginVersion apply false
20
21
}
21
22
22
23
buildscript {
@@ -26,7 +27,6 @@ buildscript {
26
27
dependencies {
27
28
classpath(Config .BuildPlugins .androidGradle)
28
29
classpath(kotlin(Config .BuildPlugins .kotlinGradlePlugin, version = Config .kotlinVersion))
29
- classpath(Config .BuildPlugins .gradleMavenPublishPlugin)
30
30
// dokka is required by gradle-maven-publish-plugin.
31
31
classpath(Config .BuildPlugins .dokkaPlugin)
32
32
classpath(Config .QualityPlugins .errorpronePlugin)
@@ -95,7 +95,7 @@ allprojects {
95
95
TestLogEvent .PASSED ,
96
96
TestLogEvent .FAILED
97
97
)
98
- maxParallelForks = Runtime .getRuntime().availableProcessors() / 4
98
+ maxParallelForks = 1
99
99
100
100
// Cap JVM args per test
101
101
minHeapSize = " 256m"
@@ -140,7 +140,7 @@ subprojects {
140
140
androidReports(" release" ) {
141
141
xml {
142
142
// Change the report file name so the Codecov Github action can find it
143
- setReportFile(file(" $buildDir / reports/kover/report.xml" ))
143
+ setReportFile(project.layout.buildDirectory. file(" reports/kover/report.xml" ).get().asFile )
144
144
}
145
145
}
146
146
}
@@ -157,6 +157,7 @@ subprojects {
157
157
158
158
if (! this .name.contains(" sample" ) && ! this .name.contains(" integration-tests" ) && this .name != " sentry-test-support" && this .name != " sentry-compose-helper" ) {
159
159
apply<DistributionPlugin >()
160
+ apply< com.vanniktech.maven.publish.MavenPublishPlugin > ()
160
161
161
162
val sep = File .separator
162
163
@@ -179,22 +180,30 @@ subprojects {
179
180
tasks.named(" distZip" ).configure {
180
181
this .dependsOn(" publishToMavenLocal" )
181
182
this .doLast {
182
- val distributionFilePath =
183
- " ${this .project.buildDir}${sep} distributions${sep}${this .project.name} -${this .project.version} .zip"
184
- val file = File (distributionFilePath)
185
- if (! file.exists()) throw IllegalStateException (" Distribution file: $distributionFilePath does not exist" )
186
- if (file.length() == 0L ) throw IllegalStateException (" Distribution file: $distributionFilePath is empty" )
183
+ val file = this .project.layout.buildDirectory.file(" distributions${sep}${this .project.name} -${this .project.version} .zip" ).get().asFile
184
+ if (! file.exists()) throw IllegalStateException (" Distribution file: ${file.absolutePath} does not exist" )
185
+ if (file.length() == 0L ) throw IllegalStateException (" Distribution file: ${file.absolutePath} is empty" )
187
186
}
188
187
}
189
188
190
- afterEvaluate {
191
- apply<MavenPublishPlugin >()
189
+ plugins.withId(" java-library" ) {
190
+ configure<MavenPublishBaseExtension > {
191
+ // we have to disable javadoc publication in maven-publish plugin as it's not
192
+ // including it in the .module file https://github.com/vanniktech/gradle-maven-publish-plugin/issues/861
193
+ // and do it ourselves
194
+ configure(JavaLibrary (JavadocJar .None (), sourcesJar = true ))
195
+ }
196
+
197
+ configure<JavaPluginExtension > {
198
+ withJavadocJar()
192
199
193
- configure<MavenPublishPluginExtension > {
194
- // signing is done when uploading files to MC
195
- // via gpg:sign-and-deploy-file (release.kts)
196
- releaseSigningEnabled = false
200
+ sourceCompatibility = JavaVersion .VERSION_1_8
201
+ targetCompatibility = JavaVersion .VERSION_1_8
197
202
}
203
+ }
204
+
205
+ afterEvaluate {
206
+ apply<MavenPublishPlugin >()
198
207
199
208
@Suppress(" UnstableApiUsage" )
200
209
configure<MavenPublishBaseExtension > {
@@ -206,7 +215,7 @@ subprojects {
206
215
repositories {
207
216
maven {
208
217
name = " unityMaven"
209
- url = file(" ${rootProject.buildDir} / unityMaven" ).toURI()
218
+ url = rootProject.layout.buildDirectory. file(" unityMaven" ).get().asFile .toURI()
210
219
}
211
220
}
212
221
}
@@ -241,48 +250,46 @@ spotless {
241
250
}
242
251
}
243
252
244
- gradle.projectsEvaluated {
245
- tasks.create(" aggregateJavadocs" , Javadoc ::class .java) {
246
- setDestinationDir(file(" $buildDir /docs/javadoc" ))
247
- title = " ${project.name} $version API"
248
- val opts = options as StandardJavadocDocletOptions
249
- opts.quiet()
250
- opts.encoding = " UTF-8"
251
- opts.memberLevel = JavadocMemberLevel .PROTECTED
252
- opts.stylesheetFile(file(" $projectDir /docs/stylesheet.css" ))
253
- opts.links = listOf (
254
- " https://docs.oracle.com/javase/8/docs/api/" ,
255
- " https://docs.spring.io/spring-framework/docs/current/javadoc-api/" ,
256
- " https://docs.spring.io/spring-boot/docs/current/api/"
257
- )
258
- subprojects
259
- .filter { ! it.name.contains(" sample" ) && ! it.name.contains(" integration-tests" ) }
260
- .forEach { proj ->
261
- proj.tasks.withType<Javadoc >().forEach { javadocTask ->
262
- source + = javadocTask.source
263
- classpath + = javadocTask.classpath
264
- excludes + = javadocTask.excludes
265
- includes + = javadocTask.includes
266
- }
253
+ tasks.register(" aggregateJavadocs" , Javadoc ::class .java) {
254
+ setDestinationDir(project.layout.buildDirectory.file(" docs/javadoc" ).get().asFile)
255
+ title = " ${project.name} $version API"
256
+ val opts = options as StandardJavadocDocletOptions
257
+ opts.quiet()
258
+ opts.encoding = " UTF-8"
259
+ opts.memberLevel = JavadocMemberLevel .PROTECTED
260
+ opts.stylesheetFile(file(" $projectDir /docs/stylesheet.css" ))
261
+ opts.links = listOf (
262
+ " https://docs.oracle.com/javase/8/docs/api/" ,
263
+ " https://docs.spring.io/spring-framework/docs/current/javadoc-api/" ,
264
+ " https://docs.spring.io/spring-boot/docs/current/api/"
265
+ )
266
+ subprojects
267
+ .filter { ! it.name.contains(" sample" ) && ! it.name.contains(" integration-tests" ) }
268
+ .forEach { proj ->
269
+ proj.tasks.withType<Javadoc >().forEach { javadocTask ->
270
+ source + = javadocTask.source
271
+ classpath + = javadocTask.classpath
272
+ excludes + = javadocTask.excludes
273
+ includes + = javadocTask.includes
267
274
}
268
- }
275
+ }
276
+ }
269
277
270
- tasks.create(" buildForCodeQL" ) {
271
- subprojects
272
- .filter {
273
- ! it.displayName.contains(" sample" ) &&
274
- ! it.displayName.contains(" integration-tests" ) &&
275
- ! it.displayName.contains(" bom" ) &&
276
- it.name != " sentry-opentelemetry"
277
- }
278
- .forEach { proj ->
279
- if (proj.plugins.hasPlugin(" com.android.library" )) {
280
- this .dependsOn(proj.tasks.findByName(" compileReleaseUnitTestSources" ))
281
- } else {
282
- this .dependsOn(proj.tasks.findByName(" testClasses" ))
283
- }
278
+ tasks.register(" buildForCodeQL" ) {
279
+ subprojects
280
+ .filter {
281
+ ! it.displayName.contains(" sample" ) &&
282
+ ! it.displayName.contains(" integration-tests" ) &&
283
+ ! it.displayName.contains(" bom" ) &&
284
+ it.name != " sentry-opentelemetry"
285
+ }
286
+ .forEach { proj ->
287
+ if (proj.plugins.hasPlugin(" com.android.library" )) {
288
+ this .dependsOn(proj.tasks.findByName(" compileReleaseUnitTestSources" ))
289
+ } else {
290
+ this .dependsOn(proj.tasks.findByName(" testClasses" ))
284
291
}
285
- }
292
+ }
286
293
}
287
294
288
295
// Workaround for https://youtrack.jetbrains.com/issue/IDEA-316081/Gradle-8-toolchain-error-Toolchain-from-executable-property-does-not-match-toolchain-from-javaLauncher-property-when-different
0 commit comments