diff options
| author | Menny Even Danan <menny@evendanan.net> | 2020-03-27 17:54:44 +0000 |
|---|---|---|
| committer | Menny Even Danan <menny@evendanan.net> | 2020-03-27 17:54:44 +0000 |
| commit | a973331f55cf11a0c0ceb739d40ba82df2ca2a09 (patch) | |
| tree | a83032301eee2fb3dc35a2b3830b760d7529be0e /buildSrc/src/main/java/deployment/DeploymentStatusRequestTask.java | |
| parent | b5136f8836cc428435998565345707516c634e41 (diff) | |
| download | AnySoftKeyboard-a973331f55cf11a0c0ceb739d40ba82df2ca2a09.tar.gz AnySoftKeyboard-a973331f55cf11a0c0ceb739d40ba82df2ca2a09.tar.bz2 | |
Fix output file creation for deploy task
Diffstat (limited to 'buildSrc/src/main/java/deployment/DeploymentStatusRequestTask.java')
| -rw-r--r-- | buildSrc/src/main/java/deployment/DeploymentStatusRequestTask.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/buildSrc/src/main/java/deployment/DeploymentStatusRequestTask.java b/buildSrc/src/main/java/deployment/DeploymentStatusRequestTask.java index df6eed23d..38cd87be6 100644 --- a/buildSrc/src/main/java/deployment/DeploymentStatusRequestTask.java +++ b/buildSrc/src/main/java/deployment/DeploymentStatusRequestTask.java @@ -10,7 +10,6 @@ import java.util.Arrays; import java.util.Locale; import javax.inject.Inject; import org.gradle.api.DefaultTask; -import org.gradle.api.Project; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.TaskAction; @@ -20,12 +19,19 @@ public abstract class DeploymentStatusRequestTask extends DefaultTask { private String mDeploymentId; private String mDeploymentState; - static void makeBuildDir(Project project) throws IOException { - File buildDir = project.getBuildDir(); + static void createEmptyOutputFile(File outputFile) throws IOException { + File buildDir = outputFile.getParentFile(); if (!buildDir.isDirectory() && !buildDir.mkdirs()) { throw new IOException( "Failed to create build output folder: " + buildDir.getAbsolutePath()); } + + if (outputFile.isFile() && !outputFile.delete()) { + throw new IOException( + "Failed to delete existing output file : " + outputFile.getAbsolutePath()); + } + + Files.createFile(outputFile.toPath()); } @Inject @@ -70,7 +76,7 @@ public abstract class DeploymentStatusRequestTask extends DefaultTask { @TaskAction public void statusAction() { try { - makeBuildDir(getProject()); + createEmptyOutputFile(getStatueFile()); final DeploymentStatus.Response response = statusRequest( new RequestCommandLineArgs(getProject().getProperties()), |
