Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
repositories {
mavenCentral()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
gradlePluginPortal()
// AGP is only published to Google's repository.
google()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
gradlePluginPortal()
// AGP is only published to Google's repository.
google()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "build-logic"
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ import org.gradle.api.attributes.Category
import org.gradle.api.attributes.LibraryElements
import org.gradle.kotlin.dsl.named

val javadocPublisher = configurations.create("javadocPublisher") {
val javadocPublisher =
configurations.create("javadocPublisher") {
isCanBeConsumed = false
isCanBeResolved = true
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named("javadoc"))
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named("javadoc"))
}
}
}

subprojects {
javadocPublisher.dependencies.add(rootProject.dependencies.project(path))
javadocPublisher.dependencies.add(rootProject.dependencies.project(path))
}

val javadocCollection = javadocPublisher.incoming.artifactView { lenient(true) }.files

tasks.register("aggregateJavadocs", AggregateJavadoc::class) {
group = "documentation"
description = "Aggregates Javadocs from all subprojects into a single directory."
javadocFiles.set(javadocCollection)
rootDir.set(layout.projectDirectory)
outputDir.set(layout.buildDirectory.dir("docs/javadoc"))
group = "documentation"
description = "Aggregates Javadocs from all subprojects into a single directory."
javadocFiles.set(javadocCollection)
rootDir.set(layout.projectDirectory)
outputDir.set(layout.buildDirectory.dir("docs/javadoc"))
}
32 changes: 17 additions & 15 deletions build-logic/src/main/kotlin/io.sentry.javadoc.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
val javadocConfig: Configuration = configurations.create("javadocConfig") {
val javadocConfig: Configuration =
configurations.create("javadocConfig") {
isCanBeResolved = false
isCanBeConsumed = true

attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named("javadoc"))
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named("javadoc"))
}
}
}

tasks.withType<Javadoc>().configureEach {
setDestinationDir(project.layout.buildDirectory.file("docs/javadoc").get().asFile)
title = "${project.name} $version API"
val opts = options as StandardJavadocDocletOptions
opts.quiet()
opts.encoding = "UTF-8"
opts.memberLevel = JavadocMemberLevel.PROTECTED
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/"
setDestinationDir(project.layout.buildDirectory.file("docs/javadoc").get().asFile)
title = "${project.name} $version API"
val opts = options as StandardJavadocDocletOptions
opts.quiet()
opts.encoding = "UTF-8"
opts.memberLevel = JavadocMemberLevel.PROTECTED
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/",
)
}

artifacts {
add(javadocConfig.name, tasks.named("javadoc"))
add(javadocConfig.name, tasks.named("javadoc"))
}
38 changes: 20 additions & 18 deletions build-logic/src/main/kotlin/io.sentry.spotless.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import com.diffplug.spotless.LineEnding

plugins {
id("com.diffplug.spotless")
id("com.diffplug.spotless")
}

spotless {
lineEndings = LineEnding.UNIX
java {
target("src/*/java/**/*.java")
removeUnusedImports()
googleJavaFormat()
targetExclude("src/**/java/io/sentry/vendor/**")
}
kotlin {
target("src/*/kotlin/**/*.kt", "src/*/java/**/*.kt")
ktfmt().googleStyle()
targetExclude("src/test/java/io/sentry/apollo4/generated/**", "src/test/java/io/sentry/apollo3/adapter/**")
}
kotlinGradle {
target("*.gradle.kts")
ktfmt().googleStyle()
}
lineEndings = LineEnding.UNIX
java {
target("src/*/java/**/*.java")
removeUnusedImports()
googleJavaFormat()
targetExclude("src/**/java/io/sentry/vendor/**")
}
kotlin {
target("src/*/kotlin/**/*.kt", "src/*/java/**/*.kt")
ktfmt().googleStyle()
targetExclude(
"src/test/java/io/sentry/apollo4/generated/**",
"src/test/java/io/sentry/apollo3/adapter/**",
)
}
kotlinGradle {
target("*.gradle.kts")
ktfmt().googleStyle()
}
}

46 changes: 23 additions & 23 deletions build-logic/src/main/kotlin/io/sentry/gradle/AggregateJavadoc.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry.gradle

import javax.inject.Inject
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileCollection
Expand All @@ -9,33 +10,32 @@ import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import javax.inject.Inject

abstract class AggregateJavadoc @Inject constructor(
@get:Internal val fs: FileSystemOperations
abstract class AggregateJavadoc
@Inject
constructor(
@get:Internal val fs: FileSystemOperations,
) : DefaultTask() {
@get:InputFiles
abstract val javadocFiles: Property<FileCollection>
@get:InputFiles abstract val javadocFiles: Property<FileCollection>

// Marked as Internal since this is only used to relativize the paths for the output directories
@get:Internal
abstract val rootDir: DirectoryProperty
// Marked as Internal since this is only used to relativize the paths for the output directories
@get:Internal abstract val rootDir: DirectoryProperty

@get:OutputDirectory
abstract val outputDir: DirectoryProperty
@get:OutputDirectory abstract val outputDir: DirectoryProperty

@TaskAction
fun aggregate() {
javadocFiles.get().forEach { file ->
fs.copy {
// Get the relative path of the project directory to the root directory
val relativePath = file.relativeTo(rootDir.get().asFile)
// Remove the 'build/docs/javadoc' part from the path
val projectPath = relativePath.path.replace("build/docs/javadoc", "")
from(file)
// Use the project name as the output directory name so that each javadoc goes into its own directory
into(outputDir.get().file(projectPath))
}
}
@TaskAction
fun aggregate() {
javadocFiles.get().forEach { file ->
fs.copy {
// Get the relative path of the project directory to the root directory
val relativePath = file.relativeTo(rootDir.get().asFile)
// Remove the 'build/docs/javadoc' part from the path
val projectPath = relativePath.path.replace("build/docs/javadoc", "")
from(file)
// Use the project name as the output directory name so that each javadoc goes into its own
// directory
into(outputDir.get().file(projectPath))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class JdkTargetConvention : Plugin<Project> {
"-Xlint:-processing",
"-Xlint:-try",
"-Xlint:-options",
)
),
)
}

Expand All @@ -67,9 +67,11 @@ class JdkTargetConvention : Plugin<Project> {
group = "verification"
report.set(project.layout.buildDirectory.file("reports/method-parameters.txt"))
}
project.tasks.matching { it.name == "check" }.configureEach {
dependsOn(verifyMethodParameters)
}
project.tasks
.matching { it.name == "check" }
.configureEach {
dependsOn(verifyMethodParameters)
}
project.plugins.withId("java-library") {
verifyMethodParameters.configure { archives.from(project.tasks.named("jar")) }
}
Expand All @@ -94,7 +96,7 @@ class JdkTargetConvention : Plugin<Project> {
project.plugins.withId("org.jetbrains.kotlin.jvm") {
project.tasks.named("compileKotlin", KotlinJvmCompile::class.java) {
compilerOptions.freeCompilerArgs.add(
compilerOptions.jvmTarget.map { "-Xjdk-release=${it.target}" }
compilerOptions.jvmTarget.map { "-Xjdk-release=${it.target}" },
)
}
}
Expand Down
Loading
Loading