architectury-templates icon indicating copy to clipboard operation
architectury-templates copied to clipboard

Kotlin Templates

Open Samarium150 opened this issue 3 years ago • 8 comments

It would be wonderful if there are templates using Kotlin, just like Adorn

Samarium150 avatar Feb 12 '22 15:02 Samarium150

Kotlin templates as in templates using Kotlin or templates in Kotlin? (as gradle.kts)

shedaniel avatar Feb 12 '22 19:02 shedaniel

Kotlin templates as in templates using Kotlin or templates in Kotlin? (as gradle.kts)

Maybe both? For me, it's a little weird that source code uses kotlin, but gradle files use groovy.

Samarium150 avatar Feb 13 '22 01:02 Samarium150

kts doesn't support allprojects and subprojects block (see https://stackoverflow.com/questions/60142502/gradle-kotlin-dsl-problems-with-subprojects-and-plugins).So it may hard to convert build.gradle to build.gradle.kts .

CubeSugarCheese avatar May 20 '22 13:05 CubeSugarCheese

kts does support them just fine, it's just that the type-safe accessors for configurations, extensions and tasks aren't generated so you have to use strings and getByName etc. (See for example my build.gradle.kts where I use subprojects blocks heavily)

Juuxel avatar May 20 '22 13:05 Juuxel

@CubeSugarCheese As @Juuxel said, it should support now. This post is outdated.

Samarium150 avatar May 20 '22 13:05 Samarium150

Also the post is correct and up-to-date afaik, it just says you can't use type-safe accessors but the answer itself is using subprojects/allprojects.

(However, it's not exactly correct about the "import statements" etc since plugins and buildscript don't generate imports. plugins does generate extra type-safe accessors though)

Juuxel avatar May 20 '22 13:05 Juuxel

Also the post is correct and up-to-date afaik, it just says you can't use type-safe accessors but the answer itself is using subprojects/allprojects.

(However, it's not exactly correct about the "import statements" etc since plugins and buildscript don't generate imports. plugins does generate extra type-safe accessors though)

well,I tried to convert groovy to kts but failed. Seeing your build.gradle.kts, I find the different is not a little which in groovy and kts. If it's possible,I want to get official kts support in next template release.

CubeSugarCheese avatar May 21 '22 03:05 CubeSugarCheese

Now, I transform groovy to kts successfully. But it still have some problems. https://github.com/CubeSugarCheese/architectury-template-kotlin-dsl Based on 1.18.2-forge-fabric-quilt-mixin

CubeSugarCheese avatar May 26 '22 13:05 CubeSugarCheese