Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial migration to native #808

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/deployment-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- '**' # We want to run this on all branch pushes
tags-ignore:
- '**' # We don't want this to run on tags pushes
branches-ignore:
# CI is not setup for Native
- 'feature/native'
pull_request:
release:
types: [ published ]
Expand Down
7 changes: 5 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ plugins {
org.jetbrains.dokka // for dokkaHtmlMultiModule task
}

repositories {
mavenCentral()
allprojects {
repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
}
}

group = Library.group
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
}

repositories {
gradlePluginPortal()
mavenCentral()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
org.jetbrains.kotlin.multiplatform
}
Expand All @@ -6,7 +8,9 @@ repositories {
mavenCentral()
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()
jvm()
js(IR) {
nodejs()
Expand Down
73 changes: 59 additions & 14 deletions buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import org.gradle.configurationcache.extensions.capitalized
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest

plugins {
Expand All @@ -22,7 +24,22 @@ apiValidation {
applyKordBCVOptions()
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default {
common {
group("nonJvm") {
withNative()
withJs()
}

group("nonNative") {
withJs()
withJvm()
}
}
}

explicitApi()

jvm()
Expand Down Expand Up @@ -50,17 +67,6 @@ kotlin {
implementation(project(":test-kit"))
}
}
val nonJvmMain by creating {
dependsOn(commonMain.get())
}
targets
.map { it.name }
.filter { it != "jvm" && it != "metadata" }
.forEach { target ->
sourceSets.getByName("${target}Main") {
dependsOn(nonJvmMain)
}
}
}
}

Expand All @@ -75,10 +81,49 @@ tasks {
environment("PROJECT_ROOT", rootProject.projectDir.absolutePath)
}

for (task in listOf("compileKotlinJvm", "compileKotlinJs", "jvmSourcesJar", "jsSourcesJar")) {
named(task) {
dependsOn("kspCommonMainKotlinMetadata")
afterEvaluate {
val compilationTasks = kotlin.targets.flatMap {
buildList {
add("compileKotlin${it.name.capitalized()}")
val sourcesJarName = "${it.name}SourcesJar"
add(sourcesJarName)
}
}
for (task in compilationTasks) {
named(task) {
dependsOn("kspCommonMainKotlinMetadata")
}
}
}


register("publishNonNative") {
dependsOn(
"publishKotlinMultiplatformPublicationToMavenRepository",
"publishJsPublicationToMavenRepository",
"publishJvmPublicationToMavenRepository"
)
}

register("publishLinux") {
dependsOn("publishLinuxX64PublicationToMavenRepository")
}

register("publishMingw") {
dependsOn("publishMingwX64PublicationToMavenRepository")
}

register("publishDarwin") {
dependsOn(
"publishMacosArm64PublicationToMavenRepository",
"publishMacosX64PublicationToMavenRepository",
"publishIosArm64PublicationToMavenRepository",
"publishIosX64PublicationToMavenRepository",
"publishWatchosX64PublicationToMavenRepository",
"publishWatchosArm64PublicationToMavenRepository",
"publishTvosX64PublicationToMavenRepository",
"publishTvosArm64PublicationToMavenRepository"
)
}

afterEvaluate {
Expand Down
32 changes: 32 additions & 0 deletions buildSrc/src/main/kotlin/kord-native-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import org.apache.tools.ant.taskdefs.condition.Os

plugins {
org.jetbrains.kotlin.multiplatform
}

kotlin {
if(!Os.isFamily(Os.FAMILY_WINDOWS)) {
linuxX64()
// Waiting for Ktor
// https://youtrack.jetbrains.com/issue/KTOR-872
//linuxArm64()
}


mingwX64()

macosArm64()
macosX64()

iosArm64()
iosX64()
// iosSimulatorArm64()

watchosX64()
watchosArm64()
// watchosSimulatorArm64()

tvosX64()
tvosArm64()
// tvosSimulatorArm64()
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/kord-publishing.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ signing {
val secretKey = getenv("SIGNING_KEY")?.let { String(Base64.getDecoder().decode(it)) }
val password = getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(secretKey, password)
sign(publishing.publications)
//sign(publishing.publications)
}
90 changes: 90 additions & 0 deletions common/api/common.api
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,96 @@ public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetada
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord {
public static final field Companion Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord$Companion;
public synthetic fun <init> (ILdev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;)V
public synthetic fun <init> (Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()Ldev/kord/common/entity/optional/Optional;
public final fun component5 ()Ljava/lang/String;
public final fun component6 ()Ldev/kord/common/entity/optional/Optional;
public final fun copy (Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord;
public static synthetic fun copy$default (Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord;Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;Ljava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord;
public fun equals (Ljava/lang/Object;)Z
public final fun getDescription ()Ljava/lang/String;
public final fun getDescriptionLocalizations ()Ldev/kord/common/entity/optional/Optional;
public final fun getKey ()Ljava/lang/String;
public final fun getName ()Ljava/lang/String;
public final fun getNameLocalizations ()Ldev/kord/common/entity/optional/Optional;
public final fun getType ()Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecord$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public abstract class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public static final field Companion Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$Companion;
public synthetic fun <init> (ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun equals (Ljava/lang/Object;)Z
public final fun getValue ()I
public final fun hashCode ()I
public final fun toString ()Ljava/lang/String;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$BooleanEqual : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public static final field INSTANCE Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$BooleanEqual;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$BooleanNotEqual : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public static final field INSTANCE Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$BooleanNotEqual;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$Companion {
public final fun getEntries ()Ljava/util/List;
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$DateTimeGreaterThanOrEqual : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public static final field INSTANCE Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$DateTimeGreaterThanOrEqual;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$DateTimeLessThanOrEqual : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public static final field INSTANCE Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$DateTimeLessThanOrEqual;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$IntegerEqual : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public static final field INSTANCE Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$IntegerEqual;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$IntegerGreaterThanOrEqual : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public static final field INSTANCE Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$IntegerGreaterThanOrEqual;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$IntegerLessThanOrEqual : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public static final field INSTANCE Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$IntegerLessThanOrEqual;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$IntegerNotEqual : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public static final field INSTANCE Ldev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$IntegerNotEqual;
}

public final class dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType$Unknown : dev/kord/common/entity/DiscordApplicationRoleConnectionMetadataRecordType {
public fun <init> (I)V
}

public final class dev/kord/common/entity/DiscordAttachment {
public static final field Companion Ldev/kord/common/entity/DiscordAttachment$Companion;
public synthetic fun <init> (ILdev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/String;Ljava/lang/String;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
Expand Down
26 changes: 26 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
`kord-native-module`
`kord-multiplatform-module`
`kord-publishing`
alias(libs.plugins.buildconfig)
Expand Down Expand Up @@ -39,6 +40,31 @@ kotlin {
implementation(projects.kspAnnotations)
}
}

nativeMain {
dependencies {
// Native does not have compileOnly
implementation(projects.kspAnnotations)
}
}

mingwMain {
dependencies {
api(libs.ktor.client.winhttp)
}
}

appleMain {
dependencies {
api(libs.ktor.client.darwin)
}
}

findByName("linuxMain")?.apply {
dependencies {
api(libs.ktor.client.curl)
}
}
}
}

Expand Down
Loading