Skip to content

Commit 300bdd7

Browse files
committed
should be working now
1 parent 1c2ce15 commit 300bdd7

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

src/main/java/edu/wpi/first/gradlerio/deploy/CreateLogFileTask.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55

66
import org.ajoberstar.grgit.Grgit;
77

8+
import javax.inject.Inject;
9+
10+
import org.codehaus.groovy.runtime.ResourceGroovyMethods;
11+
812
import org.gradle.api.DefaultTask;
913
import org.gradle.api.GradleException;
10-
import org.gradle.api.file.RegularFileProperty;
1114
import org.gradle.api.tasks.TaskAction;
1215
import org.gradle.api.tasks.OutputFile;
1316

@@ -28,12 +31,15 @@ public class CreateLogFileTask extends DefaultTask {
2831
"gitDesc",
2932
};
3033
private File deployFile;
34+
private String json;
3135

32-
@TaskAction
33-
public void execute() {
34-
Gson builder = new GsonBuilder().create();
35-
Grgit grgit;
36+
@Inject
37+
public CreateLogFileTask() {
3638
HashMap<String, String> data = new HashMap<String, String>();
39+
GsonBuilder builder = new GsonBuilder();
40+
builder.setPrettyPrinting();
41+
Gson jsongen = builder.create();
42+
Grgit grgit;
3743

3844
try {
3945
grgit = Grgit.open();
@@ -59,7 +65,8 @@ public void execute() {
5965
} catch (Exception e) {
6066
throw new GradleException("Couldn't get git description", e);
6167
}
62-
} catch (Exception e) {}
68+
} catch (Exception e) {
69+
}
6370

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

74-
deployFile = new File(builder.toJson(data));
81+
json = jsongen.toJson(data);
82+
}
83+
84+
@TaskAction
85+
public void execute() throws IOException {
86+
deployFile.getParentFile().mkdirs();
87+
ResourceGroovyMethods.setText(deployFile, json);
88+
}
89+
90+
public void setDeployFile(String path) {
91+
deployFile = new File(path);
7592
}
7693

7794
@OutputFile
78-
public RegularFileProperty getDeployFile() {
79-
// TODO! figure out how to do this
95+
public File getDeployFile() {
8096
return deployFile;
8197
};
8298
}

src/main/java/edu/wpi/first/gradlerio/deploy/FRCExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public FRCExtension(Project project, DeployExtension deployExtension) {
2626
});
2727

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

3232
deployExtension.getDeployTask().configure(t -> {

0 commit comments

Comments
 (0)