From 9841a5cf110821c3d9225e37e5f0a92a2d09b9c4 Mon Sep 17 00:00:00 2001 From: Jai A Date: Fri, 4 Dec 2020 20:57:24 -0700 Subject: [PATCH] Make compat with Modrinth --- README.md | 62 ++--- settings.gradle | 2 +- .../modrinth/minotaur/TaskModrinthUpload.java | 259 ++++++++---------- .../minotaur/request/FileDependency.java | 38 --- .../minotaur/request/RequestData.java | 107 ++++---- .../minotaur/responses/ResponseError.java | 23 +- .../minotaur/responses/ResponseUpload.java | 190 +------------ src/test/resources/localtest/build.gradle | 17 +- src/test/resources/uploadtest/build.gradle | 11 +- 9 files changed, 204 insertions(+), 505 deletions(-) delete mode 100644 src/main/java/com/modrinth/minotaur/request/FileDependency.java diff --git a/README.md b/README.md index 9b033a2..a2db99a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# [Diluv-Gradle](https://plugins.gradle.org/plugin/com.diluv.diluvgradle) -A Gradle plugin for uploading build artifacts directly to Diluv. +# [Minotaur](https://plugins.gradle.org/plugin/com.modrinth.minotaur) +A Gradle plugin for uploading build artifacts directly to Modrinth. ## Usage Guide To use this plugin you must add it to your build script. This can be done using the plugins DSL or added to the classpath directly for legacy scripts. @@ -7,7 +7,7 @@ To use this plugin you must add it to your build script. This can be done using **Plugin DSL** ```gradle plugins { - id "com.diluv.diluvgradle" version "1.2.2" + id "com.modrinth.minotaur" version "1.0.0" } ``` @@ -20,20 +20,20 @@ buildscript { } } dependencies { - classpath group: 'gradle.plugin.com.diluv.diluvgradle', name: 'DiluvGradle', version: '1.2.2' + classpath group: 'gradle.plugin.com.modrinth.minotaur', name: 'Minotaur', version: '1.0.0' } } ``` -The next step is to create a new task for uploading to Diluv. This task allows you to configure the upload and control when and how files are uploaded. +The next step is to create a new task for uploading to Modrinth. This task allows you to configure the upload and control when and how versions are uploaded. ```groovy -import TaskDiluvUpload +import TaskModrinthUpload -task publishDiluv (type: TaskDiluvUpload){ +task publishModrinth (type: TaskModrinthUpload){ - token = 'a7104dd8-f43a-4468-b5cd-b6ed3394916d' // Use an environment property! - projectId = 123456 + token = 'secret' // Use an environment property! + projectId = 'ssUbhMkL' projectVersion = '1.0.0' uploadFile = jar // This is the java jar task gameVersion = '1.12.2' @@ -44,20 +44,18 @@ task publishDiluv (type: TaskDiluvUpload){ | Property | Required | Description | |----------------------------------|----------|-------------------------------------------------------------------------------------| -| apiURL | false | The API endpoint URL to use for uploading files. Defaults to official Diluv API. | -| token | true | A valid API token for the Diluv API. | +| apiURL | false | The API endpoint URL to use for uploading files. Defaults to official Modrinth API. | +| token | true | A valid API token for the Modrinth API. | | projectId | true | The ID of the project to upload to. | -| projectVersion | true | The version of the file. Please use semantic versioning. | +| versionNumber | true | The version number of the version. | +| versionName | false | The name of the version. | | changelog | false | The changelog for the file. Allows Markdown formatting. | | uploadFile | true | The file to upload. Can be an actual file or a file task. | | releaseType | false | The release status of the file. Defaults to "alpha". | -| classifier | false | The type of file being uploaded. Defaults to binary. | -| gameVersion | true | The version of the game the file is for. Comma separated for multiple. | | failSilently | false | When true an upload failure will not fail your build. | -| addDependency(projectId) | false | Marks a project as a required dependency. | -| addOptionalDependency(projectId) | false | Marks a project as an optional/soft dependency. | -| addIncompatibility(projectId) | false | Marks a project as being incompatible with this file. | -| addRelation(projectId, type) | false | Adds a project relationship to the file. Only some relationship types are accepted. | +| addGameVersion(version) | true | Adds a game version that this file supports. At least one is needed. | +| addLoader(loader) | true | Allows supported mod loaders to be specified for the file. | +| addFile(file) | false | Allows supported mod loaders to be specified for the file. | **Note:** In some scenarios the `gameVersion` property can be detected automatically. For example the ForgeGradle and LoomGradle environments. For best results you should set this property manually. @@ -73,35 +71,19 @@ task publishDiluv (type: TaskDiluvUpload){ | Property | Type | Description | |---------------------|-------------|---------------------------------------------------------| -| status | String | The current status of the file. Approved, pending, etc. | -| lastStatusChanged | Long | The time the status last changed. | -| id | Long | The ID for the uploaded file. | -| name | String | The name of the uploaded file. | -| downloadURL | String | A download URL for the uploaded file. | -| size | Long | The file size in bytes. | -| changelog | String | The changelog for the file. | -| sha512 | String | A sha512 hash of the file. | -| releaseType | String | The release type of the file. | -| classifier | String | The classifier of the file. | -| createdAt | Long | When the file was created. | -| gameVersions | GameVersion | Not yet implemented. | -| gameSlug | String | The slug for the game that the project belongs to. | -| projectTypeSlug | String | The slug for the project type. | -| projectSlug | String | The slug of the project. | -| uploaderUserId | Long | The ID of the user who uploaded the file. | -| uploaderUsername | String | The username of the user who uploaded the file. | -| uploaderDisplayName | String | The display name of the user who uploaded the file. | +| id | String | The ID for the uploaded version. | + +More properties coming soon! #### Error Info | Property | Type | Description | |----------|--------|----------------------------------------------------------------------| -| type | String | The type of error that occurred, for example an authorization error. | -| error | String | An API error code string. | -| message | String | The error message from the API. | +| error | String | The type of error that occurred, for example an authorization error. | | +| description | String | The error message from the API. | ## Development Information -This section contains information useful to those working on the plugin directly or creating their own custom versions of our plugin. If you want to just use DiluvGradle in your build pipeline you will not need to know or understand any of this. +This section contains information useful to those working on the plugin directly or creating their own custom versions of our plugin. If you want to just use Minotaur in your build pipeline you will not need to know or understand any of this. ### Local Usage If you want to use the plugin from your local maven repo make sure you have added the mavenLocal repository to your script. Grabbing the plugin is the same as normal. To publish locally you run `./gradlew clean build publishToMavenLocal`. Local maven files can be found in the `%home%/.m2/` directory. diff --git a/settings.gradle b/settings.gradle index 6793030..d7134f8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = 'DiluvGradle' +rootProject.name = 'Minotaur' diff --git a/src/main/java/com/modrinth/minotaur/TaskModrinthUpload.java b/src/main/java/com/modrinth/minotaur/TaskModrinthUpload.java index 20368bb..70452d9 100644 --- a/src/main/java/com/modrinth/minotaur/TaskModrinthUpload.java +++ b/src/main/java/com/modrinth/minotaur/TaskModrinthUpload.java @@ -5,17 +5,10 @@ import java.lang.reflect.Method; import java.net.URI; import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.regex.Pattern; -import java.util.stream.Collectors; +import java.util.*; import javax.annotation.Nullable; -import com.modrinth.minotaur.request.FileDependency; import com.modrinth.minotaur.responses.ResponseError; import com.modrinth.minotaur.responses.ResponseUpload; import org.apache.http.HttpResponse; @@ -38,7 +31,7 @@ import com.google.gson.GsonBuilder; /** - * A task used to communicate with Diluv for the purpose of uploading build artifacts. + * A task used to communicate with Modrinth for the purpose of uploading build artifacts. */ public class TaskModrinthUpload extends DefaultTask { @@ -47,27 +40,12 @@ public class TaskModrinthUpload extends DefaultTask { */ private static final Gson GSON = new GsonBuilder().create(); - /** - * A regex pattern for matching semantic versioning version numbers. This was taken from - * https://semver.org/. - */ - private static final Pattern SEM_VER = Pattern.compile("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"); - - private static final String RELATION_REQUIRED = "required"; - private static final String RELATION_OPTIONAL = "optional"; - private static final String RELATION_INCOMPATIBLE = "incompatible"; - - /** - * A list of recognized project relationship types. - */ - private static final List PROJECT_RELATION_TYPES = Arrays.asList(RELATION_REQUIRED, RELATION_OPTIONAL, RELATION_INCOMPATIBLE); - /** * The URL used for communicating with Modrinth. This should not be changed unless you know * what you're doing. It's main use case is for debug, development, or advanced user * configurations. */ - public String apiURL = "https://api.modrinth.com"; + public String apiURL = "https://api.modrinth.com/api"; /** * The API token used to communicate with Modrinth. Make sure you keep this public! @@ -82,7 +60,12 @@ public class TaskModrinthUpload extends DefaultTask { /** * The version of the project being uploaded. */ - public String projectVersion; + public String versionNumber; + + /** + * The version name of the project being uploaded. Defaults to the version number. + */ + public String versionName; /** * The change log data to associate with the new file. @@ -94,21 +77,23 @@ public class TaskModrinthUpload extends DefaultTask { * {@link #resolveFile(Project, Object, File)}. */ public Object uploadFile; + + public Collection additionalFiles; /** * The release type for the project. */ - public String releaseType = "alpha"; - + public String releaseType = "release"; + /** - * The type of file being uploaded. + * The game versions of the game the version supports. */ - public String classifier = "binary"; - + public Set gameVersions = new HashSet<>(); + /** - * The version of the game the file supports. + * The mod loaders of the game the version supports. */ - public String gameVersion; + public Set loaders = new HashSet<>(); /** * Allows build to continue even if the upload failed. @@ -126,9 +111,35 @@ public class TaskModrinthUpload extends DefaultTask { */ @Nullable public ResponseError errorInfo = null; - - public Map projectRelations = new HashMap<>(); - + + public TaskModrinthUpload() { + this.mustRunAfter(this.getProject().getTasks().getByName("build")); + } + + public void addGameVersion (String version) { + + this.getProject().getLogger().debug("Adding game version {} to project {}.", version, this.projectId); + + if (!this.gameVersions.add(version)) { + + this.getProject().getLogger().warn("The game version {} was already applied for project {}.", version, this.projectId); + } + } + + public void addLoader (String loader) { + + this.getProject().getLogger().debug("Adding loader tag {} to project {}.", loader, this.projectId); + + if (!this.loaders.add(loader)) { + + this.getProject().getLogger().warn("The loader tag {} was already applied for project {}.", loader, this.projectId); + } + } + + public void addFile(Object file) { + additionalFiles.add(file); + } + /** * Checks if the upload was successful or not. This is provided as a small helper for use * in the build script. @@ -136,89 +147,40 @@ public class TaskModrinthUpload extends DefaultTask { * @return Whether or not the file was successfully uploaded. */ public boolean wasUploadSuccessful () { - return this.uploadInfo != null && this.errorInfo == null; } - /** - * Adds a required project dependency for the file. - * - * @param project The project that this file requires. - */ - public void addDependency (long project) { - - this.addRelation(project, RELATION_REQUIRED); - } - - /** - * Adds an optional project dependency for the file. - * - * @param project The project that is optional. - */ - public void addOptionalDependency (long project) { - - this.addRelation(project, RELATION_OPTIONAL); - } - - /** - * Adds an incompatibility relationship for the file. - * - * @param project The project that the file is not compatible with. - */ - public void addIncompatibility (long project) { - - this.addRelation(project, RELATION_INCOMPATIBLE); - } - - /** - * Adds a project relationship to the uploaded file. This determines things like - * dependencies and incompatibilities. - * - * @param project The project to add a relation with. - * @param type The type of relation to add. - */ - public void addRelation (long project, String type) { - - if (!PROJECT_RELATION_TYPES.contains(type)) { - - this.getProject().getLogger().warn("The project relation type {} is not recognized and may not work. The known types are {}.", type, PROJECT_RELATION_TYPES.stream().collect(Collectors.joining(", "))); - } - - final String existingRelation = this.projectRelations.put(project, type); - - if (existingRelation != null) { - - this.getProject().getLogger().warn("Overwriting relation for {} to {}, was previously set as {}.", project, type, existingRelation); - } - } - @TaskAction public void apply () { try { - + // Attempt to automatically resolve the game version if one wasn't specified. - if (this.gameVersion == null) { - - this.gameVersion = detectGameVersion(this.getProject()); - - if (this.gameVersion == null) { - - throw new GradleException("Can not upload to Diluv. gameVersion is null and could not be detected."); + if (this.gameVersions.isEmpty()) { + + final String detectedVersion = detectGameVersion(this.getProject()); + + if (detectedVersion == null) { + + throw new GradleException("Can not upload to Modrinth. No game version specified."); + } + + else { + this.addGameVersion(detectedVersion); } } - + + if (this.loaders.isEmpty()) { + throw new GradleException("Can not upload to Modrinth. No loaders specified."); + } + // Use project version if no version is specified. - if (this.projectVersion == null) { - - this.projectVersion = this.getProject().getVersion().toString(); + if (this.versionNumber == null) { + this.versionNumber = this.getProject().getVersion().toString(); } - - // Only semantic versioning is allowed. - if (!SEM_VER.matcher(this.projectVersion).matches()) { - - this.getProject().getLogger().error("Project version {} is not semantic versioning compatible. The file can not be uploaded. https://semver.org", this.projectVersion); - throw new GradleException("Project version '" + this.projectVersion + "' is not semantic versioning compatible. The file can not be uploaded. https://semver.org"); + + if (this.versionName == null) { + this.versionName = this.getProject().getVersion().toString(); } // Set a default changelog if the dev hasn't provided one. @@ -226,15 +188,31 @@ public void apply () { this.changelog = "The project has been updated to " + this.getProject() + ". No changelog was specified."; } - + + List filesToUpload = new ArrayList<>(); + final File file = resolveFile(this.getProject(), this.uploadFile, null); // Ensure the file actually exists before trying to upload it. if (file == null || !file.exists()) { - this.getProject().getLogger().error("The upload file is missing or null. {}", this.uploadFile); throw new GradleException("The upload file is missing or null. " + String.valueOf(this.uploadFile)); } + + filesToUpload.add(file); + + for (Object fileObject : this.additionalFiles) { + final File resolvedFile = resolveFile(this.getProject(), fileObject, null); + + // Ensure the file actually exists before trying to upload it. + if (resolvedFile == null || !resolvedFile.exists()) { + + this.getProject().getLogger().error("The upload file is missing or null. {}", fileObject); + throw new GradleException("The upload file is missing or null. " + String.valueOf(fileObject)); + } + + filesToUpload.add(resolvedFile); + } try { @@ -242,7 +220,7 @@ public void apply () { try { - this.upload(endpoint, file); + this.upload(endpoint, filesToUpload); } catch (final IOException e) { @@ -263,8 +241,8 @@ public void apply () { if (this.failSilently) { - this.getLogger().info("Failed to upload to Diluv. Check logs for more info."); - this.getLogger().error("Diluv upload failed silently.", e); + this.getLogger().info("Failed to upload to Modrinth. Check logs for more info."); + this.getLogger().error("Modrinth upload failed silently.", e); } else { @@ -278,36 +256,39 @@ public void apply () { * Uploads a file using the provided configuration. * * @param endpoint The upload endpoint. - * @param file The file to upload. + * @param files The files to upload. * @throws IOException Whenever something goes wrong wit uploading the file. */ - public void upload (URI endpoint, File file) throws IOException { - - this.getProject().getLogger().debug("Uploading {} to {}.", file.getPath(), this.getUploadEndpoint()); - + public void upload (URI endpoint, List files) throws IOException { final HttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.IGNORE_COOKIES).build()).build(); final HttpPost post = new HttpPost(endpoint); - post.addHeader("Authorization", "Bearer " + this.token); + post.addHeader("Authorization", this.token); final MultipartEntityBuilder form = MultipartEntityBuilder.create(); - form.addBinaryBody("file", file); - form.addTextBody("filename", file.getName()); + + List fileParts = new ArrayList<>(); + + for (int i = 0; i < files.size(); i++) { + fileParts.add(String.valueOf(i)); + } final RequestData data = new RequestData(); - data.setVersion(this.projectVersion); + data.setVersionNumber(this.versionNumber); + data.setVersionTitle(this.versionName); data.setChangelog(this.changelog); data.setReleaseType(this.releaseType); - data.setClassifier(this.classifier); - data.getGameVersions().add(this.gameVersion); - - for (Entry relation : this.projectRelations.entrySet()) { - - data.getDependencies().add(new FileDependency(relation.getKey(), relation.getValue())); - } + data.setGameVersions(this.gameVersions); + data.setLoaders(this.loaders); + data.setFileParts(fileParts); form.addTextBody("data", GSON.toJson(data), ContentType.APPLICATION_JSON); - + + for (int i = 0; i < files.size(); i++) { + this.getProject().getLogger().debug("Uploading {} to {}.", files.get(i).getPath(), this.getUploadEndpoint()); + form.addBinaryBody(String.valueOf(i), files.get(i)); + } + post.setEntity(form.build()); try { @@ -318,30 +299,24 @@ public void upload (URI endpoint, File file) throws IOException { if (status == 200) { this.uploadInfo = GSON.fromJson(EntityUtils.toString(response.getEntity()), ResponseUpload.class); - this.getProject().getLogger().lifecycle("Sucessfully uploaded {} to {} as file id {}.", file.getName(), this.projectId, this.uploadInfo.getId()); + this.getProject().getLogger().lifecycle("Successfully uploaded version to {} as version id {}.", this.projectId, this.uploadInfo.getId()); } else { this.errorInfo = GSON.fromJson(EntityUtils.toString(response.getEntity()), ResponseError.class); - this.getProject().getLogger().error("Upload failed! Status: {} Reson: {}", status, this.errorInfo.getMessage()); - throw new GradleException("Upload failed! Status: " + status + " Reson: " + this.errorInfo.getMessage()); + this.getProject().getLogger().error("Upload failed! Status: {} Error: {} Reason: {}", status, this.errorInfo.getError(), this.errorInfo.getDescription()); + throw new GradleException("Upload failed! Status: " + status + " Reason: " + this.errorInfo.getDescription()); } } catch (final IOException e) { - this.getProject().getLogger().error("Failure to upload file!", e); + this.getProject().getLogger().error("Failure to upload files!", e); throw e; } } - - @Override - public String toString () { - - return "TaskDiluvUpload [apiURL=" + this.apiURL + ", token=" + (this.token != null) + ", projectId=" + this.projectId + ", projectVersion=" + this.projectVersion + ", changelog=" + this.changelog + ", uploadFile=" + this.uploadFile + ", releaseType=" + this.releaseType + ", classifier=" + this.classifier + ", gameVersion=" + this.gameVersion + "]"; - } - + /** * Provides the upload API endpoint to use. * @@ -349,7 +324,7 @@ public String toString () { */ private String getUploadEndpoint () { - return this.apiURL + "/v1/projects/" + this.projectId + "/files"; + return this.apiURL + "/v1/version"; } /** @@ -384,7 +359,7 @@ else if (in instanceof AbstractArchiveTask) { return ((AbstractArchiveTask) in).getArchivePath(); } - + // Fallback to Gradle's built in file resolution mechanics. return project.file(in); } diff --git a/src/main/java/com/modrinth/minotaur/request/FileDependency.java b/src/main/java/com/modrinth/minotaur/request/FileDependency.java deleted file mode 100644 index 7721e49..0000000 --- a/src/main/java/com/modrinth/minotaur/request/FileDependency.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.modrinth.minotaur.request; - -import com.google.gson.annotations.Expose; - -public class FileDependency { - - @Expose - public Long projectId; - - @Expose - public String type; - - public FileDependency(Long projectId, String type) { - - this.projectId = projectId; - this.type = type; - } - - public Long getProjectId () { - - return this.projectId; - } - - public void setProjectId (Long projectId) { - - this.projectId = projectId; - } - - public String getType () { - - return this.type; - } - - public void setType (String type) { - - this.type = type; - } -} diff --git a/src/main/java/com/modrinth/minotaur/request/RequestData.java b/src/main/java/com/modrinth/minotaur/request/RequestData.java index 7fcbd55..3eb41f0 100644 --- a/src/main/java/com/modrinth/minotaur/request/RequestData.java +++ b/src/main/java/com/modrinth/minotaur/request/RequestData.java @@ -1,94 +1,79 @@ package com.modrinth.minotaur.request; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; public class RequestData { - + @Expose - @SerializedName("version") - public String version; - + @SerializedName("mod_id") + private String projectId; + @Expose - @SerializedName("changelog") - public String changelog; - + @SerializedName("version_number") + private String versionNumber; + @Expose - @SerializedName("releaseType") - public String releaseType; + @SerializedName("version_title") + private String versionTitle; @Expose - @SerializedName("classifier") - public String classifier; + @SerializedName("version_body") + private String changelog; @Expose - @SerializedName("gameVersions") - public List gameVersions = new ArrayList<>(); + @SerializedName("release_channel") + private String releaseType; + + @Expose + @SerializedName("game_versions") + private Collection gameVersions = new ArrayList<>(); + + @Expose + @SerializedName("loaders") + private Collection loaders = new ArrayList<>(); @Expose @SerializedName("dependencies") - public List dependencies = new ArrayList<>(); - - public String getVersion () { - - return this.version; - } + private Collection dependencies = new ArrayList<>(); + + @Expose + @SerializedName("file_parts") + private List fileParts = new ArrayList<>(); + + @Expose + @SerializedName("featured") + private boolean featured = false; - public void setVersion (String version) { - - this.version = version; + public void setVersionNumber(String version) { + this.versionNumber = version; } - - public String getChangelog () { - - return this.changelog; + + public void setVersionTitle(String title) { + this.versionTitle = title; } - public void setChangelog (String changelog) { - + public void setChangelog(String changelog) { this.changelog = changelog; } - public String getReleaseType () { - - return this.releaseType; - } - - public void setReleaseType (String releaseType) { - + public void setReleaseType(String releaseType) { this.releaseType = releaseType; } - - public String getClassifier () { - - return this.classifier; - } - - public void setClassifier (String classifier) { - - this.classifier = classifier; - } - - public List getGameVersions () { - - return this.gameVersions; - } - - public void setGameVersions (List gameVersions) { - + + public void setGameVersions(Collection gameVersions) { this.gameVersions = gameVersions; } - - public List getDependencies () { - - return this.dependencies; + + public void setLoaders(Collection loaders) { + this.loaders = loaders; } - - public void setDependencies (List dependencies) { - - this.dependencies = dependencies; + + public void setFileParts(List fileParts) { + this.fileParts = fileParts; } } diff --git a/src/main/java/com/modrinth/minotaur/responses/ResponseError.java b/src/main/java/com/modrinth/minotaur/responses/ResponseError.java index 83d7327..046678b 100644 --- a/src/main/java/com/modrinth/minotaur/responses/ResponseError.java +++ b/src/main/java/com/modrinth/minotaur/responses/ResponseError.java @@ -4,31 +4,20 @@ import com.google.gson.annotations.SerializedName; public class ResponseError { - - @Expose - @SerializedName("type") - private String type; - + @Expose @SerializedName("error") private String error; @Expose - @SerializedName("message") - private String message; - - public String getType () { - - return this.type; - } + @SerializedName("description") + private String description; - public String getError () { - + public String getError() { return this.error; } - public String getMessage () { - - return this.message; + public String getDescription() { + return this.description; } } \ No newline at end of file diff --git a/src/main/java/com/modrinth/minotaur/responses/ResponseUpload.java b/src/main/java/com/modrinth/minotaur/responses/ResponseUpload.java index 593af27..a58e779 100644 --- a/src/main/java/com/modrinth/minotaur/responses/ResponseUpload.java +++ b/src/main/java/com/modrinth/minotaur/responses/ResponseUpload.java @@ -6,196 +6,12 @@ import com.google.gson.annotations.SerializedName; public class ResponseUpload { - - @Expose - @SerializedName("status") - private String status; - - @Expose - @SerializedName("lastStatusChanged") - private Long lastStatusChanged; - @Expose @SerializedName("id") - private Long id; - - @Expose - @SerializedName("name") - private String name; - - @Expose - @SerializedName("downloadURL") - private String downloadURL; - - @Expose - @SerializedName("size") - private Long size; - - @Expose - @SerializedName("changelog") - private String changelog; - - @Expose - @SerializedName("sha512") - private String sha512; - - @Expose - @SerializedName("releaseType") - private String releaseType; - - @Expose - @SerializedName("classifier") - private String classifier; - - @Expose - @SerializedName("createdAt") - private Long createdAt; - - @Expose - @SerializedName("gameVersions") - private final List gameVersions = null; - - @Expose - @SerializedName("gameSlug") - private String gameSlug; - - @Expose - @SerializedName("projectTypeSlug") - private String projectTypeSlug; - - @Expose - @SerializedName("projectSlug") - private String projectSlug; - - @Expose - @SerializedName("uploaderUserId") - private Long uploaderUserId; - - @Expose - @SerializedName("uploaderUsername") - private String uploaderUsername; - - @Expose - @SerializedName("uploaderDisplayName") - private String uploaderDisplayName; - - public String getStatus () { - - return this.status; - } - - public Long getLastStatusChanged () { - - return this.lastStatusChanged; - } - - public Long getId () { + private String id; + + public String getId () { return this.id; } - - public String getName () { - - return this.name; - } - - public String getDownloadURL () { - - return this.downloadURL; - } - - public Long getSize () { - - return this.size; - } - - public String getChangelog () { - - return this.changelog; - } - - public String getSha512 () { - - return this.sha512; - } - - public String getReleaseType () { - - return this.releaseType; - } - - public String getClassifier () { - - return this.classifier; - } - - public Long getCreatedAt () { - - return this.createdAt; - } - - public List getGameVersions () { - - return this.gameVersions; - } - - public String getGameSlug () { - - return this.gameSlug; - } - - public String getProjectTypeSlug () { - - return this.projectTypeSlug; - } - - public String getProjectSlug () { - - return this.projectSlug; - } - - public Long getUploaderUserId () { - - return this.uploaderUserId; - } - - public String getUploaderUsername () { - - return this.uploaderUsername; - } - - public String getUploaderDisplayName () { - - return this.uploaderDisplayName; - } - - public static class GameVersion { - - @Expose - @SerializedName("version") - private String version; - - @Expose - @SerializedName("type") - private String type; - - @Expose - @SerializedName("released") - private long released; - - public String getVersion () { - - return this.version; - } - - public String getType () { - - return this.type; - } - - public Long getReleaseDate () { - - return this.released; - } - } } \ No newline at end of file diff --git a/src/test/resources/localtest/build.gradle b/src/test/resources/localtest/build.gradle index 7bc22f1..40021c7 100644 --- a/src/test/resources/localtest/build.gradle +++ b/src/test/resources/localtest/build.gradle @@ -5,30 +5,23 @@ buildscript { } dependencies { - classpath group: 'com.diluv.diluvgradle', name: 'DiluvGradle', version: '1.2.2' + classpath group: 'com.modrinth.minotaur', name: 'Minotaur', version: '1.0.0' } } apply plugin: 'java' -import com.diluv.diluvgradle.TaskDiluvUpload +import com.modrinth.minotaur.TaskModrinthUpload version = '1.0.2774' -task testPlugin (type: TaskDiluvUpload){ +task testPlugin (type: TaskModrinthUpload){ apiURL = 'http://127.0.0.1:4567' token = "C_RxaYIzXLYxKXD8itdhMUB6J6rKLcvPWpinbpH0ezc" projectId = 1 changelog = 'The changelog for my file.' uploadFile = jar - gameVersion = '1.12.2' - - doLast { - - if (wasUploadSuccessful()) { - - println 'Download: ' + uploadInfo.getDownloadURL() - } - } + addGameVersion('1.12.2') + addLoader('forge') } \ No newline at end of file diff --git a/src/test/resources/uploadtest/build.gradle b/src/test/resources/uploadtest/build.gradle index 56eaa30..5b57d15 100644 --- a/src/test/resources/uploadtest/build.gradle +++ b/src/test/resources/uploadtest/build.gradle @@ -15,20 +15,17 @@ buildscript { apply plugin: 'java' -import com.diluv.diluvgradle.TaskDiluvUpload +import com.modrinth.minotaur.TaskModrinthUpload version = '1.0.924943' -task testPlugin (type: TaskDiluvUpload){ +task testPlugin (type: TaskModrinthUpload){ apiURL = 'http://127.0.0.1:4567' token = "C_RxaYIzXLYxKXD8itdhMUB6J6rKLcvPWpinbpH0ezc" projectId = 1 changelog = 'The changelog for my file.' uploadFile = jar - gameVersion = '1.12.2' - - addDependency(2); - addOptionalDependency(3); - addIncompatibility(4); + addGameVersion('1.12.2') + addLoader('forge') } \ No newline at end of file