Fix Gradle subplugin deprecation
This commit is contained in:
@@ -11,9 +11,6 @@ plugins {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
implementation(kotlin("gradle-plugin-api"))
|
||||
|
||||
kapt("com.google.auto.service:auto-service:1.0-rc6")
|
||||
compileOnly("com.google.auto.service:auto-service-annotations:1.0-rc6")
|
||||
}
|
||||
|
||||
pluginBundle {
|
||||
|
||||
+29
-3
@@ -16,11 +16,37 @@
|
||||
|
||||
package com.bnorm.power
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
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
|
||||
|
||||
class PowerAssertGradlePlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = with(project) {
|
||||
class PowerAssertGradlePlugin : KotlinCompilerPluginSupportPlugin {
|
||||
override fun apply(target: Project): Unit = with(target) {
|
||||
extensions.create("kotlinPowerAssert", PowerAssertGradleExtension::class.java)
|
||||
}
|
||||
|
||||
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean = true
|
||||
|
||||
override fun getCompilerPluginId(): String = "com.bnorm.kotlin-power-assert"
|
||||
|
||||
override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact(
|
||||
groupId = "com.bnorm.power",
|
||||
artifactId = "kotlin-power-assert",
|
||||
version = "0.4.0-SNAPSHOT"
|
||||
)
|
||||
|
||||
override fun applyToCompilation(
|
||||
kotlinCompilation: KotlinCompilation<*>
|
||||
): Provider<List<SubpluginOption>> {
|
||||
val project = kotlinCompilation.target.project
|
||||
val extension = project.extensions.getByType(PowerAssertGradleExtension::class.java)
|
||||
return project.provider {
|
||||
extension.functions.map {
|
||||
SubpluginOption(key = "function", value = it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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 com.bnorm.power
|
||||
|
||||
import com.google.auto.service.AutoService
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact
|
||||
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
|
||||
|
||||
@AutoService(KotlinGradleSubplugin::class)
|
||||
class PowerAssertGradleSubplugin : KotlinGradleSubplugin<AbstractCompile> {
|
||||
|
||||
override fun getCompilerPluginId(): String = "com.bnorm.kotlin-power-assert"
|
||||
|
||||
override fun isApplicable(project: Project, task: AbstractCompile): Boolean =
|
||||
project.plugins.hasPlugin(PowerAssertGradlePlugin::class.java)
|
||||
|
||||
|
||||
override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact(
|
||||
groupId = "com.bnorm.power",
|
||||
artifactId = "kotlin-power-assert",
|
||||
version = "0.4.0-SNAPSHOT"
|
||||
)
|
||||
|
||||
override fun apply(
|
||||
project: Project,
|
||||
kotlinCompile: AbstractCompile,
|
||||
javaCompile: AbstractCompile?,
|
||||
variantData: Any?,
|
||||
androidProjectHandler: Any?,
|
||||
kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
|
||||
): List<SubpluginOption> {
|
||||
val extension = project.extensions.findByType(PowerAssertGradleExtension::class.java)
|
||||
?: PowerAssertGradleExtension()
|
||||
|
||||
return extension.functions.map {
|
||||
SubpluginOption(key = "function", value = it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ class PowerAssertCommandLineProcessor : CommandLineProcessor {
|
||||
optionName = "function",
|
||||
valueDescription = "function full-qualified name",
|
||||
description = "fully qualified path of function to intercept",
|
||||
required = false, // TODO required for Kotlin/JS
|
||||
allowMultipleOccurrences = true
|
||||
)
|
||||
)
|
||||
|
||||
+2
-21
@@ -5,7 +5,7 @@ buildscript {
|
||||
}
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.3.70"
|
||||
kotlin("multiplatform") version "1.4.0"
|
||||
}
|
||||
apply(plugin = "com.bnorm.power.kotlin-power-assert")
|
||||
|
||||
@@ -23,15 +23,9 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
js {
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
kotlinOptions.freeCompilerArgs += listOf("-Xir-produce-klib-dir", "-Xir-produce-js")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val osName = System.getProperty("os.name")
|
||||
@@ -43,9 +37,6 @@ kotlin {
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
@@ -53,21 +44,11 @@ kotlin {
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
}
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit"))
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-js"))
|
||||
}
|
||||
}
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
|
||||
Reference in New Issue
Block a user