Improve error handling in the case mappings or minecraft dependency was not provided #238)

dev/0.11
Fudge 2020-07-26 23:01:18 +03:00 committed by GitHub
parent 9d318dd859
commit d7f61512b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -68,6 +68,7 @@ public class MinecraftProvider extends DependencyProvider {
@Override @Override
public void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws Exception { public void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws Exception {
minecraftVersion = dependency.getDependency().getVersion(); minecraftVersion = dependency.getDependency().getVersion();
boolean offline = getProject().getGradle().getStartParameter().isOffline(); boolean offline = getProject().getGradle().getStartParameter().isOffline();
initFiles(); initFiles();

View File

@ -33,6 +33,8 @@ import java.util.Map;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.DependencySet;
import org.gradle.api.artifacts.ExternalModuleDependency; import org.gradle.api.artifacts.ExternalModuleDependency;
import org.gradle.api.artifacts.repositories.MavenArtifactRepository; import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
@ -103,7 +105,20 @@ public class LoomDependencyManager {
for (ProviderList list : targetProviders) { for (ProviderList list : targetProviders) {
Configuration configuration = project.getConfigurations().getByName(list.key); Configuration configuration = project.getConfigurations().getByName(list.key);
configuration.getDependencies().forEach(dependency -> { DependencySet dependencies = configuration.getDependencies();
if (dependencies.isEmpty()) {
throw new IllegalArgumentException(String.format("No '%s' dependency was specified!", list.key));
}
if (dependencies.size() > 1) {
throw new IllegalArgumentException(String.format("Only one '%s' dependency should be specified, but %d were!",
list.key,
dependencies.size())
);
}
for (Dependency dependency : dependencies) {
for (DependencyProvider provider : list.providers) { for (DependencyProvider provider : list.providers) {
DependencyProvider.DependencyInfo info = DependencyInfo.create(project, dependency, configuration); DependencyProvider.DependencyInfo info = DependencyInfo.create(project, dependency, configuration);
@ -113,7 +128,7 @@ public class LoomDependencyManager {
throw new RuntimeException("Failed to provide " + dependency.getGroup() + ":" + dependency.getName() + ":" + dependency.getVersion() + " : " + e.getMessage(), e); throw new RuntimeException("Failed to provide " + dependency.getGroup() + ":" + dependency.getName() + ":" + dependency.getVersion() + " : " + e.getMessage(), e);
} }
} }
}); }
} }
SourceRemapper sourceRemapper = new SourceRemapper(project, true); SourceRemapper sourceRemapper = new SourceRemapper(project, true);