Skip to content

Commit

Permalink
Fix #55
Browse files Browse the repository at this point in the history
  • Loading branch information
triphora committed Jul 16, 2023
1 parent dbd652e commit d88762f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 39 deletions.
15 changes: 6 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id 'com.gradle.plugin-publish' version '1.1.0'
id 'com.gradle.plugin-publish' version '1.2.0'
}

version = '2.8.1'
version = '2.8.2'
group = 'com.modrinth.minotaur'
archivesBaseName = 'Minotaur'
description = 'Modrinth plugin for publishing builds to the website!'
Expand All @@ -27,22 +27,19 @@ dependencies {
}

gradlePlugin {
website = 'https://modrinth.com'
vcsUrl = 'https://github.com/modrinth/minotaur'
plugins {
minotaur {
id = 'com.modrinth.minotaur'
implementationClass = 'com.modrinth.minotaur.Minotaur'
displayName = 'Minotaur'
description = 'Modrinth plugin for publishing builds to the website!'
// tags = ['modrinth', 'publish', 'mods', 'minecraft']
}
}
}

pluginBundle {
website = 'https://modrinth.com'
vcsUrl = 'https://github.com/modrinth/minotaur'
description = 'Modrinth plugin for publishing builds to the website!'
tags = ['modrinth', 'publish', 'mods', 'minecraft']
}

jar {
manifest {
attributes([
Expand Down
2 changes: 1 addition & 1 deletion fg/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
maven { url = 'https://files.minecraftforge.net/maven' }
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.+', changing: true
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.+', changing: true
}
}

Expand Down
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.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 2 additions & 1 deletion loom/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "fabric-loom" version "1.0.+"
id "fabric-loom" version "1.3.+"
id "com.modrinth.minotaur" version "2.+"
}

Expand Down Expand Up @@ -33,6 +33,7 @@ modrinth {
optional.version "UakHulqw"
incompatible.version "kdIr8lsr", "b1.2+mod"
embedded.project "sbbGxWge"
required.version "test-project", "1.19.4-SNAPSHOT"
}
debugMode = true
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
mavenCentral()
gradlePluginPortal()
}
}
rootProject.name = 'Minotaur'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ && getProject().getExtensions().findByName("loom") != null) {
List<ProjectDependency> dependencies = new ArrayList<>();
protoDependencies.addAll(ext.getNamedDependenciesAsList());
protoDependencies.addAll(ext.getDependencies().get());
protoDependencies.stream().map(dependency -> dependency.toNew(api, ext)).forEach(dependencies::add);
protoDependencies.stream().map(dependency -> dependency.toNew(api)).forEach(dependencies::add);

// Get each of the files, starting with the primary file
List<File> files = new ArrayList<>();
Expand Down
37 changes: 12 additions & 25 deletions src/main/java/com/modrinth/minotaur/dependencies/Dependency.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.modrinth.minotaur.ModrinthExtension;
import masecla.modrinth4j.endpoints.version.GetProjectVersions.GetProjectVersionsRequest;
import masecla.modrinth4j.main.ModrinthAPI;
import masecla.modrinth4j.model.version.ProjectVersion;
import masecla.modrinth4j.model.version.ProjectVersion.ProjectDependency;
import masecla.modrinth4j.model.version.ProjectVersion.ProjectDependencyType;
import org.gradle.api.GradleException;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.AbstractMap.SimpleEntry;
import java.util.Locale;
import java.util.Objects;

Expand Down Expand Up @@ -57,10 +54,9 @@ ProjectDependencyType getDependencyType() {

/**
* @param api {@link ModrinthAPI} instance
* @param ext {@link ModrinthExtension} instance
* @return a {@link ProjectDependency} instance from a {@link Dependency}
*/
public ProjectDependency toNew(ModrinthAPI api, ModrinthExtension ext) {
public ProjectDependency toNew(ModrinthAPI api) {
if (this instanceof ModDependency) {
ModDependency dep = (ModDependency) this;
String id = Objects.requireNonNull(
Expand All @@ -70,8 +66,16 @@ public ProjectDependency toNew(ModrinthAPI api, ModrinthExtension ext) {
return new ProjectDependency(null, id, null, dep.getDependencyType());
} else if (this instanceof VersionDependency) {
VersionDependency dep = (VersionDependency) this;
String versionId = resolveVersionId(dep.getProjectId(), dep.getVersionId(), api);
return new ProjectDependency(versionId, dep.getProjectId(), null, dep.getDependencyType());
SimpleEntry<String, String> projectInfo;
try {
ProjectVersion version = dep.getProjectId() == null
? api.versions().getVersion(dep.getVersionId()).join()
: api.versions().getVersionByNumber(dep.getProjectId(), dep.getVersionId()).join();
projectInfo = new SimpleEntry<>(version.getProjectId(), version.getId());
} catch (Exception e) {
throw new GradleException("Failed to resolve version \"" + dep.getVersionId() + "\"!", e);
}
return new ProjectDependency(projectInfo.getValue(), projectInfo.getKey(), null, dep.getDependencyType());
} else {
throw new GradleException("Dependency was not an instance of ModDependency or VersionDependency!");
}
Expand All @@ -88,21 +92,4 @@ public static Dependency fromNew(ProjectDependency newDep) {
return new ModDependency(newDep.getProjectId(), newDep.getDependencyType().name());
}
}

/**
* Returns a project ID from a project ID or slug
*
* @param versionId ID or version number of the project to resolve
* @return ID of the resolved project
*/
private String resolveVersionId(@Nullable String projectId, String versionId, ModrinthAPI api) {
try {
ProjectVersion version = projectId == null
? api.versions().getVersion(versionId).join()
: api.versions().getVersionByNumber(projectId, versionId).join();
return version.getId();
} catch (Exception e) {
throw new GradleException("Failed to resolve version \"" + versionId + "\"!", e);
}
}
}

0 comments on commit d88762f

Please sign in to comment.