JakeWharton / mosaic

Build terminal UI in Kotlin using Jetpack Compose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't figure out how to setup with kts files

ColtonIdle opened this issue · comments

I want to start experimenting with mosaic so I did a file > new project in intellij and followed the wizard for a gradle cmd line app. I added a few lines based on the readme and ended up with this

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version "1.5.10"
    application
    id("com.jakewharton.mosaic")
}

group = "me.coltonidle"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    testImplementation(kotlin("test-junit"))
}

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10")
        classpath("com.jakewharton.mosaic:mosaic-gradle-plugin:0.1.0")
    }
}

tasks.test {
    useJUnit()
}

tasks.withType<KotlinCompile>() {
    kotlinOptions.jvmTarget = "1.8"
}

application {
    mainClassName = "MainKt"
}

when building though I get an error of Plugin [id: 'com.jakewharton.mosaic'] was not found in any of the following sources:

I've only really only ever done android development so maybe I'm doing something really wrong here

Try putting the buildscript at the very top (it is required first to get the plugin).

My example (but not in .kts)

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10'
        classpath 'com.jakewharton.mosaic:mosaic-gradle-plugin:0.1.0'
    }
}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.5.10'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.10'
    id 'com.jakewharton.mosaic' version '0.1.0'
}

Thanks. I ended up with something like this:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10")
        classpath("com.jakewharton.mosaic:mosaic-gradle-plugin:0.1.0")
    }
}

plugins {
    id("org.jetbrains.kotlin.jvm") version "1.5.10"
    id("org.jetbrains.kotlin.plugin.serialization") version "1.5.10"
    id("com.jakewharton.mosaic") version "0.1.0"
    application
}

group = "me.coltonidle"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    testImplementation(kotlin("test-junit"))
}

tasks.test {
    useJUnit()
}

tasks.withType<KotlinCompile>() {
    kotlinOptions.jvmTarget = "1.8"
}

application {
    mainClassName = "MainKt"
}

and it at least builds and compiles.