Skip to content

Commit

Permalink
Merge pull request #6 from teogor/feature/migrate-to-kotlin-multiplat…
Browse files Browse the repository at this point in the history
…form

Migrate to Kotlin Multiplatform: Add support for JVM, JS, iOS, macOS, Linux, tvOS, and watchOS
  • Loading branch information
teogor committed Aug 28, 2024
2 parents a775424 + 97f7ef7 commit 83b02c0
Show file tree
Hide file tree
Showing 156 changed files with 34,386 additions and 591 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/publish-to-maven.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish

on:
release:
types: [ released ]
workflow_dispatch:

jobs:
publish:
name: Snapshot build and publish
runs-on: macos-latest
environment: PRODUCTION
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

- name: Install GPG
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
run: |
brew install gpg
echo "$SIGNING_KEY" | gpg --dearmor > ${HOME}/secring.gpg
- name: Grant Permission to Execute Gradle
run: chmod +x gradlew

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Publish To Maven Central
run: |
./gradlew publishAllPublicationsToMavenCentral --no-configuration-cache
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ render.experimental.xml

# Google Services (e.g. APIs or Firebase)
google-services.json

# Kotlin
.kotlin
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ Xenoglot is a comprehensive library for representing, managing, and interacting

* **Language Territorialization:** Xenoglot provides functionality for territorializing languages, adapting them to specific geographical or political contexts.

**Kotlin Multiplatform Support**

Xenoglot is designed to work across various platforms through Kotlin Multiplatform, allowing you to use it in JVM, Android, JavaScript, iOS, macOS, Linux, tvOS, and watchOS environments. Here are some of the supported targets:

- **JVM**: Supports Java Virtual Machine with Kotlin configured for JDK 11.
- **Android**: Configured to publish all library variants.
- **JavaScript**: Supports WebAssembly (WASM) and JavaScript IR, including browser and Node.js environments, and generates TypeScript definitions.
- **iOS**: Supports iOS devices and simulators, including `iosX64`, `iosArm64`, and `iosSimulatorArm64`.
- **macOS**: Supports macOS with `macosX64` and `macosArm64`.
- **Linux**: Supports Linux with `linuxX64` and `linuxArm64`.
- **tvOS**: Supports tvOS devices and simulators, including `tvosX64`, `tvosArm64`, and `tvosSimulatorArm64`.
- **watchOS**: Supports watchOS devices and simulators, including `watchosX64`, `watchosArm32`, `watchosArm64`, `watchosDeviceArm64`, and `watchosSimulatorArm64`.

**Installation**

To install Xenoglot, add the following dependency to your build script:
Expand Down Expand Up @@ -55,14 +68,6 @@ val isDialect = Dialect("en-US", Language.English).isDialect
val isScriptUsedInLanguage = Script.Cyrillic.isWrittenIn(Language.Russian)
```

**Interacting with Language Tags**

```kotlin
val languageTag = LanguageTag("fr", LanguageFamily.Romance)
val language = languageTag.asLanguage()
val countryCode = languageTag.substringAfter("-")
```

**Territorializing Languages**

```kotlin
Expand Down
6 changes: 0 additions & 6 deletions android/api/android.api

This file was deleted.

This file was deleted.

166 changes: 83 additions & 83 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import com.vanniktech.maven.publish.SonatypeHost
import dev.teogor.winds.api.MavenPublish
import dev.teogor.winds.api.getValue
import dev.teogor.winds.api.model.Developer
import dev.teogor.winds.api.model.LicenseType
import dev.teogor.winds.api.model.createVersion
import dev.teogor.winds.api.provider.Scm
import dev.teogor.winds.gradle.utils.afterWindsPluginConfiguration
import dev.teogor.winds.gradle.utils.attachTo
import dev.teogor.winds.api.SonatypeHost
import dev.teogor.winds.api.ArtifactIdFormat
import dev.teogor.winds.api.License
import dev.teogor.winds.api.Person
import dev.teogor.winds.api.Scm
import dev.teogor.winds.api.TicketSystem
import dev.teogor.winds.ktx.createVersion
import dev.teogor.winds.ktx.person
import dev.teogor.winds.ktx.scm
import dev.teogor.winds.ktx.ticketSystem
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
import org.jetbrains.dokka.gradle.DokkaPlugin

Expand All @@ -19,101 +20,90 @@ buildscript {

plugins {
// Kotlin Suite
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.jetbrains.kotlin.jvm) apply false
alias(libs.plugins.jetbrains.kotlin.multiplatform) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.jetbrains.kotlin.serialization) apply false

// Android Tools
alias(libs.plugins.android.library) apply false

alias(libs.plugins.winds) apply true
alias(libs.plugins.teogor.winds) apply true

alias(libs.plugins.vanniktech.maven) apply true
alias(libs.plugins.dokka) apply true
alias(libs.plugins.spotless) apply true
alias(libs.plugins.api.validator) apply true
alias(libs.plugins.jetbrains.dokka) apply true
alias(libs.plugins.diffplug.spotless) apply true
alias(libs.plugins.jetbrains.kotlinx.binary.compatibility) apply true

alias(libs.plugins.ben.manes.versions) apply true
alias(libs.plugins.littlerobots.version.catalog.update) apply true
}

winds {
buildFeatures {
mavenPublish = true

features {
mavenPublishing = true
docsGenerator = true
}

mavenPublish {
displayName = "Xenoglot"
name = "xenoglot"

canBePublished = false

description =
"\uD83C\uDF0D Xenoglot seamlessly masters languages and locales, empowering developers to integrate multilingual capabilities into their applications with ease."

groupId = "dev.teogor.xenoglot"
artifactIdElements = 1
url = "https://source.teogor.dev/xenoglot"

version = createVersion(1, 0, 0) {
alphaRelease(1)
moduleMetadata {
name = "Xenoglot"
description = """
|\uD83C\uDF0D Xenoglot seamlessly masters languages and locales, empowering developers to integrate multilingual capabilities into their applications with ease.
""".trimMargin()
yearCreated = 2024
websiteUrl = "https://source.teogor.dev/xenoglot"
apiDocsUrl = "$websiteUrl/html/"

artifactDescriptor {
group = "dev.teogor.xenoglot"
name = "Xenoglot"
artifactIdFormat = ArtifactIdFormat.NAME_ONLY
version = createVersion(1, 0, 0) {
alphaRelease(1)
}
}

// TODO winds
// required by dokka
project.version = version!!.toString()

inceptionYear = 2023

sourceControlManagement(
Scm.Git(
owner = "teogor",
repo = "xenoglot",
),
)
// Providing SCM (Source Control Management)
scm<Scm.GitLab> {
owner = "teogor"
repository = "xenoglot"
}

addLicense(LicenseType.APACHE_2_0)
// Providing Ticket System
ticketSystem<TicketSystem.GitHub> {
owner = "teogor"
repository = "xenoglot"
}

addDeveloper(TeogorDeveloper())
// Providing Licenses
licensedUnder(License.Apache2())

// Providing Persons
person<Person.DeveloperContributor> {
id = "teogor"
name = "Teodor Grigor"
email = "open-source@teogor.dev"
url = "https://teogor.dev"
roles = listOf("Code Owner", "Developer", "Designer", "Maintainer")
timezone = "UTC+2"
organization = "Teogor"
organizationUrl = "https://github.com/teogor"
}
}

docsGenerator {
name = "Xenoglot"
identifier = "xenoglot"
alertOnDependentModules = true
publishing {
cascade = true
enablePublicationSigning = true
optInForVanniktechPlugin = true
sonatypeHost = SonatypeHost.S01
}
}

afterWindsPluginConfiguration { winds ->
val mavenPublish: MavenPublish by winds
if (mavenPublish.canBePublished) {
mavenPublishing {
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()

@Suppress("UnstableApiUsage")
pom {
coordinates(
groupId = mavenPublish.groupId!!,
artifactId = mavenPublish.artifactId!!,
version = mavenPublish.version!!.toString(),
)
mavenPublish attachTo this
}
}
documentationBuilder {
htmlPath = "html/"
markdownNewlineSeparator = " "
}
}

data class TeogorDeveloper(
override val id: String = "teogor",
override val name: String = "Teodor Grigor",
override val email: String = "open-source@teogor.dev",
override val url: String = "https://teogor.dev",
override val roles: List<String> = listOf("Code Owner", "Developer", "Designer", "Maintainer"),
override val timezone: String = "UTC+2",
override val organization: String = "Teogor",
override val organizationUrl: String = "https://github.com/teogor",
) : Developer

val ktlintVersion = "0.50.0"

val excludedProjects = listOf(
Expand All @@ -128,9 +118,8 @@ subprojects {
target("**/*.kt")
targetExclude("**/build/**/*.kt")
ktlint(ktlintVersion)
.userData(
.editorConfigOverride(
mapOf(
"ktlint_code_style" to "official",
"ij_kotlin_allow_trailing_comma" to "true",
// These rules were introduced in ktlint 0.46.0 and should not be
// enabled without further discussion. They are disabled for now.
Expand Down Expand Up @@ -195,3 +184,14 @@ subprojects {
}
}
}

versionCatalogUpdate {
keep {
// keep versions without any library or plugin reference
keepUnusedVersions = true
// keep all libraries that aren't used in the project
keepUnusedLibraries = true
// keep all plugins that aren't used in the project
keepUnusedPlugins = true
}
}
Loading

0 comments on commit 83b02c0

Please sign in to comment.