Skip to content

Commit

Permalink
Update gradle, buildscript, license. Add publish script, maven and mo…
Browse files Browse the repository at this point in the history
…drinth publishing.
  • Loading branch information
The-Fireplace committed Jul 20, 2021
1 parent 7a23d8e commit b8f1f52
Show file tree
Hide file tree
Showing 10 changed files with 535 additions and 756 deletions.
373 changes: 373 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

675 changes: 0 additions & 675 deletions LICENSE.md

This file was deleted.

195 changes: 143 additions & 52 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
//file:noinspection GroovyAssignabilityCheck
plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
id "com.matthewprenger.cursegradle" version "1.4.0"
// Dependencies
id 'fabric-loom' version '0.9-SNAPSHOT'
// Mod Hosting Publish
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.modrinth.minotaur' version '1.1.0'
// Maven Publish
id 'maven-publish'
id 'signing'
id 'io.codearte.nexus-staging' version '0.30.0'
}

sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -10,79 +18,162 @@ archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
maven {
name 'Cloth Config'
url 'https://maven.shedaniel.me/'
}
maven {
name 'Terraformers Backup'
url 'https://raw.githubusercontent.com/TerraformersMC/Archive/main/releases/'
}
flatDir { dirs 'lib' }
}

dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modCompileOnly "dev.the-fireplace:Fireplace-Lib:${project.fireplacelib_version}:api"
modRuntime "dev.the-fireplace:Fireplace-Lib:${project.fireplacelib_version}"

compile "com.google.code.findbugs:jsr305:3.0.2"
}

repositories {
//Auto config
jcenter()
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
}

processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 8
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
java {
withSourcesJar()
withJavadocJar()
}

jar {
from "LICENSE.md"
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

curseforge {
apiKey = project.hasProperty("curseForgeApiKey") ? project.curseForgeApiKey : "empty"
project {
id = '408081'
changelog = file('changelog.txt')
releaseType = 'release'
addGameVersion '1.16.3'
addGameVersion '1.16.2'
addGameVersion '1.16.1'
addGameVersion '1.16'
addGameVersion '1.16-snapshot'
addGameVersion '1.15.2'
addGameVersion '1.14.4'
addGameVersion 'Java 8'
addGameVersion 'Fabric'
mainArtifact(new File(new File(buildDir, "libs"), "$archivesBaseName-${version}.jar")) {
displayName = "$archivesBaseName-$version"
relations {
requiredDependency 'fabric-api'
if (hasProperty('curseForgeApiKey')) {
curseforge {
apiKey = curseForgeApiKey
project {
id = '408081'
changelog = file('changelog.txt')
releaseType = project.release_type
addGameVersion project.minecraft_version
addGameVersion '1.16.4'
addGameVersion '1.16.3'
addGameVersion '1.16.2'
addGameVersion '1.16.1'
addGameVersion '1.16'
addGameVersion '1.16-Snapshot'
addGameVersion '1.15.2'
addGameVersion '1.14.4'
addGameVersion 'Java 8'
addGameVersion 'Fabric'
mainArtifact(new File(new File(buildDir, "libs"), "$archivesBaseName-${version}.jar")) {
displayName = "$archivesBaseName-$version"
relations {
requiredDependency 'fabric-api'
}
}
}
options {
javaIntegration = false
forgeGradleIntegration = false
}
}
}

import com.modrinth.minotaur.TaskModrinthUpload
if (hasProperty('modrinthApiKey')) {
task publishModrinth(type: TaskModrinthUpload) {
token = modrinthApiKey
projectId = '00000000'
versionNumber = version
versionName = project.mod_version
uploadFile = new File(new File(buildDir, "libs"), "$archivesBaseName-${version}.jar")
changelog = file('changelog.txt').getText()
releaseType = project.release_type
addGameVersion(project.minecraft_version as String)
addGameVersion('1.16.4')
addGameVersion('1.16.3')
addGameVersion('1.16.2')
addGameVersion('1.16.1')
addGameVersion('1.16')
addGameVersion('1.15.2')
addGameVersion('1.14.4')
addLoader('fabric')
}
}

if (hasProperty('nexusUsername')) {
publishing {
publications {
mavenJava(MavenPublication) {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
artifact javadocJar
pom {
name = 'Audiobook'
packaging = 'jar'
description = 'A client-side Minecraft mod that allows the system narrator to read books to you.'
url = 'https://www.curseforge.com/minecraft/mc-mods/audiobook'

scm {
connection = "scm:svn:https://github.com/The-Fireplace-Minecraft-Mods/${project.github_slug}.git"
developerConnection = "scm:svn:https://github.com/The-Fireplace-Minecraft-Mods/${project.github_slug}.git"
url = "https://github.com/The-Fireplace-Minecraft-Mods/${project.github_slug}"
}

licenses {
license {
name = 'Mozilla Public License 2.0'
url = 'https://www.mozilla.org/en-US/MPL/2.0/'
}
}

developers {
developer {
id = 'the_fireplace'
name = 'The_Fireplace'
email = '[email protected]'
}
}
}
}
}
repositories {
maven {
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = nexusUsername
password = nexusPassword
}
}
}
}

signing {
sign publishing.publications.mavenJava
}
options {
javaIntegration = false
forgeGradleIntegration = false
}
}
19 changes: 10 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
org.gradle.jvmargs=-Xmx3G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.3
yarn_mappings=1.16.3+build.1
loader_version=0.9.3+build.207
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.9
loader_version=0.11.3

# Mod Properties
mod_version = 1.0.0
maven_group = the_fireplace.audiobook
archives_base_name = Audiobook-1.16.3
maven_group = dev.the-fireplace
archives_base_name = Audiobook
github_slug = Audiobook
mod_version = 1.1.0
release_type = release

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.20.2+build.402-1.16
fabric_version=0.35.0+1.16
fireplacelib_version=5.0.0+1.16.5
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions gradlew
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
22 changes: 4 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,28 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
1 change: 1 addition & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./gradlew build curseforge publishModrinth publish closeAndReleaseRepository
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"issues": "https://github.com/The-Fireplace-Minecraft-Mods/Audiobook/issues"
},

"license": "GPL-3.0-or-later",
"license": "MPL-2.0",
"icon": "assets/audiobook/icon.png",

"environment": "*",
Expand Down

0 comments on commit b8f1f52

Please sign in to comment.