firstdarkdev / modpublisher

A dual publishing Gradle Plugin to publish mods to Modrinth, Curseforge and GitHub in one go
MIT License
19 stars 3 forks source link

{Error] No enum constant #25

Closed FaeWulf closed 1 month ago

FaeWulf commented 1 month ago

Got this 2 error when use publishModrinth or publishCurseforge

No enum constant me.hypherionmc.curseupload.constants.CurseReleaseType.BETA           # RELEASE, BETA, ALPHA
No enum constant masecla.modrinth4j.model.version.ProjectVersion.VersionType.BETA           # RELEASE, BETA, ALPHA

Build.gradle:

plugins {
    // see https://fabricmc.net/develop/ for new versions
    id 'fabric-loom' version '1.7-SNAPSHOT' apply false
    // see https://projects.neoforged.net/neoforged/moddevgradle for new versions
    id 'net.neoforged.moddev' version '0.1.110' apply false

    //publisher
    id "com.hypherionmc.modutils.modpublisher" version "2.1.6"
}

//custom task
tasks.register('copyJars', Copy) {

    dependsOn ':fabric:build', ':neoforge:build' // Make sure subprojects are built

    from('fabric/build/libs') {
        include("*${project.version}.jar")
        exclude('*-javadoc.jar', '*-sources.jar', '*-orphaned.jar')
    }

    from('neoforge/build/libs') {
        include("*${project.version}.jar")
        exclude('*-javadoc.jar', '*-sources.jar', '*-orphaned.jar')
    }

    into 'build/'
}

// Trigger the copyJars task after the subprojects' builds are done
gradle.projectsEvaluated {
    copyJars.mustRunAfter ':fabric:build', ':neoforge:build'
}

// Add a custom task to trigger the copy process
tasks.register('buildAll') {
    group = 'build'  // Assign to a visible group in Gradle tab
    description = 'Builds and copies the main JARs from subprojects to the root build folder.'

    //delete(fileTree("build/"))
    dependsOn ':fabric:build', 'neoforge:build', copyJars
}

subprojects { subproject ->
    publisher {
        apiKeys {
            modrinth System.getenv("MODRINTH_TOKEN")
            curseforge System.getenv("CURSEFORGE_TOKEN")
        }

        //debug
        setDebug(true)

        //must set this: supported version
        setGameVersions(minecraft_version, "1.21.1")

        setVersion(project.version)
        setChangelog("CHANGELOG.md")
        setVersionType(version_type as String)

        //jar file to upload
        setArtifact("build/${mod_id}-${subproject.name}-${minecraft_version}-${project.version}.jar")

        setDisableMalwareScanner(true) // Disable the built in Fractureizer scanner.
        setDisableEmptyJarCheck(true)

        // Disable check for valid mod metadata entry in artifact, which could possibly mean that the jar is empty.
        setModrinthID(modrinth_id)
        setCurseID(curseforge_id)

        //set support loader
        switch (subproject.name) {
            case "fabric":
                setLoaders("Fabric", "Quilt")
                break
            case "forge":
                setLoaders("Forge", "NeoForge")
                break
            case "neoforge":
                setLoaders("NeoForge")
                break
        }

        setDisplayName("[${subproject.name} ${minecraft_version}] ${mod_name} v${project.version}")
        //setJavaVersions([java_version])

        setCurseEnvironment("server") // "server", "client" or "both".

        modrinthDepends {
            switch (subproject.name) {
                case "fabric":
                    required "fabric-api"
                    break
                case "forge":
                    break
            }
        }

        curseDepends {
            switch (subproject.name) {
                case "fabric":
                    required "fabric-api"
                    break
                case "forge":
                    break
            }
        }
    }
}

version_type is a propertie from gradle.properties:

version_type=beta
hypherionmc commented 1 month ago

I tried to replicate the issue, with one of the test projects in the plugin, but couldn't.

publisher {
    apiKeys {
        modrinth System.getenv("MODRINTH_TOKEN")
        curseforge System.getenv("CURSE_TOKEN")
        nightbloom("1253")
    }

    setDebug(true)
    setCurseID("1234")
    setModrinthID("dsgfhs79789")
    setVersionType(version_type as String)
    setNightbloomID("craterlib")
    setChangelog("https://raw.githubusercontent.com/hypherionmc/changelogs/main/sdlink/combo.md")
    setProjectVersion("1.20.2-${project.version}")
    setDisplayName("[1.20.x] Simple Discord Link - ${project.version}")
    setGameVersions("1.20", "1.20.1", "1.20.2")
    setLoaders(ModLoader.FABRIC, ModLoader.FORGE)
    setCurseEnvironment(CurseEnvironment.BOTH)
    setArtifact(jar)
    setPlatformArtifact(com.hypherionmc.modpublisher.properties.Platform.MODRINTH, createDummyJar)
    setDisableEmptyJarCheck(true)
    addAdditionalFile(jar)
    setJavaVersions(JavaVersion.VERSION_1_8, "Java 11", 17)
    setIsManualRelease(true)

    addAdditionalFile {
        artifact jar
        displayName "Some Name"
        changelog "Hello Changelog"
    }

    github {
        tag("v${project.version}")
        createTag(true)
        createRelease(true)
        updateRelease(true)
        displayName("Hello World")
    }

    modrinthDepends {
        required "fabric-api", "craterlib"
        required "fabric-api"
    }

    curseDepends {
        required "fabric-api", "craterlib"
    }
}

Is your code maybe available on GitHub so that I can check it out?

FaeWulf commented 1 month ago

Yes, here is my sourcecode: https://github.com/FaeWulf/Diversity The code above is in the root project build.gradle

hypherionmc commented 1 month ago

Was able to reproduce the issue with your repo.

The problem is this: version_type=beta # release, beta, alpha.

Changing it to version_type=beta fixes the issue.

Additionally, your setArtifact path is incorrect.

Changing it to setArtifact("${subproject.buildDir}/libs/${mod_id}-${subproject.name}-${minecraft_version}-${project.version}.jar") fixes it

Finally, your changelog. It should be setChangelog(file("${subproject.rootDir}/CHANGELOG.md")) since you are using a file. As you have it currently set, your changelog will literally be CHANGELOG.md instead of the contents of it

FaeWulf commented 1 month ago

Thank you very much! Solved the issue.

Additionally, your setArtifact path is incorrect.

Changing it to setArtifact("${subproject.buildDir}/libs/${mod_id}-${subproject.name}-${minecraft_version}-${project.version}.jar") fixes it

There is a task above this I use to move all artifact from subproject to the root/build folder, so no worry! Thank you for the extra infomation.