Skip to content

Commit

Permalink
just need to get the data
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty committed Dec 7, 2023
1 parent 2c819e6 commit 780d66e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
25 changes: 19 additions & 6 deletions src/main/java/edu/wpi/first/gradlerio/deploy/DeployData.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package edu.wpi.first.gradlerio.deploy;

import com.google.gson.GsonBuilder;

import edu.wpi.first.gradlerio.deploy.roborio.RoboRIO;
import edu.wpi.first.deployutils.deploy.artifact.FileArtifact;

import com.google.gson.Gson;

import java.util.Map;
Expand All @@ -10,7 +14,8 @@
import java.util.HashMap;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.io.File;
import java.io.FileWriter;
import java.nio.file.Path;
import java.nio.file.Paths;

Expand All @@ -22,7 +27,8 @@ class DeployLogFile {
public String gitHash;
public String gitBranch;
public String gitDesc;
public static final Path LOG_FILE_PATH = Paths.get("/home/lvuser/deploy.json");
public static final String LOG_FILE_PATH = "deploy.json";
public File deployFile;
public String[] deployItems = {
"deployHost",
"deployUser",
Expand All @@ -36,8 +42,9 @@ class DeployLogFile {
Gson builder = new GsonBuilder().create();
Map<String, String> data = new HashMap<String, String>();
String jsonDeploy;
FileArtifact deployArtifact;

DeployLogFile() {
DeployLogFile(RoboRIO target) {
data.put(deployItems[0], deployHost);
data.put(deployItems[1], deployUser);
data.put(deployItems[2], deployDate);
Expand All @@ -48,10 +55,16 @@ class DeployLogFile {

jsonDeploy = builder.toJson(data);

deployFile = new File(LOG_FILE_PATH, jsonDeploy);

try {
Files.writeString(LOG_FILE_PATH, jsonDeploy, StandardCharsets.UTF_8);
} catch(IOException e) {
throw new GradleException("Could not write deploy log file");
deployFile.createNewFile();
} catch (IOException e) {
throw new GradleException("Couldn't write deploy log file", e);
}

deployArtifact = new FileArtifact(LOG_FILE_PATH, target);

target.getArtifacts().add(deployArtifact);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ public void apply(Project project) {
deployExtension.getTargets().registerFactory(RoboRIO.class, name -> {
RoboRIO target = project.getObjects().newInstance(RoboRIO.class, name, project, deployExtension, frcExtension);
configureRoboRIOTypes(target);
new DeployLogFile(target);
return target;
});

new DeployLogFile();
}

public Project getProject() {
Expand Down

0 comments on commit 780d66e

Please sign in to comment.