Add a `Plugin<Settings>` to the included build

pull/1909/head
Simon Marquis 2 months ago
parent 27e0336729
commit eb257bb244
No known key found for this signature in database

@ -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"
}
}
}

@ -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

@ -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"

@ -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<Settings> {
override fun apply(target: Settings) {
System.err.println("FOO!")
}
}

@ -198,3 +198,4 @@ nowinandroid-android-room = { id = "nowinandroid.android.room" }
nowinandroid-android-test = { id = "nowinandroid.android.test" } nowinandroid-android-test = { id = "nowinandroid.android.test" }
nowinandroid-hilt = { id = "nowinandroid.hilt" } nowinandroid-hilt = { id = "nowinandroid.hilt" }
nowinandroid-jvm-library = { id = "nowinandroid.jvm.library" } nowinandroid-jvm-library = { id = "nowinandroid.jvm.library" }
nowinandroid-foo = { id = "nowinandroid.foo" }

@ -16,6 +16,7 @@
pluginManagement { pluginManagement {
includeBuild("build-logic") includeBuild("build-logic")
includeBuild("build-logic-settings")
repositories { repositories {
google { google {
content { content {
@ -76,6 +77,10 @@ include(":sync:work")
include(":sync:sync-test") include(":sync:sync-test")
include(":ui-test-hilt-manifest") include(":ui-test-hilt-manifest")
plugins {
id("nowinandroid.foo")
}
check(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) { check(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
""" """
Now in Android requires JDK 17+ but it is currently using JDK ${JavaVersion.current()}. Now in Android requires JDK 17+ but it is currently using JDK ${JavaVersion.current()}.

Loading…
Cancel
Save