Skip to content
Merged
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
1 change: 1 addition & 0 deletions .idea/dictionaries/project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[![Maven Central](https://img.shields.io/maven-central/v/com.gradleup.compat.patrouille/compat-patrouille-gradle-plugin?style=flat-square)](https://central.sonatype.com/namespace/com.gradleup.compat.patrouille)
[![OSS Snapshots](https://img.shields.io/nexus/s/com.gradleup.compat.patrouille/compat-patrouille-gradle-plugin?server=https%3A%2F%2Foss.sonatype.org&label=oss-snapshots&style=flat-square)](https://oss.sonatype.org/content/repositories/snapshots/com/gradleup/compat/patrouille/)
[![Maven Central](https://img.shields.io/maven-central/v/com.gradleup.tapmoc/tapmoc-gradle-plugin?style=flat-square)](https://central.sonatype.com/namespace/com.gradleup.tapmoc)
[![OSS Snapshots](https://img.shields.io/nexus/s/com.gradleup.tapmoc/tapmoc-gradle-plugin?server=https%3A%2F%2Foss.sonatype.org&label=oss-snapshots&style=flat-square)](https://oss.sonatype.org/content/repositories/snapshots/com/gradleup/tapmoc/)


# 🐾 Compat-Patrouille 🐾

The Compat-Patrouille helps you configure your Java/Kotlin compatibility flags:

```kotlin
compatPatrouille {
tapmoc {
java(17) // build for Java 17, including source, target and api compatibility
kotlin("2.1.0") // build for kotlin 2.1.0, including language and api version
}
Expand Down Expand Up @@ -47,15 +47,15 @@ plugins {
id("com.android.library")
// etc...
// And add the CompatPatrouille plugin
id("com.gradleup.compat.patrouille").version("0.1.0")
id("com.gradleup.tapmoc").version("0.1.0")
}

/*
* Configure all your Java/Kotlin targets with a single code block.
* This code block works regardless of if you're using Kotlin/Android/KMP/etc...
* You can copy/paste it
*/
compatPatrouille {
tapmoc {
// Java takes an int for simplicity
java(17)
// Kotlin takes a string so you have more control of the patch release of the stdlib.
Expand All @@ -67,8 +67,8 @@ compatPatrouille {
If you have convention plugins, you can also use the Compat-Patrouille without all the plugin ceremony:

```kotlin
import compat.patrouille.configureJavaCompatibility
import compat.patrouille.configureKotlinCompatibility
import tapmoc.configureJavaCompatibility
import tapmoc.configureKotlinCompatibility

class ConventionPlugin: Plugin<Project> {
override fun apply(target: Project) {
Expand All @@ -84,10 +84,10 @@ That's it, you can now keep on with your life.

Enforcing compiler flags works for your own code but doesn't check your dependencies. They may use incompatible APIs that will crash at runtime and/or produce incompatible metadata that will crash at build time.

You can have compat-patrouille fail in such cases with `checkApiDependencies` or `checkRuntimeDependencies`:
You can have tapmoc fail in such cases with `checkApiDependencies` or `checkRuntimeDependencies`:

```kotlin
compatPatrouille {
tapmoc {
// Fail the build if any api dependency exposes incompatible Kotlin metadata.
checkApiDependencies(Severity.ERROR)
// Fail the build if any runtime dependency relies on an incompatible kotlin-stdlib version.
Expand All @@ -103,7 +103,7 @@ In particular:
* [non-JVM targets do not support apiVersion/languageVersion](https://youtrack.jetbrains.com/issue/KT-66755/).
* some targets (like wasmJs) require that the compile time `kotlin-stdlib` version matches the compiler version.

Not only does that mean that compat-patrouille cannot configure compatibility flags for non-JVM targets, it also means compat-patrouille may downgrade some of your dependencies.
Not only does that mean that tapmoc cannot configure compatibility flags for non-JVM targets, it also means tapmoc may downgrade some of your dependencies.

Because it relies on `coreLibrariesVersion` to configure the JVM stdlib version, some of your non-JVM libraries may be older than your compiler version, which may cause issues.

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
alias(libs.plugins.kgp.jvm).apply(false)
alias(libs.plugins.librarian).apply(false)
alias(libs.plugins.nmcp).apply(false)
alias(libs.plugins.compat.patrouille).apply(false)
alias(libs.plugins.tapmoc).apply(false)
alias(libs.plugins.gratatouille).apply(false)
alias(libs.plugins.ksp).apply(false)
}
Expand Down

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions compat-patrouille-tasks/api/compat-patrouille-tasks.api

This file was deleted.

8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[versions]
gratatouille-runtime = "0.1.2"
gratatouille-build-time = "0.1.3-SNAPSHOT-ece70695061b18da18165c5203a180d1382abcbe"
# Version of KGP we are using to build compat-patrouille
# Version of KGP we are using to build tapmoc
kgp-latest = "2.2.20"
ksp = "2.2.20-2.0.4"
# Version of KGP compat-patrouille is compatible with at runtime
# Version of KGP tapmoc is compatible with at runtime
kgp-compile-only = "1.9.0"
compile-sdk = "36"
agp9 = "9.0.0-alpha09"
Expand All @@ -22,7 +22,7 @@ cast = "net.mbonnin.cast:cast:0.0.1"
jsonpathkt = "com.eygraber:jsonpathkt-kotlinx:3.0.2"
kotlinx-json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0"
asm = "org.ow2.asm:asm:9.9"
compat-patrouille = "com.gradleup.compat.patrouille:compat-patrouille-gradle-plugin:0.0.3"
tapmoc = "com.gradleup.tapmoc:tapmoc-gradle-plugin:0.0.3"

[plugins]
kgp-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kgp-latest" }
Expand All @@ -38,5 +38,5 @@ librarian = { id = "com.gradleup.librarian", version = "0.2.1-SNAPSHOT-86b179fc0
#noinspection NewerVersionAvailable
nmcp = { id = "com.gradleup.nmcp", version = "1.0.4-SNAPSHOT-aa74448010e9ec667068e89bdd97ed5edbdf059b" }
#noinspection NewerVersionAvailable
compat-patrouille = { id = "com.gradleup.compat.patrouille", version = "0.0.1-SNAPSHOT-6757526acb8472d098bed30aa17531d7f127571f" }
tapmoc = { id = "com.gradleup.compat.patrouille", version = "0.0.1-SNAPSHOT-6757526acb8472d098bed30aa17531d7f127571f" }
gratatouille = { id = "com.gradleup.gratatouille", version.ref = "gratatouille-build-time" }
8 changes: 4 additions & 4 deletions librarian.root.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ kotlin.compatibility=2.0.21

kdoc.olderVersions=

pom.groupId=com.gradleup.compat.patrouille
pom.groupId=com.gradleup.tapmoc
pom.version=0.1.1-SNAPSHOT
pom.description=compat-patrouille
pom.vcsUrl=https://github.com/GradleUp/compat-patrouille
pom.developer=compat-patrouille authors
pom.description=tapmoc
pom.vcsUrl=https://github.com/GradleUp/tapmoc
pom.developer=tapmoc authors
pom.license=MIT

gcs.bucket=gradleup
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-repo.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import com.gradleup.librarian.cli.updateRepo

updateRepo(args) {
file("README.md") {
replacePluginVersion("com.gradleup.compat.patrouille")
replacePluginVersion("com.gradleup.tapmoc")
}
}
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ pluginManagement {
}


include(":compat-patrouille-gradle-plugin")
include(":compat-patrouille-tasks")
include(":tapmoc-gradle-plugin")
include(":tapmoc-tasks")
36 changes: 36 additions & 0 deletions tapmoc-gradle-plugin/api/tapmoc-gradle-plugin.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public abstract interface class tapmoc/CompatPatrouilleExtension {
public abstract fun checkApiDependencies (Ltapmoc/Severity;)V
public abstract fun checkRuntimeDependencies (Ltapmoc/Severity;)V
public abstract fun java (I)V
public abstract fun kotlin (Ljava/lang/String;)V
}

public final class tapmoc/CompatPatrouillePluginKt {
public static final fun tapmocPlugin (Lorg/gradle/api/Project;)V
}

public final class tapmoc/CompatibilityKt {
public static final fun configureJavaCompatibility (Lorg/gradle/api/Project;I)V
public static final fun configureKotlinCompatibility (Lorg/gradle/api/Project;Ljava/lang/String;)V
}

public final class tapmoc/Severity : java/lang/Enum {
public static final field ERROR Ltapmoc/Severity;
public static final field IGNORE Ltapmoc/Severity;
public static final field WARNING Ltapmoc/Severity;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Ltapmoc/Severity;
public static fun values ()[Ltapmoc/Severity;
}

public abstract class tapmoc/TapmocPlugin : org/gradle/api/Plugin {
public fun <init> ()V
public synthetic fun apply (Ljava/lang/Object;)V
public fun apply (Lorg/gradle/api/Project;)V
}

public final class tapmoc/internal/Compatibility_kotlinKt {
public static final fun forEachCompilerOptions (Lorg/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension;Lkotlin/jvm/functions/Function2;)V
public static final fun isKmp (Ljava/lang/Object;)Z
}

Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ dependencies {
compileOnly(libs.gradle.api)
compileOnly(libs.kgp.compile.only)
implementation(libs.gratatouille.wiring.runtime)
gratatouille(project(":compat-patrouille-tasks"))
gratatouille(project(":tapmoc-tasks"))
}

gratatouille {
codeGeneration {
addDependencies.set(false)
}
pluginLocalPublication("com.gradleup.compat.patrouille")
pluginLocalPublication("com.gradleup.tapmoc")
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package compat.patrouille.internal
package tapmoc.internal

import org.gradle.api.JavaVersion

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package compat.patrouille.internal
package tapmoc.internal

import com.android.build.api.dsl.CommonExtension
import org.gradle.api.JavaVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package tapmoc

import tapmoc.internal.CompatPatrouilleExtensionImpl
import gratatouille.wiring.GPlugin
import org.gradle.api.Project

@GPlugin(id = "com.gradleup.tapmoc")
fun tapmocPlugin(target: Project) {
target.extensions.create(
CompatPatrouilleExtension::class.java,
"tapmoc",
CompatPatrouilleExtensionImpl::class.java,
target,
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package compat.patrouille
package tapmoc

interface CompatPatrouilleExtension {
/**
Expand Down Expand Up @@ -29,7 +29,7 @@ interface CompatPatrouilleExtension {
fun kotlin(version: String)

/**
* If [check] is true, registers a `compatPatrouilleCheckApiDependencies` task that walks all the api dependencies
* If [check] is true, registers a `tapmocCheckApiDependencies` task that walks all the api dependencies
* and checks that the metadata version in the `META-INF/${lib}.kotlin_module` file is compatible with
* the specified kotlin version.
* This is version n + 1 thanks to kotlinc n + 1 forward compatibility.
Expand All @@ -40,7 +40,7 @@ interface CompatPatrouilleExtension {
fun checkApiDependencies(severity: Severity)

/**
* If [check] is true, registers a `compatPatrouilleCheckRuntimeDependencies` task that walks all the runtime dependencies
* If [check] is true, registers a `tapmocCheckRuntimeDependencies` task that walks all the runtime dependencies
* and checks that `kotlin-stdlib` is not upgraded to a version > n
*
* @param severity what to do when a dependency is found to be incompatible.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package compat.patrouille
package tapmoc

import compat.patrouille.internal.agp
import compat.patrouille.internal.configureKotlinJvmTarget
import compat.patrouille.internal.forEachCompilerOptions
import compat.patrouille.internal.kotlinExtensionOrNull
import tapmoc.internal.agp
import tapmoc.internal.configureKotlinJvmTarget
import tapmoc.internal.forEachCompilerOptions
import tapmoc.internal.kotlinExtensionOrNull
import java.lang.reflect.Method
import kotlin.text.toInt
import org.gradle.api.JavaVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package compat.patrouille.internal
package tapmoc.internal

import compat.patrouille.CompatPatrouilleExtension
import compat.patrouille.Severity
import compat.patrouille.configureJavaCompatibility
import compat.patrouille.configureKotlinCompatibility
import compat.patrouille.task.registerCheckApiDependenciesTask
import compat.patrouille.task.registerCheckRuntimeDependenciesTask
import tapmoc.CompatPatrouilleExtension
import tapmoc.Severity
import tapmoc.configureJavaCompatibility
import tapmoc.configureKotlinCompatibility
import tapmoc.task.registerCheckApiDependenciesTask
import tapmoc.task.registerCheckRuntimeDependenciesTask
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
Expand Down Expand Up @@ -44,7 +44,7 @@ internal abstract class CompatPatrouilleExtensionImpl(private val project: Proje
} else {
"apiElements"
}
val configurationProvider = project.configurations.register("compatPatrouilleCheck") {
val configurationProvider = project.configurations.register("tapmocCheck") {
it.isCanBeConsumed = false
it.isCanBeResolved = true
it.isVisible = false
Expand All @@ -56,7 +56,7 @@ internal abstract class CompatPatrouilleExtensionImpl(private val project: Proje
val checkApiDependencies = project.registerCheckApiDependenciesTask(
warningAsError = project.provider { severity == Severity.ERROR },
kotlinVersion = project.provider { kotlinVersion ?: project.getKotlinPluginVersion() },
taskName = "compatPatrouilleCheckApiDependencies",
taskName = "tapmocCheckApiDependencies",
compileClasspath = project.files(configurationProvider),
)

Expand All @@ -77,7 +77,7 @@ internal abstract class CompatPatrouilleExtensionImpl(private val project: Proje
} else {
return
}
val lifecycleTask = project.tasks.register("compatPatrouilleCheckRuntimeDependencies")
val lifecycleTask = project.tasks.register("tapmocCheckRuntimeDependencies")

targets.forEach { target ->
target.compilations.forEach {
Expand All @@ -96,7 +96,7 @@ internal abstract class CompatPatrouilleExtensionImpl(private val project: Proje
}
}
val task = project.registerCheckRuntimeDependenciesTask(
taskName = "compatPatrouilleCheck${target.name}${it.name}RuntimeDependencies",
taskName = "tapmocCheck${target.name}${it.name}RuntimeDependencies",
warningAsError = project.provider { severity == Severity.ERROR },
kotlinVersion = project.provider { kotlinVersion ?: project.getKotlinPluginVersion() },
transitiveKotlinVersions = stdlibVersions,
Expand Down
Loading