Skip to content

Commit

Permalink
Allow using Gradle addExtension task without property file
Browse files Browse the repository at this point in the history
(cherry picked from commit 1c16ec1)
  • Loading branch information
glefloch authored and gsmet committed Dec 6, 2022
1 parent c84d537 commit 20c883c
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ public AbstractGradleBuildFile(final Path projectDirPath, final ExtensionCatalog
public void writeToDisk() throws IOException {
if (rootProjectPath != null) {
Files.write(rootProjectPath.resolve(getSettingsGradlePath()), getModel().getRootSettingsContent().getBytes());
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
getModel().getRootPropertiesContent().store(out, "Gradle properties");
Files.write(rootProjectPath.resolve(GRADLE_PROPERTIES_PATH),
out.toByteArray());
if (hasRootProjectFile(GRADLE_PROPERTIES_PATH)) {
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
getModel().getRootPropertiesContent().store(out, "Gradle properties");
Files.write(rootProjectPath.resolve(GRADLE_PROPERTIES_PATH),
out.toByteArray());
}
}
} else {
writeToProjectFile(getSettingsGradlePath(), getModel().getSettingsContent().getBytes());
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
getModel().getPropertiesContent().store(out, "Gradle properties");
writeToProjectFile(GRADLE_PROPERTIES_PATH, out.toByteArray());
if (hasProjectFile(GRADLE_PROPERTIES_PATH)) {
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
getModel().getPropertiesContent().store(out, "Gradle properties");
writeToProjectFile(GRADLE_PROPERTIES_PATH, out.toByteArray());
}
}
}
writeToProjectFile(getBuildGradlePath(), getModel().getBuildContent().getBytes());
Expand Down

0 comments on commit 20c883c

Please sign in to comment.