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

Trouble in implementing Hello Kunafa example #16

Closed
sangeetds opened this issue May 27, 2020 · 12 comments
Closed

Trouble in implementing Hello Kunafa example #16

sangeetds opened this issue May 27, 2020 · 12 comments

Comments

@sangeetds
Copy link

Hi. I'm currently trying to implement this framework by following your Hello Kunafa tutorial. I think I've been able to sync the gradle properly and build the project. But I don't see anything when I open the index.html file.
I've followed the instructions and modified the build.gradle and created index and app.kt. The build shows successful but I can't see anything when I open the html file.(I'm using gradle build, also tried gradle assembleWeb and gradle compileK2J). Is there anything else in the 'Hello Kunafa' tutorial that I need to do?

@Kabbura
Copy link
Member

Kabbura commented May 27, 2020

Hi,
Can you post your build.gradle file and your index.html?

@sangeetds
Copy link
Author

Here it is:
index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Kunemo demo</title>
</head>
<body>
    <script type="text/javascript" src="web/kotlin.js"></script>
    <script type="text/javascript" src="web/kunafa.js"></script>
    <script type="text/javascript" src="web/output.js"></script>
</body>
</html>

build.gradle:

buildscript {
    ext.kotlin_version = '1.3.72'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
    }
}

group 'com.narbse'
version '1.0-SNAPSHOT'

apply plugin: 'kotlin2js'

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-js"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-js: 1.3.72"
    compile 'com.narbase:kunafa:0.2.0-beta'
    implementation 'com.narbase:kunafa:0.2.0-beta'
}

task assembleWeb(type: Sync) {
    configurations.compile.each { File file ->
        from(zipTree(file.absolutePath), {
            includeEmptyDirs = false
            include { fileTreeElement ->
                def path = fileTreeElement.path
                path.endsWith(".js") && (path.startsWith("META-INF/resources/") ||
                        !path.startsWith("META-INF/"))
            }
        })
    }
    from compileKotlin2Js.destinationDir
    into "${projectDir}/web"

    dependsOn classes
}

assemble.dependsOn assembleWeb

compileKotlin2Js {
    kotlinOptions.outputFile = "${projectDir}/web/output.js"
    kotlinOptions.moduleKind = "plain"
    kotlinOptions.sourceMap = true
}

@Kabbura
Copy link
Member

Kabbura commented May 27, 2020

I think the Hello Kunafa tutorial has not been updated to use the new KotlinJs plugin (instead of compileKotlin2Js).
To use the new plugin, check this Kunafa Todo
This is build.gradle and this is the index.html.
We will update the Hello Kunafa tutorial shortly.

@sangeetds
Copy link
Author

What command do you use to get your index.html running?
I've tried using
gradle build
and then opening the index.html
Nothing happens.

@Kabbura
Copy link
Member

Kabbura commented May 27, 2020

try ./gradlew run -t
The -t is for continuous build

@sangeetds
Copy link
Author

I'd tried that and I got this error :
Cannot GET /

@Kabbura
Copy link
Member

Kabbura commented May 27, 2020

Interesting..
Can you try to clone the todo app and run ./gradlew run -t and let me know if it works?

@sangeetds
Copy link
Author

Tried that too, unfortunately it isn't working. I think I may be missing something I don't know. I will try once again and let you know

@Kabbura
Copy link
Member

Kabbura commented May 27, 2020

That's really strange.
What version of gradle are you using?

@Kabbura
Copy link
Member

Kabbura commented May 27, 2020

I added the gradle wrapper files to the Todo repo. It's using gradle-6.2-all.zip.
Try to clone it again and run it. I think it should work.

@sangeetds
Copy link
Author

Thanks. I'll clean everything and start from scratch again. I'm using Gradle 6.3. Will let you know what happens

@sangeetds
Copy link
Author

It's working now. Will try and see what could be the problem. Thanks for the help!

@Kabbura Kabbura closed this as completed May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants