Skip to content

Commit b2356e1

Browse files
authored
Merge pull request #107 from ADI10HERO/spotbug-fix-2
fix: gradle project type spotbug fixes
2 parents 9676a06 + 6a9ff64 commit b2356e1

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/main/java/io/jenkins/plugins/conventionalcommits/utils/GradleProjectType.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
import com.github.zafarkhaja.semver.Version;
44
import io.jenkins.plugins.conventionalcommits.process.ProcessHelper;
55
import java.io.BufferedReader;
6+
import java.io.BufferedWriter;
67
import java.io.File;
7-
import java.io.FileWriter;
88
import java.io.IOException;
9+
import java.nio.charset.StandardCharsets;
910
import java.nio.file.Files;
1011
import java.nio.file.Paths;
1112
import java.nio.file.StandardCopyOption;
1213
import java.util.Arrays;
1314
import java.util.List;
1415
import java.util.Objects;
1516

16-
/**
17-
* Represent a Gradle project type (i.e with a build.gradle file).
18-
*/
17+
/** Represent a Gradle project type (i.e with a build.gradle file). */
1918
public class GradleProjectType extends ProjectType {
2019

2120
public boolean check(File directory) {
@@ -50,13 +49,13 @@ public Version getCurrentVersion(File directory, ProcessHelper processHelper)
5049
}
5150

5251
/**
53-
* Write the new calculated version in the build.gradle file.
54-
* If no version property is found, do nothing.
52+
* Write the new calculated version in the build.gradle file. If no version property is found, do
53+
* nothing.
5554
*
56-
* @param directory The directory where find the build.gradle. <b>Mandatory</b>
57-
* @param nextVersion The next version to write. <b>Mandatory</b>
55+
* @param directory The directory where find the build.gradle. <b>Mandatory</b>
56+
* @param nextVersion The next version to write. <b>Mandatory</b>
5857
* @param processHelper Not used.
59-
* @throws IOException If an error occurs when accessing to the build.gradle
58+
* @throws java.io.IOException If an error occurs when accessing to the build.gradle
6059
* @throws InterruptedException Not used.
6160
*/
6261
@Override
@@ -77,7 +76,8 @@ public void writeVersion(File directory, Version nextVersion, ProcessHelper proc
7776
String.format("%s%sgradle.properties", directory.getAbsolutePath(), File.separator);
7877

7978
try (BufferedReader reader = Files.newBufferedReader(Paths.get(buildPath))) {
80-
try (FileWriter fw = new FileWriter(buildTempPath)) {
79+
try (BufferedWriter fw =
80+
Files.newBufferedWriter(Paths.get(buildTempPath), StandardCharsets.UTF_8)) {
8181
while ((line = reader.readLine()) != null) {
8282
if (line.contains("version")) {
8383
fw.write(String.format("version = %s%n", nextVersion));
@@ -91,8 +91,8 @@ public void writeVersion(File directory, Version nextVersion, ProcessHelper proc
9191

9292
if (isVersionTag) {
9393
// Replace gradle.properties with updated version
94-
Files.move(Paths.get(buildTempPath), Paths.get(buildPath),
95-
StandardCopyOption.REPLACE_EXISTING);
94+
Files.move(
95+
Paths.get(buildTempPath), Paths.get(buildPath), StandardCopyOption.REPLACE_EXISTING);
9696
} else {
9797
Files.deleteIfExists(Paths.get(buildPath));
9898
throw new IOException("Unable to get version in gradle.properties");

0 commit comments

Comments
 (0)