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

Fix vendordep update behavior. #240

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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 @@ -24,7 +24,6 @@
public class VendorDepTask extends DefaultTask {
private String url;
private boolean update;
private DownloadAction downloadAction = new DownloadAction(getProject());
private WPIVendorDepsExtension wpiExt = getProject().getExtensions().getByType(WPIVendorDepsExtension.class);

@Option(option = "url", description = "The vendordep JSON URL or path")
Expand Down Expand Up @@ -54,8 +53,11 @@ public void install() throws IOException {
BufferedReader reader = Files.newBufferedReader(Path.of(vendordep.getPath()));
var jsonUrl = gson.fromJson(reader, JsonDependency.class).jsonUrl;
if (jsonUrl != null) {
url = jsonUrl;
downloadRemote(Path.of(vendordep.getPath()));
if (jsonUrl.isEmpty()) {
getLogger().warn("Couldn't get jsonUrl for " + vendordep);
continue;
}
downloadRemote(Path.of(vendordep.getPath()), jsonUrl);
} else {
getLogger().warn("Couldn't get jsonUrl for " + vendordep);
}
Expand All @@ -71,7 +73,7 @@ public void install() throws IOException {
copyLocal(filename, dest);
} else {
getLogger().info("Remotely fetching " + filename);
downloadRemote(dest);
downloadRemote(dest, url);
}

var destString = dest.toString();
Expand Down Expand Up @@ -168,7 +170,8 @@ private void copyLocal(String filename, Path dest) {
* Download a vendor JSON file from a URL
* @param dest the destination file
*/
private void downloadRemote(Path dest) throws IOException {
private void downloadRemote(Path dest, String url) throws IOException {
DownloadAction downloadAction = new DownloadAction(getProject());
downloadAction.src(url);
downloadAction.dest(dest.toFile());
downloadAction.execute();
Expand Down