diff --git a/build.gradle b/build.gradle index b376325..c8f24df 100644 --- a/build.gradle +++ b/build.gradle @@ -321,4 +321,5 @@ idea.project.settings { } } +apply from: 'gradle/scripts/publishing.gradle' apply from: 'gradle/scripts/extra.gradle' \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 6542ccf..5a0d5c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -51,20 +51,20 @@ maven_url = # Publishing # release_type can only be: release, beta or alpha (applies to CurseForge / Modrinth) -release_type = release +release_type = beta publish_with_changelog = ${{ it.file('CHANGELOG.md').exists() }} # Publishing to CurseForge (Provide secret: CURSEFORGE_TOKEN) # To configure dependencies, head to publishing.gradle's curseforge block -publish_to_curseforge = false +publish_to_curseforge = true # CurseForge project ID must be the numerical ID and not the slug -curseforge_project_id = +curseforge_project_id = 692142 curseforge_debug = false # Publishing to Modrinth (Provide secret: MODRINTH_TOKEN), the token must have the `CREATE_VERSION` and `PROJECT_WRITE` permissions # To configure dependencies, head to publishing.gradle's modrinth block -publish_to_modrinth = false -modrinth_project_id = +publish_to_modrinth = true +modrinth_project_id = rWzXKfPV # Allows gradle to publish updated READMEs to the project body (via the modrinthSyncBody task) modrinth_sync_readme = false modrinth_debug = false diff --git a/gradle/scripts/publishing.gradle b/gradle/scripts/publishing.gradle new file mode 100644 index 0000000..c7897c9 --- /dev/null +++ b/gradle/scripts/publishing.gradle @@ -0,0 +1,107 @@ +apply from: 'gradle/scripts/helpers.gradle' + +setDefaultProperty('publish_to_maven', true, false) +setDefaultProperty('publish_to_curseforge', true, false) +setDefaultProperty('publish_to_modrinth', true, false) + +if (propertyBool('publish_to_maven')) { + assertProperty('maven_name') + assertProperty('maven_url') + publishing { + repositories { + maven { + name propertyString('maven_name').replaceAll("\\s", "") + url propertyString('maven_url') + credentials(PasswordCredentials) + } + } + publications { + mavenJava(MavenPublication) { + from components.java // Publish with standard artifacts + setGroupId(propertyString('root_package'))// Publish with root package as maven group + setArtifactId(propertyString('mod_id')) // Publish artifacts with mod id as the artifact id + + // Custom artifact: + // If you want to publish a different artifact to the one outputted when building normally + // Create a different gradle task (Jar task), in extra.gradle + // Remove the 'from components.java' line above + // Add this line (change the task name): + // artifacts task_name + } + } + } +} + +// Documentation here: https://github.com/matthewprenger/CurseGradle/wiki/ +if (propertyBool('publish_to_curseforge')) { + apply plugin: 'com.matthewprenger.cursegradle' + assertProperty('curseforge_project_id') + assertProperty('release_type') + setDefaultProperty('curseforge_debug', false, false) + curseforge { + apiKey = System.getenv('CURSEFORGE_TOKEN') == null ? "" : System.getenv('CURSEFORGE_TOKEN') + // noinspection GroovyAssignabilityCheck + project { + id = propertyString('curseforge_project_id') + addGameVersion 'Java 8' + addGameVersion 'Forge' + addGameVersion '1.12.2' + releaseType = propertyString('release_type') + if (!propertyBool('publish_with_changelog')) { + changelog = parserChangelog() + changelogType = 'markdown' + } + mainArtifact tasks.reobfJar, { + displayName = "${propertyString('mod_name')} ${propertyString('mod_version')}" + if (propertyBool('use_mixins')) { + relations { + requiredDependency 'mixin-booter' + } + } + if (propertyBool('use_asset_mover')) { + relations { + requiredDependency 'assetmover' + } + } + } + options { + debug = propertyBool('curseforge_debug') + } + } + } +} + +// Documentation here: https://github.com/modrinth/minotaur +if (propertyBool('publish_to_modrinth')) { + apply plugin: 'com.modrinth.minotaur' + assertProperty('modrinth_project_id') + assertProperty('release_type') + setDefaultProperty('modrinth_debug', false, false) + modrinth { + token = System.getenv('MODRINTH_TOKEN') ? "" : System.getenv('MODRINTH_TOKEN') + projectId = propertyString('modrinth_project_id') + versionNumber = propertyString('mod_version') + versionType = propertyString('release_type') + uploadFile = tasks.reobfJar + gameVersions = ['1.12.2'] + loaders = ['forge'] + debugMode = propertyBool('modrinth_debug') + if (propertyBool('use_mixins') || propertyBool('use_asset_mover')) { + dependencies { + if (propertyBool('use_mixins')) { + required.project 'mixinbooter' + } + if (propertyBool('use_asset_mover')) { + required.project 'assetmover' + } + } + } + if (!propertyBool('publish_with_changelog')) { + changelog = parserChangelog() + } + if (propertyBool('modrinth_sync_readme')) { + syncBodyFrom = file('README.md').text + tasks.modrinth.dependsOn(tasks.modrinthSyncBody) + } + } +} \ No newline at end of file