Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {

getLog().info("[MAVEN-CORE-IT-LOG] Creating output file " + outputFile);

OutputStream out = null;
try {
outputFile.getParentFile().mkdirs();
out = new FileOutputStream(outputFile);
outputFile.getParentFile().mkdirs();
try (OutputStream out = new FileOutputStream(outputFile)) {
componentProperties.store(out, "MAVEN-CORE-IT-LOG");
} catch (IOException e) {
throw new MojoExecutionException("Output file could not be created: " + outputFile, e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// just ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 files 7 times dry - count check seems valid.

image
  • lucky number seven

}
}
throw new MojoExecutionException(e);
}

getLog().info("[MAVEN-CORE-IT-LOG] Created output file " + outputFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,11 @@ public void run() {

getLog().info("[MAVEN-CORE-IT-LOG] Creating output file " + outputFile);

OutputStream out = null;
try {
outputFile.getParentFile().mkdirs();
out = new FileOutputStream(outputFile);
outputFile.getParentFile().mkdirs();
try (OutputStream out = new FileOutputStream(outputFile)) {
componentProperties.store(out, "MAVEN-CORE-IT-LOG");
} catch (IOException e) {
throw new MojoExecutionException("Output file could not be created: " + outputFile, e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// just ignore
}
}
throw new MojoExecutionException(e);
}

getLog().info("[MAVEN-CORE-IT-LOG] Created output file " + outputFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package org.apache.maven.plugin.coreit;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.Properties;

import org.apache.maven.plugin.MojoExecutionException;
Expand All @@ -35,21 +35,11 @@
class PropertiesUtil {

public static void write(File outputFile, Properties props) throws MojoExecutionException {
OutputStream out = null;
try {
outputFile.getParentFile().mkdirs();
out = new FileOutputStream(outputFile);
outputFile.getParentFile().mkdirs();
try (OutputStream out = Files.newOutputStream(outputFile.toPath())) {
props.store(out, "MAVEN-CORE-IT-LOG");
} catch (IOException e) {
throw new MojoExecutionException("Output file could not be created: " + outputFile, e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// just ignore
}
}
throw new MojoExecutionException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,11 @@ public static Properties read(File inputFile) throws MojoExecutionException {
}

public static void write(File outputFile, Properties props) throws MojoExecutionException {
OutputStream os = null;
try {
outputFile.getParentFile().mkdirs();
os = new FileOutputStream(outputFile);
outputFile.getParentFile().mkdirs();
try (OutputStream os = new FileOutputStream(outputFile)) {
props.store(os, "MAVEN-CORE-IT-LOG");
} catch (IOException e) {
throw new MojoExecutionException(
"Output file " + outputFile + " could not be created: " + e.getMessage(), e);
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
// just ignore
}
}
throw new MojoExecutionException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {

getLog().info("[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile);

OutputStream out = null;
try {
outputFile.getParentFile().mkdirs();
out = new FileOutputStream(outputFile);
outputFile.getParentFile().mkdirs();
try (OutputStream out = new FileOutputStream(outputFile)) {
props.store(out, "MAVEN-CORE-IT-LOG");
} catch (IOException e) {
throw new MojoExecutionException("Output file could not be created: " + outputFile, e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// just ignore
}
}
throw new MojoExecutionException(e);
}

getLog().info("[MAVEN-CORE-IT-LOG] Created output file: " + outputFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,11 @@ public void execute() throws MojoExecutionException {
}
}

OutputStream out = null;
try {
outputFile.getParentFile().mkdirs();
out = new FileOutputStream(outputFile);
outputFile.getParentFile().mkdirs();
try (OutputStream out = new FileOutputStream(outputFile)) {
properties.store(out, "MAVEN-CORE-IT-LOG");
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// ignore
}
}
throw new MojoExecutionException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,11 @@ public void execute() throws MojoExecutionException {
}
}

OutputStream out = null;
try {
outputFile.getParentFile().mkdirs();
out = new FileOutputStream(outputFile);
outputFile.getParentFile().mkdirs();
try (OutputStream out = new FileOutputStream(outputFile)) {
properties.store(out, "MAVEN-CORE-IT-LOG");
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// ignore
}
}
throw new MojoExecutionException(e);
}
}
}