Skip to content

Commit

Permalink
create file to be deployed
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty committed Dec 7, 2023
1 parent 5bfcaeb commit 2c819e6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/main/java/edu/wpi/first/gradlerio/deploy/DeployData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

import com.google.gson.GsonBuilder;
import com.google.gson.Gson;

import java.util.Map;

import org.gradle.api.GradleException;

import java.util.HashMap;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

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

DeployLogFile() {
data.put(deployItems[0], deployHost);
Expand All @@ -41,6 +48,10 @@ class DeployLogFile {

jsonDeploy = builder.toJson(data);

deployDotJson = new File(LOG_FILE_PATH);
try {
Files.writeString(LOG_FILE_PATH, jsonDeploy, StandardCharsets.UTF_8);
} catch(IOException e) {
throw new GradleException("Could not write deploy log file");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import edu.wpi.first.gradlerio.deploy.roborio.RoboRIO;
import edu.wpi.first.gradlerio.deploy.roborio.RobotCommandArtifact;
import edu.wpi.first.deployutils.deploy.NamedObjectFactory;
import edu.wpi.first.gradlerio.deploy.DeployLogFile;

public class FRCDeployPlugin implements Plugin<Project> {

Expand Down Expand Up @@ -59,6 +60,8 @@ public void apply(Project project) {
configureRoboRIOTypes(target);
return target;
});

new DeployLogFile();
}

public Project getProject() {
Expand Down

0 comments on commit 2c819e6

Please sign in to comment.