Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a basic vendor deps dependency mechanism #163

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ targetCompatibility = 11

allprojects {
group = "edu.wpi.first"
version = "2024.1.0"
version = "2024.2.0"

if (project.hasProperty('publishVersion')) {
version = project.publishVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package edu.wpi.first.nativeutils.vendordeps;

public class ConflictingVendorDependencyException extends RuntimeException {
public ConflictingVendorDependencyException(String requestingUuid, String requiredUuid, String errorMessage) {
super("Conflicting Vendor Dependency " + requiredUuid + " for uuid " + requestingUuid + ". Reason: "
+ errorMessage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package edu.wpi.first.nativeutils.vendordeps;

public class MissingRequiredVendorDependencyException extends RuntimeException {
public MissingRequiredVendorDependencyException(String requestingUuid, String requiredUuid, String errorMessage) {
super("Missing Vendor Dependency " + requiredUuid + " for uuid " + requestingUuid + ". Reason: "
+ errorMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,29 @@ public void loadAll() {
loadFrom(vendorFolder(project));
}

public void validateDependencies() {
for (NamedJsonDependency jsonDep : dependencySet) {
VendorDependency[] requiredDependencies = jsonDep.dependency.requires;
if (requiredDependencies != null) {
for (VendorDependency requiredDep : requiredDependencies) {
if (dependencySet.findByName(requiredDep.uuid) == null) {
throw new ConflictingVendorDependencyException(jsonDep.name, requiredDep.uuid,
requiredDep.errorMessage);
}
}
}
VendorDependency[] conflictsWithDependencies = jsonDep.dependency.conflictsWith;
if (conflictsWithDependencies != null) {
for (VendorDependency conflictsWithDep : conflictsWithDependencies) {
if (dependencySet.findByName(conflictsWithDep.uuid) != null) {
throw new ConflictingVendorDependencyException(jsonDep.name, conflictsWithDep.uuid,
conflictsWithDep.errorMessage);
}
}
}
}
}

public void loadFrom(File directory) {
for (File f : vendorFiles(directory)) {
JsonDependency dep = parse(f);
Expand Down Expand Up @@ -255,10 +278,19 @@ public boolean useInRio() {
public boolean sharedLibrary;
}

public static class VendorDependency {
public String uuid;
public String errorMessage;
public String offlineFileName;
public String onlineUrl;
}

public static class JsonDependency {
public String name;
public String version;
public String uuid;
public VendorDependency[] requires;
public VendorDependency[] conflictsWith;
public String[] mavenUrls;
public String[] extraGroupIds;
public String jsonUrl;
Expand Down
2 changes: 1 addition & 1 deletion testing/cpp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import edu.wpi.first.toolchain.NativePlatforms

plugins {
id "cpp"
id "edu.wpi.first.NativeUtils" version "2024.0.1"
id "edu.wpi.first.NativeUtils" version "2024.1.0"
}

nativeUtils.addWpiNativeUtils()
Expand Down
Loading