Skip to content

Commit

Permalink
Fix Kotlin Multiplatform support
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierSegoviaCordoba committed Sep 2, 2024
1 parent bd97afc commit 4ab84de
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 60 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Fixed

- Kotlin multiplatform support

### Removed

### Updated
Expand Down
7 changes: 4 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[versions]
hubdle = "0.7.8"
hubdleCatalog = "0.3.7"
javiersc-kotlin-compiler-extensions = "0.3.0+2.0.20"
hubdle = "0.7.10"
hubdleCatalog = "0.3.8"
javiersc-kotlin-compiler-extensions = "0.4.1+2.0.20"

[libraries]
hubdle-catalog = { module = "com.javiersc.hubdle:hubdle-version-catalog", version.ref = "hubdleCatalog" }
javiersc-kotlin-compiler-extensions = { module = "com.javiersc.kotlin:kotlin-compiler-extensions", version.ref = "javiersc-kotlin-compiler-extensions" }
javiersc-kotlin-compiler-gradle-extensions = { module = "com.javiersc.kotlin:kotlin-compiler-gradle-extensions", version.ref = "javiersc-kotlin-compiler-extensions" }
javiersc-kotlin-compiler-test-extensions = { module = "com.javiersc.kotlin:kotlin-compiler-test-extensions", version.ref = "javiersc-kotlin-compiler-extensions" }

[plugins]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.javiersc.kotlin.kopy.compiler.fir.generation
import com.javiersc.kotlin.compiler.extensions.fir.asFirOrNull
import com.javiersc.kotlin.kopy.compiler.kopyClassId
import com.javiersc.kotlin.kopy.compiler.kopyFqName
import com.javiersc.kotlin.kopy.compiler.utils.toName
import com.javiersc.kotlin.kopy.compiler.setName
import org.jetbrains.kotlin.KtFakeSourceElementKind.AssignmentPluginAltered
import org.jetbrains.kotlin.fakeElement
import org.jetbrains.kotlin.fir.FirSession
Expand Down Expand Up @@ -77,7 +77,7 @@ internal class FirKopyAssignExpressionAltererExtension(
argumentList = buildUnaryArgumentList(rightArgument)
calleeReference = buildSimpleNamedReference {
source = variableAssignment.source
name = "set".toName()
name = setName
}
origin = FirFunctionCallOrigin.Regular
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package com.javiersc.kotlin.kopy.compiler.fir.generation

import com.javiersc.kotlin.compiler.extensions.common.toName
import com.javiersc.kotlin.compiler.extensions.fir.createFirAnnotation
import com.javiersc.kotlin.compiler.extensions.fir.toFirTypeRef
import com.javiersc.kotlin.kopy.args.KopyFunctions
Expand All @@ -24,7 +25,6 @@ import com.javiersc.kotlin.kopy.compiler.setName
import com.javiersc.kotlin.kopy.compiler.underscoreAtomicName
import com.javiersc.kotlin.kopy.compiler.updateEachName
import com.javiersc.kotlin.kopy.compiler.updateName
import com.javiersc.kotlin.kopy.compiler.utils.toName
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.javiersc.kotlin.kopy.compiler.ir.utils

import com.javiersc.kotlin.compiler.extensions.ir.hasAnnotation
import com.javiersc.kotlin.kopy.compiler.kopyFunctionCopyFqName
import com.javiersc.kotlin.kopy.compiler.kopyFunctionInvokeFqName
import com.javiersc.kotlin.kopy.compiler.kopyFunctionSetFqName
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.javiersc.kotlin.kopy.compiler

import com.javiersc.kotlin.kopy.compiler.utils.toCallableId
import com.javiersc.kotlin.kopy.compiler.utils.toClassId
import com.javiersc.kotlin.kopy.compiler.utils.toFqName
import com.javiersc.kotlin.kopy.compiler.utils.toName
import com.javiersc.kotlin.compiler.extensions.common.toCallableId
import com.javiersc.kotlin.compiler.extensions.common.toClassId
import com.javiersc.kotlin.compiler.extensions.common.toFqName
import com.javiersc.kotlin.compiler.extensions.common.toName
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
Expand Down
8 changes: 8 additions & 0 deletions kopy-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ hubdle {
format.isEnabled = false
projectConfig { //
generateProjectData(true)
generateAdditionalData {
const(
name = "compilerExtensions",
type = "String",
value = "${hubdle.javiersc.kotlin.compiler.extensions.get()}",
)
}
}
publishing()
}
Expand Down Expand Up @@ -59,6 +66,7 @@ hubdle {
dependencies {
implementation(gradleKotlinDsl())
api(projects.kopyArgs)
implementation(libs.javiersc.kotlin.compiler.gradle.extensions)
compileOnly(projects.kopyCompiler)
compileOnly(hubdle.jetbrains.kotlin.gradle.plugin)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.javiersc.kotlin.kopy.gradle.plugin

import com.javiersc.gradle.logging.extensions.warnColored
import com.javiersc.kotlin.compiler.gradle.extensions.KotlinCompilerGradlePlugin
import com.javiersc.kotlin.kopy.args.KopyFunctions
import com.javiersc.kotlin.kopy.args.KopyVisibility
import com.javiersc.kotlin.kopy.compiler.KopyCompilerProjectData
Expand All @@ -15,7 +16,6 @@ import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.the
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
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
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
Expand All @@ -24,21 +24,28 @@ public class KopyGradlePlugin
@Inject
constructor(
private val providers: ProviderFactory,
) : KotlinCompilerPluginSupportPlugin {
) : KotlinCompilerGradlePlugin {

private val Project.kopy: KopyExtension
get() = the<KopyExtension>()


override fun apply(target: Project) {
super.apply(target)
target.createExtension()
target.withKotlin {
suppressKopyOptInt()
reportKotlinVersion()
}
target.withKotlinAndroid { dependencies { "api"(kopyRuntime) } }
target.withKotlinJvm { dependencies { "api"(kopyRuntime) } }
target.withKotlinMultiplatform { dependencies { "commonMainApi"(kopyRuntime) } }
target.withKotlinMultiplatform {
dependencies {
"commonMainApi"(kopyRuntime)
compilerClasspath(kopyArgs)
compilerClasspath(kopyRuntime)
compilerClasspath(KopyGradlePluginAdditionalData.compilerExtensions)
}
}
}

override fun applyToCompilation(
Expand Down Expand Up @@ -113,5 +120,8 @@ constructor(
}
}

private const val kopyArgs =
"com.javiersc.kotlin:kopy-args:${KopyCompilerProjectData.Version}"

private const val kopyRuntime =
"com.javiersc.kotlin:kopy-runtime:${KopyCompilerProjectData.Version}"

0 comments on commit 4ab84de

Please sign in to comment.