From 114807c27e7d0e9abd8dfe3b7b50ab42d82672e7 Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Mon, 8 Jul 2024 13:03:31 -0300 Subject: [PATCH] Avoid storing timestamp in Gradle.properties (cherry picked from commit 423b4f4d7dc159a605ab139e33d827791e606a78) --- .github/dependabot.yml | 1 + .../archetype-resources/gradle.properties | 4 ++-- .../base/gradle.tpl.qute.properties | 5 +++-- .../gradle/base/gradle.tpl.qute.properties | 5 +++-- .../tools/devtools-common/pom.xml | 4 ++++ .../buildfile/AbstractGradleBuildFile.java | 21 ++++++++++--------- .../AbstractGradleBuildFilesCreator.java | 7 ++++++- .../devtools/project/buildfile/BuildFile.java | 4 ++++ independent-projects/tools/pom.xml | 6 ++++++ .../compile-only-lombok/gradle.properties | 6 +++--- .../gradle.properties | 4 ++-- .../gradle.properties | 4 ++-- .../gradle.properties | 5 +++-- 13 files changed, 50 insertions(+), 26 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7ffe773060c4f..9df0e488cf3af 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -184,6 +184,7 @@ updates: - dependency-name: biz.paluch.logging:logstash-gelf - dependency-name: org.bitbucket.b_c:jose4j - dependency-name: io.fabric8:maven-model-helper + - dependency-name: org.codejive:java-properties ignore: # this one cannot be upgraded due to the usage of proxies in new versions # the proxy implements interfaces in a random order which causes issues diff --git a/extensions/amazon-lambda/maven-archetype/src/main/resources/archetype-resources/gradle.properties b/extensions/amazon-lambda/maven-archetype/src/main/resources/archetype-resources/gradle.properties index 644310c2b3a94..c77b7693b0052 100644 --- a/extensions/amazon-lambda/maven-archetype/src/main/resources/archetype-resources/gradle.properties +++ b/extensions/amazon-lambda/maven-archetype/src/main/resources/archetype-resources/gradle.properties @@ -1,5 +1,5 @@ -#Gradle properties -#Tue Mar 17 10:20:48 UTC 2020 +# Gradle properties + quarkusPluginVersion=${project.version} quarkusPlatformArtifactId=quarkus-bom quarkusPlatformVersion=${project.version} diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle-kotlin-dsl/base/gradle.tpl.qute.properties b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle-kotlin-dsl/base/gradle.tpl.qute.properties index d3160667382c5..80d94672c2262 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle-kotlin-dsl/base/gradle.tpl.qute.properties +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle-kotlin-dsl/base/gradle.tpl.qute.properties @@ -1,6 +1,7 @@ -#Gradle properties +# Gradle properties + quarkusPluginId={quarkus.gradle-plugin.id} quarkusPluginVersion={quarkus.gradle-plugin.version} quarkusPlatformGroupId={quarkus.platform.group-id} quarkusPlatformArtifactId={quarkus.platform.artifact-id} -quarkusPlatformVersion={quarkus.platform.version} \ No newline at end of file +quarkusPlatformVersion={quarkus.platform.version} diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle/base/gradle.tpl.qute.properties b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle/base/gradle.tpl.qute.properties index d3160667382c5..80d94672c2262 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle/base/gradle.tpl.qute.properties +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle/base/gradle.tpl.qute.properties @@ -1,6 +1,7 @@ -#Gradle properties +# Gradle properties + quarkusPluginId={quarkus.gradle-plugin.id} quarkusPluginVersion={quarkus.gradle-plugin.version} quarkusPlatformGroupId={quarkus.platform.group-id} quarkusPlatformArtifactId={quarkus.platform.artifact-id} -quarkusPlatformVersion={quarkus.platform.version} \ No newline at end of file +quarkusPlatformVersion={quarkus.platform.version} diff --git a/independent-projects/tools/devtools-common/pom.xml b/independent-projects/tools/devtools-common/pom.xml index 2e5832fddb6af..e7b70a29daea2 100644 --- a/independent-projects/tools/devtools-common/pom.xml +++ b/independent-projects/tools/devtools-common/pom.xml @@ -106,6 +106,10 @@ jakarta.enterprise jakarta.enterprise.cdi-api + + org.codejive + java-properties + org.junit.jupiter junit-jupiter diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFile.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFile.java index dd5ea2931ce1e..d9ad8bdb7eb79 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFile.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFile.java @@ -1,18 +1,19 @@ package io.quarkus.devtools.project.buildfile; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.StringWriter; import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Properties; import java.util.Scanner; import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.codejive.properties.Properties; + import io.quarkus.maven.dependency.ArtifactCoords; import io.quarkus.maven.dependency.ArtifactKey; import io.quarkus.registry.catalog.ExtensionCatalog; @@ -47,22 +48,22 @@ public void writeToDisk() throws IOException { if (rootProjectPath != null) { Files.write(rootProjectPath.resolve(getSettingsGradlePath()), getModel().getRootSettingsContent().getBytes()); 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()); + try (StringWriter sw = new StringWriter()) { + getModel().getRootPropertiesContent().store(sw, "Gradle properties"); + Files.writeString(rootProjectPath.resolve(GRADLE_PROPERTIES_PATH), + sw.toString()); } } } else { writeToProjectFile(getSettingsGradlePath(), getModel().getSettingsContent().getBytes()); if (hasProjectFile(GRADLE_PROPERTIES_PATH)) { - try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { - getModel().getPropertiesContent().store(out, "Gradle properties"); - writeToProjectFile(GRADLE_PROPERTIES_PATH, out.toByteArray()); + try (StringWriter sw = new StringWriter()) { + getModel().getPropertiesContent().store(sw, "Gradle properties"); + writeToProjectFile(GRADLE_PROPERTIES_PATH, sw.toString()); } } } - writeToProjectFile(getBuildGradlePath(), getModel().getBuildContent().getBytes()); + writeToProjectFile(getBuildGradlePath(), getModel().getBuildContent()); } static boolean containsProperty(ArtifactCoords coords) { diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFilesCreator.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFilesCreator.java index 5d6ad5618536f..e3c8f24cf8069 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFilesCreator.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFilesCreator.java @@ -8,9 +8,10 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; -import java.util.Properties; import java.util.concurrent.atomic.AtomicReference; +import org.codejive.properties.Properties; + import io.quarkus.devtools.project.QuarkusProject; import io.quarkus.devtools.project.buildfile.AbstractGradleBuildFile.Model; import io.quarkus.maven.dependency.ArtifactCoords; @@ -122,6 +123,10 @@ protected void writeToProjectFile(final String fileName, final byte[] content) t Files.write(quarkusProject.getProjectDirPath().resolve(fileName), content); } + protected void writeToProjectFile(final String fileName, final String content) throws IOException { + Files.writeString(quarkusProject.getProjectDirPath().resolve(fileName), content); + } + private void createProperties() throws IOException { final ExtensionCatalog platform = quarkusProject.getExtensionsCatalog(); Properties props = getModel().getPropertiesContent(); diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java index a05d32b9e103a..ce9cb33e71f3f 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java @@ -155,6 +155,10 @@ protected void writeToProjectFile(final String fileName, final byte[] content) t Files.write(projectDirPath.resolve(fileName), content); } + protected void writeToProjectFile(final String fileName, final String content) throws IOException { + Files.writeString(projectDirPath.resolve(fileName), content); + } + private Set getDependenciesKeys() throws IOException { return getDependencies().stream().map(ArtifactCoords::getKey).collect(Collectors.toSet()); } diff --git a/independent-projects/tools/pom.xml b/independent-projects/tools/pom.xml index 61e0fcf3f99fd..9432bc380b5fe 100644 --- a/independent-projects/tools/pom.xml +++ b/independent-projects/tools/pom.xml @@ -60,6 +60,7 @@ 3.2.0 2.0.2 4.2.1 + 0.0.7 registry-client @@ -175,6 +176,11 @@ jboss-logging ${jboss-logging.version} + + org.codejive + java-properties + ${java-properties.version} + org.junit.jupiter junit-jupiter diff --git a/integration-tests/gradle/src/main/resources/compile-only-lombok/gradle.properties b/integration-tests/gradle/src/main/resources/compile-only-lombok/gradle.properties index cac35f5608ec1..542d9cf933db7 100644 --- a/integration-tests/gradle/src/main/resources/compile-only-lombok/gradle.properties +++ b/integration-tests/gradle/src/main/resources/compile-only-lombok/gradle.properties @@ -1,6 +1,6 @@ -#Gradle properties -#Tue Aug 04 17:04:55 CEST 2020 +# Gradle properties + quarkusPlatformArtifactId=quarkus-bom quarkusPlatformGroupId=io.quarkus org.gradle.logging.level=INFO -lombokVersion=1.18.12 \ No newline at end of file +lombokVersion=1.18.12 diff --git a/integration-tests/gradle/src/main/resources/multi-module-included-build/gradle.properties b/integration-tests/gradle/src/main/resources/multi-module-included-build/gradle.properties index a0bb7cd4da3b4..0b9b349582ac3 100644 --- a/integration-tests/gradle/src/main/resources/multi-module-included-build/gradle.properties +++ b/integration-tests/gradle/src/main/resources/multi-module-included-build/gradle.properties @@ -1,4 +1,4 @@ -#Gradle properties -#Tue Aug 25 06:41:36 GMT 2020 +# Gradle properties + quarkusPlatformArtifactId=quarkus-bom quarkusPlatformGroupId=io.quarkus diff --git a/integration-tests/gradle/src/main/resources/multi-module-kotlin-project/gradle.properties b/integration-tests/gradle/src/main/resources/multi-module-kotlin-project/gradle.properties index b8ff81712a497..d54b9c8a6b92b 100644 --- a/integration-tests/gradle/src/main/resources/multi-module-kotlin-project/gradle.properties +++ b/integration-tests/gradle/src/main/resources/multi-module-kotlin-project/gradle.properties @@ -1,5 +1,5 @@ -#Gradle properties -#Wed May 06 08:31:08 UTC 2020 +# Gradle properties + quarkusPlatformArtifactId=quarkus-bom quarkusPlatformGroupId=io.quarkus diff --git a/integration-tests/gradle/src/main/resources/multi-module-with-empty-module/gradle.properties b/integration-tests/gradle/src/main/resources/multi-module-with-empty-module/gradle.properties index e6b64c6a56957..0b9b349582ac3 100644 --- a/integration-tests/gradle/src/main/resources/multi-module-with-empty-module/gradle.properties +++ b/integration-tests/gradle/src/main/resources/multi-module-with-empty-module/gradle.properties @@ -1,3 +1,4 @@ -#Gradle properties +# Gradle properties + quarkusPlatformArtifactId=quarkus-bom -quarkusPlatformGroupId=io.quarkus \ No newline at end of file +quarkusPlatformGroupId=io.quarkus