Skip to content

Commit

Permalink
should be working now
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty committed Mar 28, 2024
1 parent 3669a35 commit 963e7b3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

import org.ajoberstar.grgit.Grgit;

import javax.inject.Inject;

import org.codehaus.groovy.runtime.ResourceGroovyMethods;

import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.OutputFile;

Expand All @@ -28,12 +31,15 @@ public class CreateLogFileTask extends DefaultTask {
"gitDesc",
};
private File deployFile;
private String json;

@TaskAction
public void execute() {
Gson builder = new GsonBuilder().create();
Grgit grgit;
@Inject
public CreateLogFileTask() {
HashMap<String, String> data = new HashMap<String, String>();
GsonBuilder builder = new GsonBuilder();
builder.setPrettyPrinting();
Gson jsongen = builder.create();
Grgit grgit;

try {
grgit = Grgit.open();
Expand All @@ -59,7 +65,8 @@ public void execute() {
} catch (Exception e) {
throw new GradleException("Couldn't get git description", e);
}
} catch (Exception e) {}
} catch (Exception e) {
}

try {
data.put(DEPLOY_ITEMS[0], Runtime.getRuntime().exec("hostname").getOutputStream().toString().strip());
Expand All @@ -71,12 +78,21 @@ public void execute() {
data.put(DEPLOY_ITEMS[2], LocalDateTime.now().toString());
data.put(DEPLOY_ITEMS[3], System.getProperty("user.dir"));

deployFile = new File(builder.toJson(data));
json = jsongen.toJson(data);
}

@TaskAction
public void execute() throws IOException {
deployFile.getParentFile().mkdirs();
ResourceGroovyMethods.setText(deployFile, json);
}

public void setDeployFile(String path) {
deployFile = new File(path);
}

@OutputFile
public RegularFileProperty getDeployFile() {
// TODO! figure out how to do this
public File getDeployFile() {
return deployFile;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public FRCExtension(Project project, DeployExtension deployExtension) {
});

deployLogFile = project.getTasks().register("writeDeployFile", CreateLogFileTask.class, t -> {
t.getDeployFile().set(project.getLayout().getBuildDirectory().file("debug/deploy.json"));
t.setDeployFile(project.getLayout().getBuildDirectory().toString() + "debug/debug_info.json");
});

deployExtension.getDeployTask().configure(t -> {
Expand Down

0 comments on commit 963e7b3

Please sign in to comment.