Skip to content

Commit

Permalink
Update Gradle publish plugin, Kotlin docs, debug mode (#17)
Browse files Browse the repository at this point in the history
* Update Gradle publish plugin, fix Kotlin DSL docs

Fixes an issue which may cause builds to fail in some circumstances, citing some Log4j issue (gradle/gradle#19458)

* Add debug mode (fixes #15)

* Don't copy-paste, kids
  • Loading branch information
triphora committed Mar 4, 2022
1 parent 49186c1 commit ef1535d
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 15 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ The next step is to create a new task for uploading to Modrinth. This task allow
```kotlin
import com.modrinth.minotaur.dependencies.ModDependency
modrinth {
token = System.getenv("MODRINTH_TOKEN") // This is the default. Remember to have the MODRINTH_TOKEN environment variable set or else this will fail, or set it to whatever you want - just make sure it stays private!
projectId = "AABBCCDD"
versionNumber = "1.0.0" // You don't need to set this manually. Will fail if Modrinth has this version already
versionType = "release" // This is the default
uploadFile = jar // With Fabric Loom or Architectury Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions = arrayOf("1.18", "1.18.1") // Must be an array, even with only one version
loaders = arrayOf("fabric") // Must also be an array - no need to specify this if you're using Fabric Loom or ForgeGradle
dependencies = arrayOf( // Yet another array. Create a new `ModDependency` or `VersionDependency` with two strings - the ID and the scope
ModDependency("P7dR8mSH", "required") // Creates a new required dependency on Fabric API
token.set(System.getenv("MODRINTH_TOKEN")) // This is the default. Remember to have the MODRINTH_TOKEN environment variable set or else this will fail, or set it to whatever you want - just make sure it stays private!
projectId.set("AABBCCDD")
versionNumber.set("1.0.0") // You don't need to set this manually. Will fail if Modrinth has this version already
versionType.set("release") // This is the default
uploadFile.set(jar) // With Fabric Loom or Architectury Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions.addAll(arrayOf("1.18", "1.18.1")) // Must be an array, even with only one version
loaders.add("fabric") // Must also be an array - no need to specify this if you're using Fabric Loom or ForgeGradle
dependencies.set( // Yet another array. Create a new `ModDependency` or `VersionDependency` with two strings - the ID and the scope
mutableListOf(
ModDependency("P7dR8mSH", "required") // Creates a new required dependency on Fabric API
)
)
}
```
Expand All @@ -103,6 +105,7 @@ modrinth {
| dependencies | false | Dependencies of the uploaded version. | |
| failSilently | false | When true an upload failure will not fail your build. | `false` |
| detectLoaders | false | Whether mod loaders will be automatically detected. | `true` |
| debugMode | false | Doesn't actually upload the version, and prints the data to be uploaded. | `true` |

**Note:** In most scenarios the `gameVersions` and `loaders` properties can be detected automatically. This is done in environments using ForgeGradle and Fabric Loom.

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'java'
id 'com.gradle.plugin-publish' version '0.19.0'
id 'com.gradle.plugin-publish' version '0.20.0'
id 'java-gradle-plugin'
id 'maven-publish'
}

version = '2.0.0'
version = '2.0.1'
group = 'com.modrinth.minotaur'
archivesBaseName = 'Minotaur'
description = 'Modrinth plugin for publishing builds to the website!'
Expand Down
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-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 9 additions & 1 deletion src/main/java/com/modrinth/minotaur/ModrinthExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ModrinthExtension {
private final ListProperty<Object> additionalFiles;
private final ListProperty<String> gameVersions, loaders;
private final ListProperty<Dependency> dependencies;
private final Property<Boolean> failSilently, detectLoaders;
private final Property<Boolean> failSilently, detectLoaders, debugMode;

/**
* @param project The Gradle project that the extension is applied to
Expand All @@ -36,6 +36,7 @@ public ModrinthExtension(Project project) {
dependencies = project.getObjects().listProperty(Dependency.class).empty();
failSilently = project.getObjects().property(Boolean.class).convention(false);
detectLoaders = project.getObjects().property(Boolean.class).convention(true);
debugMode = project.getObjects().property(Boolean.class).convention(false);
}

/**
Expand Down Expand Up @@ -139,4 +140,11 @@ public Property<Boolean> getFailSilently() {
public Property<Boolean> getDetectLoaders() {
return this.detectLoaders;
}

/**
* @return Whether the plugin is in debug mode. Debug mode does not actually upload any files.
*/
public Property<Boolean> getDebugMode() {
return this.debugMode;
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/modrinth/minotaur/TaskModrinthUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ public void upload(URI endpoint, List<File> files) throws IOException {
data.setFileParts(fileParts);
data.setPrimaryFile("0"); // The primary file will always be of the first index in the list

if (extension.getDebugMode().get()) {
this.getProject().getLogger().lifecycle("Full data to be sent for upload: {}", GSON.toJson(data));
this.getProject().getLogger().lifecycle("Minotaur debug mode is enabled. Not going to upload this version.");
return;
}

form.addTextBody("data", GSON.toJson(data), ContentType.APPLICATION_JSON);

for (int i = 0; i < files.size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/fg/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

plugins {
id "com.modrinth.minotaur" version "2.0.0-SNAPSHOT"
id "com.modrinth.minotaur" version "2.0.1-SNAPSHOT"
id "java"
id "idea"
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/loom/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "fabric-loom" version "0.10-SNAPSHOT"
id "com.modrinth.minotaur" version "2.0.0-SNAPSHOT"
id "com.modrinth.minotaur" version "2.0.1"
}

version = "1.0.387"
Expand Down Expand Up @@ -38,4 +38,5 @@ modrinth {
new ModDependency("tsi4hUoN", "optional"),
new VersionDependency("igy4JZo5", DependencyType.INCOMPATIBLE)
]
debugMode = true
}

0 comments on commit ef1535d

Please sign in to comment.