Browse Source
* Fix compatibility with Intellij 2021.3 Resolves #1373 * Use Java reflection * Set Java source & target compatibility for build helpers Otherwise, Gradle might set Gradle metadata attributes in such way, that transitive dependencies of published modules are not resolved * Configure shadow jar manually Applying plugin configures additional publication, so that both .jar and -shadow.jar are published, and additional configurations are added to Gradle metadata. To avoid unexpected metadata resolution results, ShadowJar task is now configured manually * Fix closeStagingRepo JSON request * Update publishing build-helpers in composepull/1420/head
Alexey Tsvetkov
3 years ago
committed by
GitHub
10 changed files with 47 additions and 16 deletions
@ -0,0 +1,30 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.jetbrains.compose.desktop.ide.preview |
||||||
|
|
||||||
|
import com.intellij.openapi.externalSystem.model.Key |
||||||
|
import com.intellij.openapi.externalSystem.model.project.AbstractNamedData |
||||||
|
import java.lang.reflect.Modifier |
||||||
|
|
||||||
|
internal val kotlinTargetDataKey: Key<out AbstractNamedData> = run { |
||||||
|
val kotlinTargetDataClass = try { |
||||||
|
Class.forName("org.jetbrains.kotlin.idea.gradle.configuration.KotlinTargetData") |
||||||
|
} catch (e: ClassNotFoundException) { |
||||||
|
try { |
||||||
|
Class.forName("org.jetbrains.kotlin.idea.configuration.KotlinTargetData") |
||||||
|
} catch (e: ClassNotFoundException) { |
||||||
|
error("Could not find 'KotlinTargetData' class") |
||||||
|
} |
||||||
|
} |
||||||
|
val companionField = kotlinTargetDataClass.fields.firstOrNull { Modifier.isStatic(it.modifiers) && it.name == "Companion" } |
||||||
|
?: error("'${kotlinTargetDataClass.canonicalName}.Companion") |
||||||
|
val companionInstance = companionField.get(kotlinTargetDataClass) |
||||||
|
val companionClass = companionInstance.javaClass |
||||||
|
val getKeyMethod = companionClass.methods.firstOrNull { it.name == "getKEY" } |
||||||
|
?: error("Cannot find '${kotlinTargetDataClass.canonicalName}.Companion.getKEY'") |
||||||
|
@Suppress("UNCHECKED_CAST") |
||||||
|
getKeyMethod.invoke(companionInstance) as Key<out AbstractNamedData> |
||||||
|
} |
Loading…
Reference in new issue