diff --git a/build-helpers/build.gradle.kts b/build-helpers/build.gradle.kts index abdc241eb1..87a8539d3b 100644 --- a/build-helpers/build.gradle.kts +++ b/build-helpers/build.gradle.kts @@ -14,6 +14,8 @@ subprojects { plugins.withType(JavaBasePlugin::class.java) { afterEvaluate { configureIfExists { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 if (sourceSets.names.contains(SourceSet.MAIN_SOURCE_SET_NAME)) { withJavadocJar() withSourcesJar() diff --git a/build-helpers/publishing/build.gradle.kts b/build-helpers/publishing/build.gradle.kts index 630f071209..da4ff48bc1 100644 --- a/build-helpers/publishing/build.gradle.kts +++ b/build-helpers/publishing/build.gradle.kts @@ -6,7 +6,7 @@ plugins { `maven-publish` `java-gradle-plugin` id("org.jetbrains.kotlin.jvm") - id("com.github.johnrengelman.shadow") + id("com.github.johnrengelman.shadow") apply false } repositories { @@ -34,7 +34,7 @@ dependencies { embedded("de.undercouch:gradle-download-task:4.1.2") } -val shadow = tasks.named("shadowJar") { +val shadowJar by tasks.registering(ShadowJar::class) { val fromPackage = "de.undercouch" val toPackage = "org.jetbrains.compose.internal.publishing.$fromPackage" relocate(fromPackage, toPackage) @@ -44,7 +44,7 @@ val shadow = tasks.named("shadowJar") { } val jar = tasks.named("jar") { - dependsOn(shadow) - from(zipTree(shadow.get().archiveFile)) + dependsOn(shadowJar) + from(zipTree(shadowJar.get().archiveFile)) this.duplicatesStrategy = DuplicatesStrategy.INCLUDE } \ No newline at end of file diff --git a/build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/SonatypeRestApiClient.kt b/build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/SonatypeRestApiClient.kt index fda0d1637d..029bb3606a 100644 --- a/build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/SonatypeRestApiClient.kt +++ b/build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/SonatypeRestApiClient.kt @@ -80,7 +80,8 @@ class SonatypeRestApiClient( logger.info("Closing repository '${repo.id}'") buildRequest("service/local/staging/bulk/close") { val request = "{\"data\":{\"stagedRepositoryIds\":[\"${repo.id}\"]}}" - post(Xml.serialize(request).toRequestBody(Json.mediaType)) + post(request.toRequestBody(Json.mediaType)) + .addHeader("Accept", Json.mediaType.toString()) }.execute { responseBody -> logger.info("Finished closing repository '${repo.id}': '${responseBody.string()}'") } diff --git a/compose/settings.gradle.kts b/compose/settings.gradle.kts index 443f932168..2ee48851ee 100644 --- a/compose/settings.gradle.kts +++ b/compose/settings.gradle.kts @@ -6,7 +6,7 @@ pluginManagement { maven("https://maven.pkg.jetbrains.space/public/p/space/maven") } dependencies { - classpath("org.jetbrains.compose.internal.build-helpers:publishing:0.1.0") + classpath("org.jetbrains.compose.internal.build-helpers:publishing:0.1.3") } } } diff --git a/idea-plugin/build.gradle.kts b/idea-plugin/build.gradle.kts index 742d9e7e58..0904fbb8c6 100644 --- a/idea-plugin/build.gradle.kts +++ b/idea-plugin/build.gradle.kts @@ -3,8 +3,8 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile plugins { id("java") id("org.jetbrains.kotlin.jvm") version "1.5.10" - id("org.jetbrains.intellij") version "1.1.2" - id("org.jetbrains.changelog") version "1.1.2" + id("org.jetbrains.intellij") version "1.3.0" + id("org.jetbrains.changelog") version "1.3.1" } val projectProperties = ProjectProperties(project) diff --git a/idea-plugin/gradle.properties b/idea-plugin/gradle.properties index 077072f910..a823eb6ac6 100644 --- a/idea-plugin/gradle.properties +++ b/idea-plugin/gradle.properties @@ -1,12 +1,12 @@ # Opt-out flag for bundling Kotlin standard library. # See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details. -kotlin.stdlib.default.dependency = false +kotlin.stdlib.default.dependency=false deploy.version=0.1-SNAPSHOT plugin.channels=snapshots plugin.since.build=203 -plugin.until.build=212.* +plugin.until.build=213.* ## See https://jb.gg/intellij-platform-builds-list for available build versions. plugin.verifier.ide.versions=2020.3.2, 2021.1 diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/ConfigurePreviewTaskNameCache.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/ConfigurePreviewTaskNameCache.kt index 83948e2c0b..f5e07fc90f 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/ConfigurePreviewTaskNameCache.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/ConfigurePreviewTaskNameCache.kt @@ -13,7 +13,6 @@ import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project import com.intellij.util.concurrency.annotations.RequiresReadLock -import org.jetbrains.kotlin.idea.configuration.KotlinTargetData import org.jetbrains.plugins.gradle.settings.GradleSettings import org.jetbrains.plugins.gradle.util.GradleConstants @@ -30,7 +29,7 @@ internal class ConfigurePreviewTaskNameProviderImpl : ConfigurePreviewTaskNamePr val modulePath = ExternalSystemApiUtil.getExternalProjectPath(module) ?: return null val moduleNode = moduleDataNodeOrNull(module.project, modulePath) if (moduleNode != null) { - val target = ExternalSystemApiUtil.getChildren(moduleNode, KotlinTargetData.KEY).singleOrNull() + val target = ExternalSystemApiUtil.getChildren(moduleNode, kotlinTargetDataKey).singleOrNull() if (target != null) { return previewTaskName(target.data.externalName) } diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewLocation.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewLocation.kt index ceb50191a6..bf8920b006 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewLocation.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewLocation.kt @@ -8,7 +8,6 @@ package org.jetbrains.compose.desktop.ide.preview import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.util.concurrency.annotations.RequiresReadLock -import org.jetbrains.kotlin.idea.debugger.getService import org.jetbrains.kotlin.psi.KtNamedFunction data class PreviewLocation(val fqName: String, val modulePath: String, val taskName: String) @@ -21,7 +20,7 @@ internal fun KtNamedFunction.asPreviewFunctionOrNull(): PreviewLocation? { val module = ProjectFileIndex.getInstance(project).getModuleForFile(containingFile.virtualFile) if (module == null || module.isDisposed) return null - val service = project.getService() + val service = project.getService(PreviewStateService::class.java) val previewTaskName = service.configurePreviewTaskNameOrNull(module) ?: DEFAULT_CONFIGURE_PREVIEW_TASK_NAME val modulePath = ExternalSystemApiUtil.getExternalProjectPath(module) ?: return null return PreviewLocation(fqName = fqName, modulePath = modulePath, taskName = previewTaskName) diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewStateService.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewStateService.kt index 1beba8abb8..3a85c90f84 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewStateService.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/PreviewStateService.kt @@ -17,7 +17,7 @@ import com.intellij.openapi.util.Disposer import com.intellij.ui.components.JBLoadingPanel import com.intellij.util.concurrency.annotations.RequiresReadLock import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.* -import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID +import org.jetbrains.plugins.gradle.util.GradleConstants import javax.swing.JComponent import javax.swing.event.AncestorEvent import javax.swing.event.AncestorListener @@ -140,7 +140,7 @@ private class ConfigurePreviewTaskNameCacheInvalidator( ) : ExternalSystemTaskNotificationListenerAdapter(null) { override fun onStart(id: ExternalSystemTaskId, workingDir: String?) { if ( - id.projectSystemId == GRADLE_SYSTEM_ID && + id.projectSystemId == GradleConstants.SYSTEM_ID && id.type == ExternalSystemTaskType.RESOLVE_PROJECT ) { configurePreviewTaskNameCache.invalidate() diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/ijCompatibilityUtils.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/ijCompatibilityUtils.kt new file mode 100644 index 0000000000..2f52a60774 --- /dev/null +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/desktop/ide/preview/ijCompatibilityUtils.kt @@ -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 = 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 +} \ No newline at end of file