-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Neeme Praks
committed
Jan 14, 2025
1 parent
e14380d
commit e77837f
Showing
31 changed files
with
296,309 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Gradle wrapper plugin for Kotlin (IR) compiler plugin for kotlin-logging | ||
|
||
Just a Gradle wrapper for the Kotlin (IR) Compiler plugin for kotlin-logging, | ||
see [kotlin-ir-plugin](../kotlin-ir-plugin) for the actual Kotlin (IR) compiler plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
plugins { | ||
id("java-gradle-plugin") | ||
id("com.gradle.plugin-publish") version "1.2.1" | ||
kotlin("jvm") | ||
id("com.github.gmazzo.buildconfig") | ||
id("com.diffplug.spotless") | ||
|
||
} | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(kotlin("gradle-plugin-api")) | ||
} | ||
|
||
buildConfig { | ||
val project = project(":kotlin-ir-plugin") | ||
packageName("${rootProject.extra["kotlin_plugin_package_name"]}") | ||
buildConfigField("String", "KOTLIN_PLUGIN_ID", "\"${rootProject.extra["kotlin_plugin_id"]}\"") | ||
buildConfigField("String", "KOTLIN_PLUGIN_GROUP", "\"${project.group}\"") | ||
buildConfigField("String", "KOTLIN_PLUGIN_NAME", "\"${project.name}\"") | ||
buildConfigField("String", "KOTLIN_PLUGIN_VERSION", "\"${project.version}\"") | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
create("kotlinLoggingIrPlugin") { | ||
id = rootProject.extra["kotlin_plugin_id"] as String | ||
displayName = "kotlin-logging IR plugin" | ||
description = "Collects metadata about logging calls from the source code and adds it to the respective calls" | ||
implementationClass = "io.github.oshai.kotlinlogging.irplugin.KotlinLoggingGradlePlugin" | ||
} | ||
} | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "localPluginRepository" | ||
url = uri(rootProject.layout.buildDirectory.dir("local-plugin-repository")) | ||
} | ||
} | ||
} | ||
|
||
// Static code analysis tools | ||
spotless { | ||
kotlin { | ||
target("src/**/*.kt") | ||
ktfmt("0.47").googleStyle() | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...le/src/main/kotlin/io/github/oshai/kotlinlogging/irplugin/KotlinLoggingGradleExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2020 Brian Norman | ||
* | ||
* 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. | ||
*/ | ||
|
||
package io.github.oshai.kotlinlogging.irplugin | ||
|
||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.provider.Property | ||
|
||
// Based on https://github.com/bnorm/kotlin-ir-plugin-template | ||
open class KotlinLoggingGradleExtension(objects: ObjectFactory) { | ||
val disableAll: Property<String> = objects.property(String::class.java) | ||
val disableTransformingDeprecatedApi: Property<String> = objects.property(String::class.java) | ||
val disableTransformingNotImplementedApi: Property<String> = objects.property(String::class.java) | ||
val disableTransformingEntryExitApi: Property<String> = objects.property(String::class.java) | ||
val disableTransformingThrowingCatchingApi: Property<String> = | ||
objects.property(String::class.java) | ||
val disableCollectingCallSiteInformation: Property<String> = objects.property(String::class.java) | ||
} |
73 changes: 73 additions & 0 deletions
73
...radle/src/main/kotlin/io/github/oshai/kotlinlogging/irplugin/KotlinLoggingGradlePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (C) 2020 Brian Norman | ||
* | ||
* 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. | ||
*/ | ||
|
||
package io.github.oshai.kotlinlogging.irplugin | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.provider.Provider | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin | ||
import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact | ||
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption | ||
|
||
// Based on https://github.com/bnorm/kotlin-ir-plugin-template | ||
class KotlinLoggingGradlePlugin : KotlinCompilerPluginSupportPlugin { | ||
override fun apply(target: Project): Unit = | ||
with(target) { extensions.create("kotlinlogging", KotlinLoggingGradleExtension::class.java) } | ||
|
||
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean = true | ||
|
||
override fun getCompilerPluginId(): String = BuildConfig.KOTLIN_PLUGIN_ID | ||
|
||
override fun getPluginArtifact(): SubpluginArtifact = | ||
SubpluginArtifact( | ||
groupId = BuildConfig.KOTLIN_PLUGIN_GROUP, | ||
artifactId = BuildConfig.KOTLIN_PLUGIN_NAME, | ||
version = BuildConfig.KOTLIN_PLUGIN_VERSION, | ||
) | ||
|
||
override fun applyToCompilation( | ||
kotlinCompilation: KotlinCompilation<*> | ||
): Provider<List<SubpluginOption>> { | ||
val project = kotlinCompilation.target.project | ||
val extension = project.extensions.getByType(KotlinLoggingGradleExtension::class.java) | ||
return project.provider { | ||
listOf( | ||
SubpluginOption(key = "disableAll", value = extension.disableAll.get()), | ||
SubpluginOption( | ||
key = "disableTransformingDeprecatedApi", | ||
value = extension.disableTransformingDeprecatedApi.get(), | ||
), | ||
SubpluginOption( | ||
key = "disableTransformingNotImplementedApi", | ||
value = extension.disableTransformingNotImplementedApi.get(), | ||
), | ||
SubpluginOption( | ||
key = "disableTransformingEntryExitApi", | ||
value = extension.disableTransformingEntryExitApi.get(), | ||
), | ||
SubpluginOption( | ||
key = "disableTransformingThrowingCatchingApi", | ||
value = extension.disableTransformingThrowingCatchingApi.get(), | ||
), | ||
SubpluginOption( | ||
key = "disableCollectingCallSiteInformation", | ||
value = extension.disableCollectingCallSiteInformation.get(), | ||
), | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.