fix #85, remove parts of deprecated code, update Mixin
parent
2b4d9fd3bc
commit
17b8aa7a70
|
@ -42,7 +42,7 @@ dependencies {
|
||||||
}
|
}
|
||||||
implementation ('org.jetbrains:intellij-fernflower:1.0.0.8')
|
implementation ('org.jetbrains:intellij-fernflower:1.0.0.8')
|
||||||
|
|
||||||
implementation ('net.fabricmc:sponge-mixin:0.7.11.23') {
|
implementation ('net.fabricmc:sponge-mixin:0.7.11.27') {
|
||||||
exclude module: 'launchwrapper'
|
exclude module: 'launchwrapper'
|
||||||
exclude module: 'guava'
|
exclude module: 'guava'
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ import org.gradle.api.Project;
|
||||||
import org.gradle.api.UnknownDomainObjectException;
|
import org.gradle.api.UnknownDomainObjectException;
|
||||||
import org.gradle.api.artifacts.Configuration;
|
import org.gradle.api.artifacts.Configuration;
|
||||||
import org.gradle.api.artifacts.Dependency;
|
import org.gradle.api.artifacts.Dependency;
|
||||||
|
import org.gradle.api.artifacts.component.ComponentIdentifier;
|
||||||
|
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
|
||||||
|
import org.gradle.api.artifacts.result.ResolvedArtifactResult;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -135,11 +138,16 @@ public class LoomGradleExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Dependency findDependency(Collection<String> configs, BiPredicate<String, String> groupNameFilter) {
|
private ResolvedArtifactResult findDependency(Collection<Configuration> configs, BiPredicate<String, String> groupNameFilter) {
|
||||||
for (String s : configs) {
|
for (Configuration config : configs) {
|
||||||
for (Dependency dependency : project.getConfigurations().getByName(s).getDependencies()) {
|
for (ResolvedArtifactResult artifact : config.getIncoming().getArtifacts().getArtifacts()) {
|
||||||
if (groupNameFilter.test(dependency.getGroup(), dependency.getName())) {
|
ComponentIdentifier artifactId = artifact.getId().getComponentIdentifier();
|
||||||
return dependency;
|
if (artifactId instanceof ModuleComponentIdentifier) {
|
||||||
|
String group = ((ModuleComponentIdentifier) artifactId).getGroup();
|
||||||
|
String name = ((ModuleComponentIdentifier) artifactId).getModule();
|
||||||
|
if (groupNameFilter.test(group, name)) {
|
||||||
|
return artifact;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,21 +156,13 @@ public class LoomGradleExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Dependency findBuildscriptDependency(BiPredicate<String, String> groupNameFilter) {
|
private ResolvedArtifactResult findBuildscriptDependency(BiPredicate<String, String> groupNameFilter) {
|
||||||
for (Configuration config : project.getBuildscript().getConfigurations().getAsMap().values()) {
|
return findDependency(project.getBuildscript().getConfigurations(), groupNameFilter);
|
||||||
for (Dependency dependency : config.getDependencies()) {
|
|
||||||
if (groupNameFilter.test(dependency.getGroup(), dependency.getName())) {
|
|
||||||
return dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getLoomVersion() {
|
public String getLoomVersion() {
|
||||||
Dependency dependency = findBuildscriptDependency((group, name) -> {
|
ResolvedArtifactResult dependency = findBuildscriptDependency((group, name) -> {
|
||||||
if (name.equalsIgnoreCase("fabric-loom")) {
|
if (name.equalsIgnoreCase("fabric-loom")) {
|
||||||
return group.equalsIgnoreCase("net.fabricmc");
|
return group.equalsIgnoreCase("net.fabricmc");
|
||||||
}
|
}
|
||||||
|
@ -182,12 +182,12 @@ public class LoomGradleExtension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dependency != null ? dependency.getVersion() : null;
|
return dependency != null ? ((ModuleComponentIdentifier) dependency.getId().getComponentIdentifier()).getVersion() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Dependency getMixinDependency() {
|
private ResolvedArtifactResult getMixinDependency() {
|
||||||
return findDependency(Collections.singletonList("compile"), (group, name) -> {
|
return findDependency(Collections.singletonList(project.getConfigurations().getByName("compile")), (group, name) -> {
|
||||||
if (name.equalsIgnoreCase("mixin") && group.equalsIgnoreCase("org.spongepowered")) {
|
if (name.equalsIgnoreCase("mixin") && group.equalsIgnoreCase("org.spongepowered")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -202,19 +202,17 @@ public class LoomGradleExtension {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getMixinVersion() {
|
public String getMixinVersion() {
|
||||||
Dependency dependency = getMixinDependency();
|
ResolvedArtifactResult dependency = getMixinDependency();
|
||||||
if (dependency != null) {
|
return dependency != null ? ((ModuleComponentIdentifier) dependency.getId().getComponentIdentifier()).getVersion() : null;
|
||||||
return dependency.getVersion();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getMixinJsonVersion() {
|
public String getMixinJsonVersion() {
|
||||||
Dependency dependency = getMixinDependency();
|
ResolvedArtifactResult artifactResult = getMixinDependency();
|
||||||
|
|
||||||
|
if (artifactResult != null) {
|
||||||
|
ModuleComponentIdentifier dependency = ((ModuleComponentIdentifier) artifactResult.getId().getComponentIdentifier());
|
||||||
|
|
||||||
if (dependency != null) {
|
|
||||||
if (dependency.getGroup().equalsIgnoreCase("net.fabricmc")) {
|
if (dependency.getGroup().equalsIgnoreCase("net.fabricmc")) {
|
||||||
if (Objects.requireNonNull(dependency.getVersion()).split("\\.").length >= 4) {
|
if (Objects.requireNonNull(dependency.getVersion()).split("\\.").length >= 4) {
|
||||||
return dependency.getVersion().substring(0, dependency.getVersion().lastIndexOf('.')) + "-SNAPSHOT";
|
return dependency.getVersion().substring(0, dependency.getVersion().lastIndexOf('.')) + "-SNAPSHOT";
|
||||||
|
|
|
@ -126,53 +126,16 @@ public abstract class DependencyProvider {
|
||||||
|
|
||||||
// TODO: Can this be done with stable APIs only?
|
// TODO: Can this be done with stable APIs only?
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
public Set<File> resolve(String classifier) {
|
public Set<File> resolve() {
|
||||||
if (classifier.isEmpty()) {
|
|
||||||
return sourceConfiguration.files(dependency);
|
return sourceConfiguration.files(dependency);
|
||||||
} else if ("sources".equals(classifier)) {
|
|
||||||
for (ResolvedArtifact rd : sourceConfiguration.getResolvedConfiguration().getResolvedArtifacts()) {
|
|
||||||
if (rd.getModuleVersion().getId().getGroup().equals(dependency.getGroup())
|
|
||||||
&& rd.getModuleVersion().getId().getName().equals(dependency.getName())
|
|
||||||
&& rd.getModuleVersion().getId().getVersion().equals(dependency.getVersion())) {
|
|
||||||
|
|
||||||
ImmutableSet.Builder<File> files = ImmutableSet.builder();
|
|
||||||
|
|
||||||
ArtifactResolutionQuery query = project.getDependencies().createArtifactResolutionQuery();
|
|
||||||
query.forComponents(DefaultModuleComponentIdentifier.newId(rd.getModuleVersion().getId()));
|
|
||||||
//noinspection unchecked
|
|
||||||
query.withArtifacts(JvmLibrary.class, SourcesArtifact.class);
|
|
||||||
for (ComponentArtifactsResult cresult : query.execute().getResolvedComponents()) {
|
|
||||||
for (ArtifactResult result : cresult.getArtifacts(SourcesArtifact.class)) {
|
|
||||||
if (result instanceof ResolvedArtifactResult) {
|
|
||||||
files.add(((ResolvedArtifactResult) result).getFile());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return files.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ImmutableSet.of();
|
|
||||||
} else {
|
|
||||||
project.getLogger().warn("Unsupported classifier '" + classifier + "'");
|
|
||||||
return ImmutableSet.of();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<File> resolveFile() {
|
public Optional<File> resolveFile() {
|
||||||
return resolveFile("");
|
Set<File> files = resolve();
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<File> resolveFile(String classifier) {
|
|
||||||
Set<File> files = resolve(classifier);
|
|
||||||
if (files.isEmpty()) {
|
if (files.isEmpty()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
} else if (files.size() > 1) {
|
} else if (files.size() > 1) {
|
||||||
StringBuilder builder = new StringBuilder(this.toString());
|
StringBuilder builder = new StringBuilder(this.toString());
|
||||||
if (!classifier.isEmpty()) {
|
|
||||||
builder.append(" [").append(classifier).append("]");
|
|
||||||
}
|
|
||||||
builder.append(" resolves to more than one file:");
|
builder.append(" resolves to more than one file:");
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
builder.append("\n\t-").append(f.getAbsolutePath());
|
builder.append("\n\t-").append(f.getAbsolutePath());
|
||||||
|
@ -261,15 +224,6 @@ public abstract class DependencyProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<File> resolve(String classifier) {
|
|
||||||
File file = classifierToFile.get(classifier);
|
|
||||||
if (file != null) return Collections.singleton(file);
|
|
||||||
|
|
||||||
//Suppose we can always try the super resolving method, doubt it will do anything more though
|
|
||||||
return super.resolve(classifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getResolvedVersion() {
|
public String getResolvedVersion() {
|
||||||
return version;
|
return version;
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class LoomDependencyManager {
|
||||||
|
|
||||||
for (Dependency dependency : configuration.getDependencies()) {
|
for (Dependency dependency : configuration.getDependencies()) {
|
||||||
DependencyInfo info = DependencyInfo.create(project, dependency, configuration);
|
DependencyInfo info = DependencyInfo.create(project, dependency, configuration);
|
||||||
for (File input : info.resolve("")) {
|
for (File input : info.resolve()) {
|
||||||
if (seenFiles.add(input)) {
|
if (seenFiles.add(input)) {
|
||||||
ModProcessor.readInstallerJson(input, project);
|
ModProcessor.readInstallerJson(input, project);
|
||||||
if (extension.getInstallerJson() != null) {
|
if (extension.getInstallerJson() != null) {
|
||||||
|
|
Loading…
Reference in New Issue