Giter Site home page Giter Site logo

Comments (3)

soywiz avatar soywiz commented on May 13, 2024 1

Can you try the instructions provided in the README? If they work for you I will merge the PR, or adjust it until it is clear.

from klock.

simonegiacomelli avatar simonegiacomelli commented on May 13, 2024 1

Thanks! Now it works.

In the beginning I thought that commonMainApi, jvmMainApi, jsMainApi were functions of gradle that were doing some magic instead of 'implementation' but It wasn't so.
So I just used 'implementation' instead of them.

I will paste here my working build.gradle (in the hope it can be helpful to others)

buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id 'kotlin-multiplatform' version '1.3.21'
}
repositories {
    jcenter()
    maven { url "http://dl.bintray.com/kotlin/ktor" }
    mavenCentral()
    maven { url "https://dl.bintray.com/soywiz/soywiz" }
}
def ktor_version = '1.0.1'
def logback_version = '1.2.3'
def klockVersion = "1.3.1"

kotlin {
    jvm()
    js() {
        compilations.all {
            kotlinOptions {
                languageVersion = "1.3"
                moduleKind = "umd"
                sourceMap = true
                metaInfo = true
            }
        }
    }
    sourceSets {
        commonMain {
            dependencies {
                implementation kotlin('stdlib-common')
                implementation "com.soywiz:klock-metadata:$klockVersion"
            }
        }
        commonTest {
            dependencies {
                implementation kotlin('test-common')
                implementation kotlin('test-annotations-common')
            }
        }
        jvmMain {
            dependencies {
                implementation kotlin('stdlib-jdk8')
                implementation "io.ktor:ktor-server-netty:$ktor_version"
                implementation "io.ktor:ktor-html-builder:$ktor_version"
                implementation "ch.qos.logback:logback-classic:$logback_version"
                implementation 'net.sf.biweekly:biweekly:0.6.3'
                implementation "com.soywiz:klock-jvm:$klockVersion"
            }
        }
        jvmTest {
            dependencies {
                implementation kotlin('test')
                implementation kotlin('test-junit')
            }
        }
        jsMain {
            dependencies {
                implementation kotlin('stdlib-js')
                implementation "com.soywiz:klock-js:$klockVersion"
            }
        }
        jsTest {
            dependencies {
                implementation kotlin('test-js')
            }
        }
    }
}

def webFolder = new File(project.buildDir, "../src/jsMain/web")
def jsCompilations = kotlin.targets.js.compilations

task populateWebFolder(dependsOn: [jsMainClasses]) {
    doLast {
        copy {
            from jsCompilations.main.output
            from kotlin.sourceSets.jsMain.resources.srcDirs
            jsCompilations.test.runtimeDependencyFiles.each {
                if (it.exists() && !it.isDirectory()) {
                    from zipTree(it.absolutePath).matching { include '*.js' }
                }
            }
            into webFolder
        }
    }
}

jsJar.dependsOn(populateWebFolder)

task run(type: JavaExec, dependsOn: [jvmMainClasses, jsJar]) {
    main = "sample.SampleJvmKt"
    classpath { [
            kotlin.targets.jvm.compilations.main.output.allOutputs.files,
            configurations.jvmRuntimeClasspath,
    ] }
    args = []
}

from klock.

webfrea-k avatar webfrea-k commented on May 13, 2024

I have pretty much the same build.gradle as @simonegiacomelli . However, I also have the iOS source set, which is combined into iOSMain:

iOSMain.dependencies {
            implementation "io.ktor:ktor-client-ios:$ktor_version"
            implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
            implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
}
configure([ios_arm64Main, ios_x86_64Main]) {
            dependsOn iOSMain
        }

Adding Klock -iosx64 breaks iosarm64 build and vice-versa.
What would be the correct way to include Klock for iOS simulator (x64) and real device (arm64) in the example above?

from klock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.