diff --git a/src/main/java/de/dentrassi/rpm/builder/RpmUnpackMojo.java b/src/main/java/de/dentrassi/rpm/builder/RpmUnpackMojo.java index a44cc8d..009a775 100644 --- a/src/main/java/de/dentrassi/rpm/builder/RpmUnpackMojo.java +++ b/src/main/java/de/dentrassi/rpm/builder/RpmUnpackMojo.java @@ -10,7 +10,6 @@ import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -171,15 +170,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { } try (final RpmInputStream in = - new RpmInputStream(new BufferedInputStream(new FileInputStream(this.rpmFile)))) { + new RpmInputStream(new BufferedInputStream(Files.newInputStream(this.rpmFile.toPath())))) { final InputHeader header = in.getPayloadHeader(); - header.getEntry(RpmTag.FILE_GROUPNAME); - header.getEntry(RpmTag.FILE_USERNAME); - final CpioArchiveInputStream cpio = in.getCpioStream(); CpioArchiveEntry entry; - while ((entry = cpio.getNextCPIOEntry()) != null) { + while ((entry = cpio.getNextEntry()) != null) { unpackEntry(header, cpio, entry, targetDir); } } catch (final IllegalArgumentException | IllegalStateException e) { diff --git a/src/main/java/de/dentrassi/rpm/builder/Script.java b/src/main/java/de/dentrassi/rpm/builder/Script.java index d5bcdd7..1f6d5e7 100644 --- a/src/main/java/de/dentrassi/rpm/builder/Script.java +++ b/src/main/java/de/dentrassi/rpm/builder/Script.java @@ -11,11 +11,11 @@ package de.dentrassi.rpm.builder; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import com.google.common.base.Strings; import com.google.common.io.CharStreams; @@ -61,7 +61,7 @@ public String makeScriptContent() throws IOException { } if (this.file != null) { - try (Reader reader = new InputStreamReader(new FileInputStream(this.file), StandardCharsets.UTF_8)) { + try (Reader reader = new InputStreamReader(Files.newInputStream(this.file.toPath()), StandardCharsets.UTF_8)) { return CharStreams.toString(reader); } } diff --git a/src/main/java/de/dentrassi/rpm/builder/SigningHelper.java b/src/main/java/de/dentrassi/rpm/builder/SigningHelper.java index 8202896..8700e33 100644 --- a/src/main/java/de/dentrassi/rpm/builder/SigningHelper.java +++ b/src/main/java/de/dentrassi/rpm/builder/SigningHelper.java @@ -10,9 +10,9 @@ *******************************************************************************/ package de.dentrassi.rpm.builder; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -46,7 +46,7 @@ public static PGPPrivateKey loadKey(final Signature signature, final Logger logg throw new MojoFailureException(signature, "'passphrase' parameter not set", "Signing requires the 'passphrase' parameter to be set."); } - try (InputStream input = new FileInputStream(signature.getKeyringFile())) { + try (InputStream input = Files.newInputStream(signature.getKeyringFile().toPath())) { final PGPPrivateKey privateKey = PgpHelper.loadPrivateKey(input, signature.getKeyId(), signature.getPassphrase()); if (privateKey == null) { throw new MojoFailureException(String.format("Unable to load GPG key '%s' from '%s'", signature.getKeyId(), signature.getKeyringFile())); diff --git a/src/main/java/de/dentrassi/rpm/builder/YumMojo.java b/src/main/java/de/dentrassi/rpm/builder/YumMojo.java index 91dade9..87dc527 100644 --- a/src/main/java/de/dentrassi/rpm/builder/YumMojo.java +++ b/src/main/java/de/dentrassi/rpm/builder/YumMojo.java @@ -191,7 +191,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } if (this.files != null) { - paths.addAll(this.files.stream().map(f -> f.toPath()).collect(Collectors.toList())); + paths.addAll(this.files.stream().map(File::toPath).collect(Collectors.toList())); } if (this.directories != null) { for (final File dir : this.directories) { @@ -245,7 +245,7 @@ private void addSinglePackage(final Path path, final Context context) throws IOE try (CpioArchiveInputStream cpio = ris.getCpioStream()) { CpioArchiveEntry cpioEntry; - while ((cpioEntry = cpio.getNextCPIOEntry()) != null) { + while ((cpioEntry = cpio.getNextEntry()) != null) { providedFiles.add(RpmInformations.normalize(cpioEntry.getName())); } }