1.15.2 Problem with Kotlin

Discussion in 'Spigot Plugin Development' started by eirikh1996, Feb 15, 2020.

  1. Hello. I am trying to make a plugin with Kotlin as well as building it woth Maven. However, I have a serious problem. Maven is not resolving the recent bukkit artifact, causing the build to error when running mvn clean install. Here is my current POM:
    HTML:
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

        <modelVersion>4.0.0</modelVersion>

        <groupId>org.example</groupId>
        <artifactId>UltraWorldGenerator</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>

        <name>org.example UltraWorldGenerator</name>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <kotlin.version>1.3.61</kotlin.version>
            <kotlin.code.style>official</kotlin.code.style>
            <junit.version>4.12</junit.version>
        </properties>
        <repositories>
            <repository>
                <id>spigot-repo</id>
                <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
            </repository>
        </repositories>
        <dependencies>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-test-junit</artifactId>
                <version>${kotlin.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-test</artifactId>
                <version>${kotlin.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.15.2-R0.1-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-stdlib-jdk8</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
        </dependencies>

        <build>
            <sourceDirectory>src/main/kotlin</sourceDirectory>

            <plugins>
                <plugin>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-plugin</artifactId>
                    <version>${kotlin.version}</version>
                    <executions>
                        <execution>
                            <id>compile</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>test-compile</id>
                            <phase>test-compile</phase>
                            <goals>
                                <goal>test-compile</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <jvmTarget>1.8</jvmTarget>
                    </configuration>
                </plugin>
            </plugins>
        </build>

    </project>
     
    What is wrong here?
     
  2. Have you tried forcing the maven resolve again?
     
  3. Is there a reason you have bukkit as your dependency rather than spigot-api?

    Code (Text):
    <groupId>org.spigotmc</groupId>
    <artifactId>spigot-api</artifactId>
    p.s. you'll likely need to shade in kotlin too
     
    • Agree Agree x 1
  4. You should never shade the spigot api, use <scope>provided</scope>
     
  5. I said shade kotlin lib, not spigot
     
  6. Yes but you have no scope defined for the bukkit api, you should ass the provided scope
     
  7. I never said anything about dependency scoping :p