Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.inject.Inject;
Expand All @@ -17,6 +18,7 @@
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.provider.Property;
import org.gradle.api.resources.TextResourceFactory;
import org.gradle.internal.os.OperatingSystem;
import org.gradle.nativeplatform.plugins.NativeComponentPlugin;

Expand Down Expand Up @@ -54,10 +56,13 @@ public WPIJavaVendorDepsExtension getJavaVendor() {
return javaVendor;
}

private final TextResourceFactory resources;

@Inject
public WPIVendorDepsExtension(Project project) {
this.log = ETLoggerFactory.INSTANCE.create("WPIVendorDeps");
this.project = project;
this.resources = project.getResources().getText();
hwSimulation = project.hasProperty(HW_SIM_SWITCH_PROPERTY);
dependencySet = project.getObjects().namedDomainObjectSet(NamedJsonDependency.class);
vendorRepos = project.getObjects().namedDomainObjectSet(VendorMavenRepo.class);
Expand Down Expand Up @@ -112,6 +117,32 @@ public static List<File> vendorFiles(File directory) {
}
}

private void applyIncludedGradleScriptInternal(NamedJsonDependency dep) {
String includedGradle = dep.getDependency().includedGradle;
if (includedGradle == null) {
return;
}

if (includedGradle.isBlank()) {
return;
}

project.apply(Map.of("from", resources.fromString(includedGradle)));
}

public void applyIncludedGradleScripts() {
for (NamedJsonDependency dep : dependencySet) {
applyIncludedGradleScriptInternal(dep);
}
}

public void applyIncludedGradleScript(String uuid) {
NamedJsonDependency dep = dependencySet.findByName(uuid);
if (dep != null) {
applyIncludedGradleScriptInternal(dep);
}
}

public void loadAll() {
loadFrom(vendorFolder(project));
}
Expand Down Expand Up @@ -266,6 +297,7 @@ public static class JsonDependency {
public JavaArtifact[] javaDependencies;
public JniArtifact[] jniDependencies;
public CppArtifact[] cppDependencies;
public String includedGradle;
}

public static class NamedJsonDependency implements Named {
Expand Down