diff --git a/build-logic-settings/build.gradle.kts b/build-logic-settings/build.gradle.kts new file mode 100644 index 000000000..9b8b2aed5 --- /dev/null +++ b/build-logic-settings/build.gradle.kts @@ -0,0 +1,56 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * 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 + * + * https://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. + */ + +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +plugins { + `kotlin-dsl` + alias(libs.plugins.android.lint) +} + +group = "com.google.samples.apps.nowinandroid.buildlogic" + +// Configure the build-logic plugins to target JDK 17 +// This matches the JDK used to build the project, and is not related to what is running on device. +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_17 + } +} + +dependencies { +} + +tasks { + validatePlugins { + enableStricterValidation = true + failOnWarning = true + } +} + +gradlePlugin { + plugins { + register("foo") { + id = libs.plugins.nowinandroid.foo.get().pluginId + implementationClass = "FooSettingsPlugin" + } + } +} diff --git a/build-logic-settings/gradle.properties b/build-logic-settings/gradle.properties new file mode 100644 index 000000000..5e07c65d0 --- /dev/null +++ b/build-logic-settings/gradle.properties @@ -0,0 +1,6 @@ +# Gradle properties are not passed to included builds https://github.com/gradle/gradle/issues/2534 +org.gradle.parallel=true +org.gradle.caching=true +org.gradle.configureondemand=true +org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true diff --git a/build-logic-settings/settings.gradle.kts b/build-logic-settings/settings.gradle.kts new file mode 100644 index 000000000..eadef5096 --- /dev/null +++ b/build-logic-settings/settings.gradle.kts @@ -0,0 +1,42 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * 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 + * + * https://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. + */ + +pluginManagement { + repositories { + gradlePluginPortal() + google() + } +} + +dependencyResolutionManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + } + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} + +rootProject.name = "build-logic-settings" diff --git a/build-logic-settings/src/main/kotlin/FooSettingsPlugin.kt b/build-logic-settings/src/main/kotlin/FooSettingsPlugin.kt new file mode 100644 index 000000000..bad5454fc --- /dev/null +++ b/build-logic-settings/src/main/kotlin/FooSettingsPlugin.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * https://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. + */ + +import org.gradle.api.Plugin +import org.gradle.api.initialization.Settings + +class FooSettingsPlugin : Plugin { + override fun apply(target: Settings) { + System.err.println("FOO!") + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5ea4c084c..ec44ab379 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -198,3 +198,4 @@ nowinandroid-android-room = { id = "nowinandroid.android.room" } nowinandroid-android-test = { id = "nowinandroid.android.test" } nowinandroid-hilt = { id = "nowinandroid.hilt" } nowinandroid-jvm-library = { id = "nowinandroid.jvm.library" } +nowinandroid-foo = { id = "nowinandroid.foo" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 2b8c6e45c..2b93db97e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,6 +16,7 @@ pluginManagement { includeBuild("build-logic") + includeBuild("build-logic-settings") repositories { google { content { @@ -76,6 +77,10 @@ include(":sync:work") include(":sync:sync-test") include(":ui-test-hilt-manifest") +plugins { + id("nowinandroid.foo") +} + check(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) { """ Now in Android requires JDK 17+ but it is currently using JDK ${JavaVersion.current()}.