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

Kotlin Support #722

Open
Jaimss opened this issue Jun 12, 2020 · 22 comments
Open

Kotlin Support #722

Jaimss opened this issue Jun 12, 2020 · 22 comments
Labels
status: accepted This is a high-priority feature or a reproduced bug status: needs investigation status: unverified Needs triage type: enhancement

Comments

@Jaimss
Copy link

Jaimss commented Jun 12, 2020

Hi, I love using this plugin to setup my minecraft plugin projects. In the past I have always used Java, but recently, I switched to Kotlin because I personally like it more and I think it is better.

Would it be possible to add Kotlin support to the options when setting up a project?

@DenWav
Copy link
Member

DenWav commented Jun 16, 2020

Maybe, depends on when Jetbrain's multi JVM language API work truly gets to a point when it can support it. The issue now is any features written for Java don't work for Kotlin, though that should be changing / is changing due to new API changes Jetbrains is working on. If it's to the point where mcdev features work or only require minor changes to work then it's something to consider possibly.

@Jaimss
Copy link
Author

Jaimss commented Jun 16, 2020

Alright. It’s not too big of a deal. I just have to recreate my main class as a kotlin class and add maven dependencies for kotlin to set it up, but if it could be automatic, that would we awesome!

@SmushyTaco
Copy link

+1

@TheFruxz
Copy link

Problem? NO!

I don't see a problem in using Kotlin on a bukkit server, because libraries from e.g. https://dev.bukkit.org/projects/kotlin are adding the "compatibility" directly.

On the contrary, currently it is easier than ever to use the programming language Kotlin in a Java environment!

For comparison, Forge usually has to be installed on the server AND even manually by the user, Kotlin has to be added ONLY as a default plugin by the administrator

Since Kotlin also works directly with Java and refers to it several times, Kotlin is indirectly a Java framework, but I would not go that far :D

It is a fact that nowadays it is not a technical problem to use Kotlin instead of Java or with Java, so that such a feature is important for the current market.

As an example: new Android apps are nowadays also developed natively with Kotlin (problems? NO!)

Since this plugin has unfortunately already 'missed' some new systems, it would be a pity to miss this system as well. For people like me this would be a reason to change to another system or to develop a plugin which offers these basic simple functions and extended support.

And if you need help inserting the Kotlin-Dependency, you can create a community call, maybe even report me yourself.

Partially taken from closed issue #749

@Earthcomputer
Copy link
Member

There is no reason to spam. Lack of kotlin support in the plugin is a technical limitation. If we didn't see the merits of kotlin, do you really think MinecraftDev itself would be written in kotlin?

@davenathanael
Copy link

Hello, sorry for replying to an old-ish issue. I'm new to JVM dependency-management world such as Gradle/Maven (coming from JS/Python/Go), and would like to try on developing Spigot plugins.

I'm currently trying to use Kotlin as the language. I understand MinecraftDev currently does not support Kotlin yet, but with the spirit of "getting the minimal workspace right" (what I feel from this project, similar to "bootstraper", boilerplate, scaffolding, generator, etc. from other languages), do you guys have a migration guide for migrating Java-Gradle Spigot plugin MinecraftDev project to use Kotlin? I have looked around at some repositories here on GitHub but seems everyone have their own way to setup the Gradle etc. If that's currently available, or if there's a recommended article/repository that I can refer to, that'd be great, but if there's none currently, that's ok as well. Thanks and cheers :)

@Jaimss
Copy link
Author

Jaimss commented Sep 11, 2020

I haven't used the MinecraftDev setup in a while, but iirc it sets up your plugin.yml and leaves you with a project structure similar to this:
src/main/java // java code would go here
I think they also put a Main class in that directory, which I would delete cause its in java.
src/main/resources // plugin.yml, config.yml, etc.

When I do plugins, I just add a folder to that structure at
/src/main/kotlin // kotlin code goes here
I also would usually create a new package inside the kotlin folder called dev.jaims.pluginname, but afaik you don't really need to do that.
Inside there you also have to setup your main class. Here is a quick example of what that might look like in Kotlin.

package dev.jaims.relicthub

import dev.jaims.mcutils.bukkit.log
import dev.jaims.mcutils.bukkit.register
import dev.jaims.relicthub.listener.JoinLeaveListener
import org.bukkit.plugin.java.JavaPlugin

class RelictHub : JavaPlugin() {

    // startup login
    override fun onEnable() {

    }

    // shutdown logic
    override fun onDisable() {

    }
}

You shouldn't need to change much of the build.gradle, but I've copied a recent one I did for a 1.16 paper plugin.

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.4.0'
    id 'com.github.johnrengelman.shadow' version '6.0.0'
}

group 'dev.jaims'
version '1.0'

shadowJar {
    archiveClassifier.set("")
}

repositories {
    mavenCentral()
    maven { url 'https://papermc.io/repo/repository/maven-public/' }
    maven { url 'https://repo.jaims.dev/repository/maven-releases' }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    implementation 'dev.jaims.mcutils:bukkit:2.1.1'
    compileOnly 'com.destroystokyo.paper:paper-api:1.16.1-R0.1-SNAPSHOT'
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

I think the only difference is adding the compileKotlin and compileTestKotlin tasks, as well as the kotlin std lib and kotlin plugin. I also added the shadowJar stuff to be able to shade dependencies.

Hopefully this sorta answered what you were asking, but to sum it all up, I would usually just add the two Kotlin tasks, then start writing code at /src/main/kotlin or similar depending on what your package name is and where in your project its located.

@davenathanael
Copy link

Thank you for your suggestion @Jaimss!

@stale
Copy link

stale bot commented Dec 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Dec 19, 2020
@DenWav DenWav added the status: accepted This is a high-priority feature or a reproduced bug label Dec 27, 2020
@stale stale bot removed the status: stale label Dec 27, 2020
@DenWav
Copy link
Member

DenWav commented Dec 27, 2020

To shed more light on what the technical limitation is:

Creating a project with a Kotlin template is very easy. Not hard at all, and that's NOT the issue we are referring to.

The plugin does a lot more than simply project creation. It's kind of disheartening how few people seem to actually understand that, but regardless, it does. I have pretty high standards for my own projects and work, and I am not going to release a half-baked feature. Creating a project in Kotlin when none of the other inspections and quick fixes that this plugin provides also work in Kotlin would definitely be half-baked.

I didn't realize I hadn't marked this issue as accepted, so I did that. Hopefully that makes it more clear about where we stand on this, I hope.

@Earthcomputer Earthcomputer pinned this issue Jan 7, 2021
@onion108
Copy link

onion108 commented Oct 6, 2021

+1

@nm17
Copy link

nm17 commented Oct 8, 2021

Definitely need an update on this, this is still an issue

@re-ovo
Copy link

re-ovo commented Dec 16, 2021

+1

2 similar comments
@JadeNeoma
Copy link

+1

@Schmarni-Dev
Copy link

+1

@mindsolve
Copy link

Hi everyone! I would love to see full first class support for Kotlin, especially including all the quick fixes and inspections.
Would donations or putting a "bounty" on this issue help dedicating more time/resources, or would it just needlessly increase pressure?

@filename24
Copy link

+1

2 similar comments
@jcurtis06
Copy link

+1

@astridlol
Copy link

+1

@XyperCode
Copy link

XyperCode commented Feb 5, 2023

It seems like it throws internal errors when using Kotlin in Architectury mods too.
https://github.com/minecraft-dev/mcdev-error-report/issues/312#issuecomment-1416067901

@T3sT3ro
Copy link

T3sT3ro commented Feb 25, 2023

Has there been any work done on this matter and is there some kind of list of things that would have to be implemented (or list of blockers) for this issue to get closed? Maybe if we can all work together then this can be finished.

@FaultyFunctions
Copy link

Any news on adding Kotlin support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted This is a high-priority feature or a reproduced bug status: needs investigation status: unverified Needs triage type: enhancement
Projects
None yet
Development

No branches or pull requests