Hi! I am using a Kotlin DSL gradle file but I cannot manage to get a plugin working... I'd like to ...
m
Hi! I am using a Kotlin DSL gradle file but I cannot manage to get a plugin working... I'd like to compile a little program and send it over to my RaspberryPi. I am basing myself on [a working example using groovy DSL](https://github.com/jinqian/kotlin-native-chifoumi/blob/master/project/build.gradle) I start by declaring a remote which, even though it looks red on my IDE, seems like it works:
Copy code
plugins {
    id("org.hidetake.ssh")
}
remotes {
    create("raspberry") {
        host = "192.168.1.36"
        user = "pi"
        password = "doesntmatter"
    }
}
But when I start declaring the gradle task all falls apart:
Copy code
tasks.register("deploy-to-pi") {
    doLast{
        ssh.run {
            session(remotes["raspberry"]) {

            }
        }
    }
}
With:
Unresolved reference: session
v
You use the Kotlin
run
function, not the one from that plugin. That plugin is written very Groovy-specific, so you need some ugliness unless you request from the author a nicer Kotlin compatibility. I think this should work:
Copy code
tasks.register("deploy-to-pi") {
    doLast{
        ssh.run(delegateClosureOf<RunHandler> {
            session(remotes["raspberry"], delegateClosureOf<SessionHandler> {
            })
        })
    }
}
m
Thank you for your comment I'll try it as soon as I get on the project!
It's been a while. But I've tried that and I couldn't get it to work. I've created a custom task to handle copying the distributable over the RPi
Copy code
tasks.register<Exec>("deploy-geckos") {
    group ="build"
    dependsOn("packageDeb")
    val fileToSend = "$buildDir/libs/desktop-jvm-1.0.0.jar"
    commandLine("sshpass", "-p", "pass", "scp", fileToSend, "user@host://home/pi/Desktop")

}
Of course we could omit sshpass if we sent our ssh key to RPi
v
What has that to do with the
run
method execution? confused
m
I couldn't get it to work and I ditched the previous approach as it was causing too much of a headache for something I would've done in Make under a minute. It's not related to the run method execution because I am no longer using that
v
Ah, I see
152 Views