diff --git a/acra-advanced-scheduler/build.gradle.kts b/acra-advanced-scheduler/build.gradle.kts index 3d6b8474..85905208 100644 --- a/acra-advanced-scheduler/build.gradle.kts +++ b/acra-advanced-scheduler/build.gradle.kts @@ -25,5 +25,5 @@ android { } dependencies { - acraCore() + api(projects.acraCore) } \ No newline at end of file diff --git a/acra-core/build.gradle.kts b/acra-core/build.gradle.kts index f141d19f..b7c4ab59 100644 --- a/acra-core/build.gradle.kts +++ b/acra-core/build.gradle.kts @@ -25,5 +25,5 @@ android { } dependencies { - api(project(":acra-javacore")) + api(projects.acraJavacore) } diff --git a/acra-dialog/build.gradle.kts b/acra-dialog/build.gradle.kts index 31280a69..13a36050 100644 --- a/acra-dialog/build.gradle.kts +++ b/acra-dialog/build.gradle.kts @@ -19,5 +19,5 @@ plugins { } dependencies { - acraCore() + api(projects.acraCore) } diff --git a/acra-http/build.gradle.kts b/acra-http/build.gradle.kts index 31280a69..13a36050 100644 --- a/acra-http/build.gradle.kts +++ b/acra-http/build.gradle.kts @@ -19,5 +19,5 @@ plugins { } dependencies { - acraCore() + api(projects.acraCore) } diff --git a/acra-javacore/build.gradle.kts b/acra-javacore/build.gradle.kts index 8e504f11..d8a6b8aa 100644 --- a/acra-javacore/build.gradle.kts +++ b/acra-javacore/build.gradle.kts @@ -19,6 +19,5 @@ plugins { } dependencies { - val androidxAnnotationVersion: String by project - api("androidx.annotation:annotation:$androidxAnnotationVersion") + api(libs.androidx.annotation) } diff --git a/acra-limiter/build.gradle.kts b/acra-limiter/build.gradle.kts index 31280a69..13a36050 100644 --- a/acra-limiter/build.gradle.kts +++ b/acra-limiter/build.gradle.kts @@ -19,5 +19,5 @@ plugins { } dependencies { - acraCore() + api(projects.acraCore) } diff --git a/acra-mail/build.gradle.kts b/acra-mail/build.gradle.kts index 31280a69..13a36050 100644 --- a/acra-mail/build.gradle.kts +++ b/acra-mail/build.gradle.kts @@ -19,5 +19,5 @@ plugins { } dependencies { - acraCore() + api(projects.acraCore) } diff --git a/acra-notification/build.gradle.kts b/acra-notification/build.gradle.kts index 855b088c..a575d056 100644 --- a/acra-notification/build.gradle.kts +++ b/acra-notification/build.gradle.kts @@ -19,7 +19,6 @@ plugins { } dependencies { - acraCore() - val androidxCoreVersion: String by project - implementation("androidx.core:core:$androidxCoreVersion") + api(projects.acraCore) + implementation(libs.androidx.core) } diff --git a/acra-toast/build.gradle.kts b/acra-toast/build.gradle.kts index 31280a69..13a36050 100644 --- a/acra-toast/build.gradle.kts +++ b/acra-toast/build.gradle.kts @@ -19,5 +19,5 @@ plugins { } dependencies { - acraCore() + api(projects.acraCore) } diff --git a/annotationprocessor/build.gradle.kts b/annotationprocessor/build.gradle.kts index c36cfd01..c5aecdee 100644 --- a/annotationprocessor/build.gradle.kts +++ b/annotationprocessor/build.gradle.kts @@ -18,12 +18,11 @@ plugins { } dependencies { - implementation("com.google.auto:auto-common:1.0") - implementation("com.squareup:kotlinpoet:1.8.0") - implementation(kotlin("reflect")) - implementation("org.apache.commons:commons-text:1.9") - implementation(project(":annotations")) - implementation(project(":acra-javacore")) - val autoServiceVersion: String by project - implementation("com.google.auto.service:auto-service:$autoServiceVersion") + implementation(libs.autoCommon) + implementation(libs.kotlinPoet) + implementation(libs.kotlin.reflect) + implementation(libs.commonsText) + implementation(projects.annotations) + implementation(projects.acraJavacore) + implementation(libs.autoService.processor) } \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 537aa4a5..6f9b61d5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,5 +15,5 @@ */ plugins { - `acra-release` + id("acra-release") } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 7a38427d..fa5c7b1e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -27,29 +27,17 @@ repositories { } dependencies { - val androidBuildPluginVersion: String by project - implementation("com.android.tools.build:gradle:$androidBuildPluginVersion") - val kotlinVersion: String by project - implementation(kotlin("gradle-plugin:$kotlinVersion")) - implementation(kotlin("allopen:$kotlinVersion")) - val dokkaVersion: String by project - implementation("org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion") - implementation("org.jetbrains.dokka:dokka-core:$dokkaVersion") - val jgitverVersion: String by project - implementation("gradle.plugin.fr.brouillard.oss.gradle:gradle-jgitver-plugin:$jgitverVersion") - val nexusPublishVersion: String by project - implementation("io.github.gradle-nexus:publish-plugin:$nexusPublishVersion") + implementation(libs.android.build) + implementation(libs.kotlin.gradle) + implementation(libs.kotlin.allopen) + implementation(libs.dokka.gradle) + implementation(libs.dokka.core) + implementation(libs.jgitver) + implementation(libs.nexusPublish) } -val compileKotlin: KotlinCompile by tasks -compileKotlin.kotlinOptions { - jvmTarget = "1.8" -} -val compileTestKotlin: KotlinCompile by tasks -compileTestKotlin.kotlinOptions { - jvmTarget = "1.8" -} - -kotlinDslPluginOptions { - experimentalWarning.set(false) +tasks.withType { + kotlinOptions { + jvmTarget = "1.8" + } } \ No newline at end of file diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties deleted file mode 120000 index 7677fb73..00000000 --- a/buildSrc/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -../gradle.properties \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/settings.gradle.kts similarity index 63% rename from buildSrc/src/main/kotlin/dependencies.kt rename to buildSrc/settings.gradle.kts index 6cf49c27..5a47dfbb 100644 --- a/buildSrc/src/main/kotlin/dependencies.kt +++ b/buildSrc/settings.gradle.kts @@ -1,8 +1,8 @@ /* - * Copyright (c) 2020 + * Copyright (c) 2021 * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import org.gradle.kotlin.dsl.DependencyHandlerScope -import org.gradle.kotlin.dsl.project - -fun DependencyHandlerScope.acraCore() { - "api"(project(":acra-core")) -} - - +enableFeaturePreview("VERSION_CATALOGS") +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/acra-android-library.gradle.kts b/buildSrc/src/main/kotlin/acra-android-library.gradle.kts index 4a38b3fc..9c3e4fee 100644 --- a/buildSrc/src/main/kotlin/acra-android-library.gradle.kts +++ b/buildSrc/src/main/kotlin/acra-android-library.gradle.kts @@ -27,12 +27,12 @@ plugins { } android { - val androidVersion: String by project - val androidMinVersion: String by project - compileSdkVersion(Integer.parseInt(androidVersion)) + val androidTarget: String by Libs.versions + val androidMin: String by Libs.versions + compileSdkVersion(Integer.parseInt(androidTarget)) defaultConfig { - minSdkVersion(androidMinVersion) - targetSdkVersion(androidVersion) + minSdkVersion(androidMin) + targetSdkVersion(androidTarget) buildConfigField("String", "VERSION_NAME", "\"$version\"") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -58,26 +58,12 @@ tasks.withType { } dependencies { - val androidXTestVersion: String by project - androidTestImplementation("androidx.test:core:$androidXTestVersion") - androidTestImplementation("androidx.test:runner:$androidXTestVersion") { - exclude(group = "org.hamcrest") - } - androidTestImplementation("androidx.test:rules:$androidXTestVersion") { - exclude(group = "org.hamcrest") - } - val androidXJunitVersion: String by project - androidTestImplementation("androidx.test.ext:junit:$androidXJunitVersion") { - exclude(group = "org.hamcrest") - } - val hamcrestVersion: String by project - androidTestImplementation("org.hamcrest:hamcrest:$hamcrestVersion") + androidTestImplementation(Libs.bundles["androidx-test"]) val autoServiceVersion: String by project - "kaptTest"("com.google.auto.service:auto-service:$autoServiceVersion") - testCompileOnly("com.google.auto.service:auto-service-annotations:$autoServiceVersion") + "kaptTest"(Libs["autoService-processor"]) + testCompileOnly(Libs["autoService-annotations"]) "kapt"(project(":annotationprocessor")) compileOnly(project(":annotations")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1") } tasks.withType { diff --git a/buildSrc/src/main/kotlin/acra-publish.gradle.kts b/buildSrc/src/main/kotlin/acra-publish.gradle.kts index b579639d..8b7ce9ab 100644 --- a/buildSrc/src/main/kotlin/acra-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/acra-publish.gradle.kts @@ -14,7 +14,6 @@ * limitations under the License. */ import com.android.build.gradle.LibraryExtension -import gradle.kotlin.dsl.accessors._f9b7db6b229a578e2a74683274145336.sourceSets import org.jetbrains.dokka.gradle.DokkaTask @@ -39,7 +38,10 @@ tasks.register("javadocJar") { afterEvaluate { tasks.register("sourcesJar") { group = "documentation" - from(project.extensions.findByType()?.sourceSets?.get("main")?.java?.srcDirs ?: sourceSets["main"].allSource) + from( + project.extensions.findByType()?.sourceSets?.get("main")?.java?.srcDirs + ?: project.extensions.getByType()["main"].allSource + ) archiveClassifier.set("sources") } diff --git a/buildSrc/src/main/kotlin/auto-service.gradle.kts b/buildSrc/src/main/kotlin/auto-service.gradle.kts index 06275ad8..202a519f 100644 --- a/buildSrc/src/main/kotlin/auto-service.gradle.kts +++ b/buildSrc/src/main/kotlin/auto-service.gradle.kts @@ -17,6 +17,6 @@ apply(plugin = "kotlin-kapt") dependencies { val autoServiceVersion: String by project - "kapt"("com.google.auto.service:auto-service:$autoServiceVersion") - "compileOnly"("com.google.auto.service:auto-service-annotations:$autoServiceVersion") + "kapt"(Libs["autoService-processor"]) + "compileOnly"(Libs["autoService-annotations"]) } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/catalogUtils.kt b/buildSrc/src/main/kotlin/catalogUtils.kt new file mode 100644 index 00000000..a7be8d04 --- /dev/null +++ b/buildSrc/src/main/kotlin/catalogUtils.kt @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:Suppress("UnstableApiUsage") + +import org.gradle.api.Project +import org.gradle.api.artifacts.ExternalModuleDependencyBundle +import org.gradle.api.artifacts.MinimalExternalModuleDependency +import org.gradle.api.artifacts.VersionCatalog +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.api.provider.Provider +import org.gradle.kotlin.dsl.the +import java.util.* +import kotlin.reflect.KProperty + +/* +VersionCatalog typesafe accessors aren't available in precompiled script plugins - see https://github.com/gradle/gradle/issues/15383 +These are workarounds + */ + +val Project.Libs: VersionCatalog + get() = the().named("libs") + +class Versions(private val versionCatalog: VersionCatalog) { + operator fun getValue(receiver: Versions?, property: KProperty<*>): String = get(property.name.replace(Regex("([A-Z])"), "-$1").toLowerCase(Locale.ROOT)) + + operator fun get(name: String): String = + versionCatalog.findVersion(name).orElse(null)?.toString() ?: throw IllegalArgumentException("Unknown version $name") +} + +class Bundles(private val versionCatalog: VersionCatalog) { + operator fun getValue(receiver: Bundles?, property: KProperty<*>): Provider = + get(property.name.replace(Regex("([A-Z])"), "-$1").toLowerCase(Locale.ROOT)) + + operator fun get(name: String): Provider = + versionCatalog.findBundle(name).orElse(null) ?: throw IllegalArgumentException("Unknown version $name") +} + +val VersionCatalog.versions: Versions + get() = Versions(this) + +val VersionCatalog.bundles: Bundles + get() = Bundles(this) + +operator fun VersionCatalog.get(library: String): Provider = findDependency(library).get() \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/repositories.gradle.kts b/buildSrc/src/main/kotlin/repositories.gradle.kts index 75389d72..bd4c78ee 100644 --- a/buildSrc/src/main/kotlin/repositories.gradle.kts +++ b/buildSrc/src/main/kotlin/repositories.gradle.kts @@ -18,6 +18,4 @@ import org.gradle.kotlin.dsl.repositories repositories { mavenCentral() google() - //TODO: Remove when kotlinx.html is available in maven central - maven { setUrl("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index d968702c..72e6fe4f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,18 +29,3 @@ kapt.use.worker.api=false # upload properties group=ch.acra -# versions -androidVersion=30 -androidMinVersion=14 -androidBuildPluginVersion=4.1.3 -autoServiceVersion=1.0 -junitVersion=4.12 -androidxCoreVersion=1.3.2 -androidxAnnotationVersion=1.2.0 -kotlinVersion=1.4.32 -dokkaVersion=1.4.32 -hamcrestVersion=2.2 -androidXTestVersion=1.3.0 -androidXJunitVersion=1.1.2 -jgitverVersion=0.10.0-rc03 -nexusPublishVersion=1.0.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..63472886 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,43 @@ +[versions] +android-target = "30" +android-min = "14" +android-build = "4.1.3" +autoService = "1.0" +junit = "4.12" +androidx-core = "1.3.2" +androidx-annotation = "1.2.0" +kotlin = "1.5.10" +dokka = "1.4.32" +hamcrest = "2.2" +androidx-test = "1.3.0" +androidx-junit = "1.1.2" +jgitver = "0.10.0-rc03" +nexusPublish = "1.0.0" +autoCommon = "1.0" +kotlinPoet = "1.8.0" +commonsText = "1.9" + +[libraries] +android-build = { module = "com.android.tools.build:gradle", version.ref = "android-build" } +kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +kotlin-allopen = { module = "org.jetbrains.kotlin:kotlin-allopen", version.ref = "kotlin" } +kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } +dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } +dokka-core = { module = "org.jetbrains.dokka:dokka-core", version.ref = "dokka" } +jgitver = { module = "gradle.plugin.fr.brouillard.oss.gradle:gradle-jgitver-plugin", version.ref = "jgitver" } +nexusPublish = { module = "io.github.gradle-nexus:publish-plugin", version.ref = "nexusPublish" } +androidx-core = { module = "androidx.core:core", version.ref = "androidx-core" } +androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidx-annotation" } +androidx-test-core = { module = "androidx.test:core", version.ref = "androidx-test" } +androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test" } +androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test" } +androidx-test-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-junit" } +hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" } +autoService-processor = { module = "com.google.auto.service:auto-service", version.ref = "autoService" } +autoService-annotations = { module = "com.google.auto.service:auto-service", version.ref = "autoService" } +autoCommon = { module = "com.google.auto:auto-common", version.ref = "autoCommon" } +kotlinPoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinPoet" } +commonsText = { module = "org.apache.commons:commons-text", version.ref = "commonsText" } + +[bundles] +androidx-test = ["androidx-test-core", "androidx-test-runner", "androidx-test-rules", "androidx-test-junit", "hamcrest"] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8e0e6b97..afd7f5fa 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip diff --git a/settings.gradle.kts b/settings.gradle.kts index 706e804d..b146c15b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -26,13 +26,7 @@ include("acra-limiter") include("acra-advanced-scheduler") includeBuild("examples") -pluginManagement { - repositories { - gradlePluginPortal() - } - plugins { - val kotlinVersion: String by settings - kotlin("android") version kotlinVersion - } -} +enableFeaturePreview("VERSION_CATALOGS") +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + if(file("acratest").exists()) include("acratest") \ No newline at end of file