From c9d385e8580bc9adc8f0f49810e153787bc6c0df Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Sun, 21 Apr 2024 08:29:10 +0200 Subject: [PATCH] [MARTIFACT-62] Drop deprecated classes and artifacts (#31) * Drop deprecated classes * Fix merge issue * Declare deps if used --- .github/dependabot.yml | 30 ++++ .github/workflows/maven-verify.yml | 2 +- pgp-keys-map.list | 14 +- pom.xml | 48 +++++- .../buildinfo/AbstractBuildinfoMojo.java | 21 ++- .../artifact/buildinfo/BuildInfoWriter.java | 69 ++++----- .../artifact/buildinfo/BuildinfoMojo.java | 2 +- .../buildinfo/CheckBuildPlanMojo.java | 36 +++-- .../artifact/buildinfo/CompareMojo.java | 45 +++--- .../artifact/buildinfo/JdkToolchainUtil.java | 13 +- .../buildinfo/ReferenceBuildinfoUtil.java | 141 ++++++++---------- src/site/apt/plugin-issues.apt | 50 ++++--- ...tReproduciblePluginsDocumentationTest.java | 18 ++- 13 files changed, 273 insertions(+), 216 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..95c2b1a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,30 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +version: 2 +updates: + +- package-ecosystem: maven + directory: "/" + schedule: + interval: daily + time: '04:00' + open-pull-requests-limit: 10 + +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index bbd7786..932827c 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -24,4 +24,4 @@ on: jobs: build: name: Verify - uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v2 + uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 diff --git a/pgp-keys-map.list b/pgp-keys-map.list index 5e0a25e..a366867 100644 --- a/pgp-keys-map.list +++ b/pgp-keys-map.list @@ -15,15 +15,19 @@ # specific language governing permissions and limitations # under the License. -commons-codec:commons-codec = 0xBC87A3FD0A54480F0BADBEBD21939FF0CA2A6567 +com.github.luben:zstd-jni = 0x9AC5712CABE9635B65663AB0711C0A9A896FE336 +commons-codec:commons-codec = 0x2DB4F1EF0FA761ECC4EA935C86FDC7E2A11262CB commons-io:commons-io = 0x2DB4F1EF0FA761ECC4EA935C86FDC7E2A11262CB javax.inject:javax.inject = noSig +junit:junit = 0xFF6E2C001948C5F2F38B0CC385911F425EC61B51 org.apache.maven.* = 0xB920D295BF0E61CB4CF0896C33CD6733AF5EC452 -org.apache.maven:maven-archiver = 0x29BEA2A645F2D6CED7FB12E02B172E3E156466E8 +org.apache.maven:maven-archiver = 0x84789D24DF77A32433CE1F079EB80E92EB2135B1 +org.apache.maven.resolver = 0x29BEA2A645F2D6CED7FB12E02B172E3E156466E8 org.apache.maven.shared:maven-shared-utils = 0x84789D24DF77A32433CE1F079EB80E92EB2135B1 -org.codehaus.plexus:plexus-archiver = 0x29BEA2A645F2D6CED7FB12E02B172E3E156466E8 -org.codehaus.plexus:plexus-interpolation = 0x47063E8BA7A6450E4A52E7AE466CAED6E0747D50 -org.codehaus.plexus:plexus-io = 0xF254B35617DC255D9344BCFA873A8E86B4372146 +org.codehaus.plexus:plexus-archiver = 0x84789D24DF77A32433CE1F079EB80E92EB2135B1 +org.codehaus.plexus:plexus-interpolation = 0xF254B35617DC255D9344BCFA873A8E86B4372146 +org.codehaus.plexus:plexus-io = 0x09A808E1930F779CC6C54807E4C753D85335E876 org.codehaus.plexus:plexus-utils = 0xEA23DB1360D9029481E7F2EFECDFEA3CB4493B94 org.codehaus.plexus:plexus-xml = 0xFA77DCFEF2EE6EB2DEBEDD2C012579464D01C06A +org.hamcrest = 0xE3A9F95079E84CE201F7CF60BEDE11EAF1164480 org.slf4j:slf4j-api = 0x475F3B8E59E6E63AA78067482C7B12F2A511E325 diff --git a/pom.xml b/pom.xml index 8314fc9..9546bcf 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ Plugin to manage artifacts tasks - ${mavenVersion} + 3.2.5 @@ -60,7 +60,8 @@ - 3.2.5 + 3.9.6 + 1.9.18 8 2024-03-29T06:57:38Z @@ -91,16 +92,24 @@ provided - org.eclipse.aether - aether-api - 1.0.0.v20140518 + org.apache.maven.resolver + maven-resolver-api + ${resolverVersion} provided + + + org.apache.maven.resolver + maven-resolver-util + ${resolverVersion} + compile + org.codehaus.plexus plexus-xml 3.0.0 + org.apache.maven.shared maven-shared-utils @@ -109,7 +118,7 @@ org.apache.maven maven-archiver - 3.6.0 + 3.6.1 org.tukaani @@ -128,18 +137,43 @@ commons-codec commons-codec - 1.15 + 1.16.1 + + + commons-io + commons-io + 2.15.1 org.apache.maven.plugin-tools maven-plugin-annotations provided + + org.hamcrest + hamcrest-core + 2.2 + test + + + junit + junit + 4.13.2 + test + + + org.apache.maven.plugins + maven-compiler-plugin + + none + true + + org.simplify4u.plugins pgpverify-maven-plugin diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java index ba669a6..1c6a8ac 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java @@ -26,14 +26,12 @@ import java.nio.charset.StandardCharsets; import java.nio.file.*; import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.Instant; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import org.apache.maven.archiver.MavenArchiver; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -42,9 +40,9 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.rtinfo.RuntimeInformation; -import org.apache.maven.shared.utils.io.FileUtils; import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.ToolchainManager; +import org.eclipse.aether.artifact.Artifact; /** * Base buildinfo-generating class, for goals related to Reproducible Builds {@code .buildinfo} files. @@ -126,9 +124,6 @@ public abstract class AbstractBuildinfoMojo extends AbstractMojo { @Component private ToolchainManager toolchainManager; - @Component - protected ArtifactHandlerManager artifactHandlerManager; - @Component protected RuntimeInformation rtInformation; @@ -163,8 +158,8 @@ public void execute() throws MojoExecutionException { static boolean hasBadOutputTimestamp( String outputTimestamp, Log log, MavenProject project, List reactorProjects) { - MavenArchiver archiver = new MavenArchiver(); - Date timestamp = archiver.parseOutputTimestamp(outputTimestamp); + Instant timestamp = + MavenArchiver.parseBuildOutputTimestamp(outputTimestamp).orElse(null); if (timestamp == null) { log.error("Reproducible Build not activated by project.build.outputTimestamp property: " + "see https://maven.apache.org/guides/mini/guide-reproducible-builds.html"); @@ -218,7 +213,11 @@ protected void copyAggregateToRoot(File aggregate) throws MojoExecutionException File rootCopy = new File(root.getBuild().getDirectory(), root.getArtifactId() + '-' + root.getVersion() + extension); try { - FileUtils.copyFile(aggregate, rootCopy); + Files.copy( + aggregate.toPath(), + rootCopy.toPath(), + LinkOption.NOFOLLOW_LINKS, + StandardCopyOption.REPLACE_EXISTING); getLog().info("Aggregate " + extension.substring(1) + " copied to " + rootCopy); } catch (IOException ioe) { throw new MojoExecutionException("Could not copy " + aggregate + " to " + rootCopy, ioe); @@ -240,7 +239,7 @@ protected Map generateBuildinfo(boolean mono) throws MojoExecu try (PrintWriter p = new PrintWriter(new BufferedWriter( new OutputStreamWriter(Files.newOutputStream(buildinfoFile.toPath()), StandardCharsets.UTF_8)))) { - BuildInfoWriter bi = new BuildInfoWriter(getLog(), p, mono, artifactHandlerManager, rtInformation); + BuildInfoWriter bi = new BuildInfoWriter(getLog(), p, mono, rtInformation); bi.setIgnoreJavadoc(ignoreJavadoc); bi.setIgnore(ignore); bi.setToolchain(getToolchain()); diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java index 42d1dd2..b3333fe 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java @@ -27,17 +27,15 @@ import java.util.stream.Collectors; import org.apache.commons.codec.digest.DigestUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.RepositoryUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.rtinfo.RuntimeInformation; -import org.apache.maven.shared.utils.PropertyUtils; -import org.apache.maven.shared.utils.StringUtils; import org.apache.maven.toolchain.Toolchain; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.util.artifact.ArtifactIdUtils; /** * Buildinfo content writer. @@ -46,7 +44,6 @@ class BuildInfoWriter { private final Log log; private final PrintWriter p; private final boolean mono; - private final ArtifactHandlerManager artifactHandlerManager; private final RuntimeInformation rtInformation; private final Map artifacts = new LinkedHashMap<>(); private int projectCount = -1; @@ -54,16 +51,10 @@ class BuildInfoWriter { private List ignore; private Toolchain toolchain; - BuildInfoWriter( - Log log, - PrintWriter p, - boolean mono, - ArtifactHandlerManager artifactHandlerManager, - RuntimeInformation rtInformation) { + BuildInfoWriter(Log log, PrintWriter p, boolean mono, RuntimeInformation rtInformation) { this.log = log; this.p = p; this.mono = mono; - this.artifactHandlerManager = artifactHandlerManager; this.rtInformation = rtInformation; } @@ -162,32 +153,26 @@ void printArtifacts(MavenProject project) throws MojoExecutionException { } // detect Maven 4 consumer POM transient attachment - Artifact consumerPom = project.getAttachedArtifacts().stream() - .filter(a -> "pom".equals(a.getType()) && "consumer".equals(a.getClassifier())) + Artifact consumerPom = RepositoryUtils.toArtifacts(project.getAttachedArtifacts()).stream() + .filter(a -> "pom".equals(a.getExtension()) && "consumer".equals(a.getClassifier())) .findAny() .orElse(null); int n = 0; - Artifact pomArtifact = new DefaultArtifact( - project.getGroupId(), - project.getArtifactId(), - project.getVersion(), - null, - "pom", - "", - artifactHandlerManager.getArtifactHandler("pom")); + Artifact pomArtifact = + new DefaultArtifact(project.getGroupId(), project.getArtifactId(), null, "pom", project.getVersion()); if (consumerPom != null) { // Maven 4 transient consumer POM attachment is published as the POM, overrides build POM, see // https://github.com/apache/maven/blob/c79a7a02721f0f9fd7e202e99f60b593461ba8cc/maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java#L130-L155 try { Path pomFile = Files.createTempFile(Paths.get(project.getBuild().getDirectory()), "consumer-", ".pom"); Files.copy(consumerPom.getFile().toPath(), pomFile, StandardCopyOption.REPLACE_EXISTING); - pomArtifact.setFile(pomFile.toFile()); + pomArtifact = pomArtifact.setFile(pomFile.toFile()); } catch (IOException e) { p.println("Error processing consumer POM: " + e); } } else { - pomArtifact.setFile(project.getFile()); + pomArtifact = pomArtifact.setFile(project.getFile()); } artifacts.put(pomArtifact, prefix + n); @@ -202,15 +187,15 @@ void printArtifacts(MavenProject project) throws MojoExecutionException { } if (project.getArtifact().getFile() != null) { - printArtifact(prefix, n++, project.getArtifact()); + printArtifact(prefix, n++, RepositoryUtils.toArtifact(project.getArtifact())); } - for (Artifact attached : project.getAttachedArtifacts()) { + for (Artifact attached : RepositoryUtils.toArtifacts(project.getAttachedArtifacts())) { if (attached == consumerPom) { // ignore consumer pom continue; } - if (attached.getType().endsWith(".asc")) { + if (attached.getExtension().endsWith(".asc")) { // ignore pgp signatures continue; } @@ -231,17 +216,18 @@ private void printArtifact(String prefix, int i, Artifact artifact) throws MojoE prefix = prefix + i; File artifactFile = artifact.getFile(); if (artifactFile.isDirectory()) { - if ("pom".equals(artifact.getType())) { + if ("pom".equals(artifact.getExtension())) { // ignore .pom files: they should not be treated as Artifacts return; } // edge case found in a distribution module with default packaging and skip set for // m-jar-p: should use pom packaging instead - throw new MojoExecutionException("Artifact " + artifact.getId() + " points to a directory: " + artifactFile - + ". Packaging should be 'pom'?"); + throw new MojoExecutionException("Artifact " + ArtifactIdUtils.toId(artifact) + " points to a directory: " + + artifactFile + ". Packaging should be 'pom'?"); } if (!artifactFile.isFile()) { - log.warn("Ignoring artifact " + artifact.getId() + " because it points to inexistent " + artifactFile); + log.warn("Ignoring artifact " + ArtifactIdUtils.toId(artifact) + " because it points to inexistent " + + artifactFile); return; } @@ -254,14 +240,12 @@ static String getArtifactFilename(Artifact artifact) { path.append(artifact.getArtifactId()).append('-').append(artifact.getBaseVersion()); - if (artifact.hasClassifier()) { + if (!artifact.getClassifier().isEmpty()) { path.append('-').append(artifact.getClassifier()); } - ArtifactHandler artifactHandler = artifact.getArtifactHandler(); - - if (StringUtils.isNotEmpty(artifactHandler.getExtension())) { - path.append('.').append(artifactHandler.getExtension()); + if (!artifact.getExtension().isEmpty()) { + path.append('.').append(artifact.getExtension()); } return path.toString(); @@ -297,7 +281,14 @@ Map getArtifacts() { * @throws MojoExecutionException */ static Properties loadOutputProperties(File buildinfo) throws MojoExecutionException { - Properties prop = PropertyUtils.loadOptionalProperties(buildinfo); + Properties prop = new Properties(); + if (buildinfo != null) { + try (InputStream is = Files.newInputStream(buildinfo.toPath())) { + prop.load(is); + } catch (IOException e) { + // silent + } + } for (String name : prop.stringPropertyNames()) { if (!name.startsWith("outputs.") || name.endsWith(".coordinates")) { prop.remove(name); diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java index 77c6de0..f5a7db3 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java @@ -20,13 +20,13 @@ import java.util.Map; -import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectHelper; +import org.eclipse.aether.artifact.Artifact; /** * Creates a buildinfo file recording build environment and output (from {@code package}), as specified in diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CheckBuildPlanMojo.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CheckBuildPlanMojo.java index 2263474..7a6e00f 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CheckBuildPlanMojo.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CheckBuildPlanMojo.java @@ -27,8 +27,6 @@ import java.util.Properties; import java.util.Set; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleExecutor; import org.apache.maven.lifecycle.MavenExecutionPlan; @@ -40,6 +38,10 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.eclipse.aether.util.version.GenericVersionScheme; +import org.eclipse.aether.version.InvalidVersionSpecificationException; +import org.eclipse.aether.version.Version; +import org.eclipse.aether.version.VersionScheme; /** * Check from buildplan that plugins used don't have known Reproducible Builds issues. @@ -81,6 +83,8 @@ public class CheckBuildPlanMojo extends AbstractMojo { @Parameter(property = "check.failOnNonReproducible", defaultValue = "true") private boolean failOnNonReproducible; + private final VersionScheme versionScheme = new GenericVersionScheme(); + protected MavenExecutionPlan calculateExecutionPlan() throws MojoExecutionException { try { return lifecycleExecutor.calculateExecutionPlan(session, tasks); @@ -120,21 +124,25 @@ public void execute() throws MojoExecutionException { getLog().warn(logMessage); } fail = true; - } else { - ArtifactVersion minimum = new DefaultArtifactVersion(issue); - ArtifactVersion version = new DefaultArtifactVersion(plugin.getVersion()); - if (version.compareTo(minimum) < 0) { - String logMessage = "plugin with non-reproducible output: " + id + ", require minimum " + issue; - if (failOnNonReproducible) { - getLog().error(logMessage); + try { + Version minimum = versionScheme.parseVersion(issue); + Version version = versionScheme.parseVersion(plugin.getVersion()); + if (version.compareTo(minimum) < 0) { + String logMessage = + "plugin with non-reproducible output: " + id + ", require minimum " + issue; + if (failOnNonReproducible) { + getLog().error(logMessage); + } else { + getLog().warn(logMessage); + } + fail = true; } else { - getLog().warn(logMessage); + okCount++; + getLog().debug("No known issue with " + id + " (>= " + issue + ")"); } - fail = true; - } else { - okCount++; - getLog().debug("No known issue with " + id + " (>= " + issue + ")"); + } catch (InvalidVersionSpecificationException e) { + throw new MojoExecutionException(e); } } } diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojo.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojo.java index c6d913e..a37eb56 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojo.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojo.java @@ -21,6 +21,7 @@ import java.io.BufferedWriter; import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; @@ -30,20 +31,17 @@ import java.util.Map; import java.util.Properties; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.utils.PropertyUtils; -import org.apache.maven.shared.utils.StringUtils; import org.apache.maven.shared.utils.logging.MessageUtils; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.util.artifact.ArtifactIdUtils; import static org.apache.maven.plugins.artifact.buildinfo.BuildInfoWriter.getArtifactFilename; @@ -76,9 +74,6 @@ public class CompareMojo extends AbstractBuildinfoMojo { @Parameter(property = "compare.aggregate.only", defaultValue = "false") private boolean aggregateOnly; - @Component - private ArtifactFactory artifactFactory; - /** * The entry point to Maven Artifact Resolver, i.e. the component doing all the work. */ @@ -104,9 +99,6 @@ public class CompareMojo extends AbstractBuildinfoMojo { @Parameter(property = "compare.fail", defaultValue = "true") private boolean fail; - @Component - private ArtifactRepositoryLayout artifactRepositoryLayout; - @Override public void execute(Map artifacts) throws MojoExecutionException { getLog().info("Checking against reference build from " + referenceRepo + "..."); @@ -146,15 +138,8 @@ private File downloadOrCreateReferenceBuildinfo(boolean mono, Map artifacts, File referenc p.println("ok=" + ok); p.println("ko=" + ko); p.println("ignored=" + ignored.size()); - p.println("okFiles=\"" + StringUtils.join(okFilenames.iterator(), " ") + '"'); - p.println("koFiles=\"" + StringUtils.join(koFilenames.iterator(), " ") + '"'); - p.println("ignoredFiles=\"" + StringUtils.join(ignored.iterator(), " ") + '"'); - Properties ref = PropertyUtils.loadOptionalProperties(referenceBuildinfo); + p.println("okFiles=\"" + String.join(" ", okFilenames) + '"'); + p.println("koFiles=\"" + String.join(" ", koFilenames) + '"'); + p.println("ignoredFiles=\"" + String.join(" ", ignored) + '"'); + Properties ref = new Properties(); + if (referenceBuildinfo != null) { + try (InputStream in = Files.newInputStream(referenceBuildinfo.toPath())) { + ref.load(in); + } catch (IOException e) { + // nothing + } + } String v = ref.getProperty("java.version"); if (v != null) { p.println("reference_java_version=\"" + v + '"'); @@ -283,13 +275,14 @@ private String diffoscope(Artifact a, File referenceDir) { // reference file name is taken from repository format File reference = new File(new File(referenceDir, a.getGroupId()), getRepositoryFilename(a)); if (actual == null) { - return "missing file for " + a.getId() + " reference = " + relative(reference) + " actual = null"; + return "missing file for " + ArtifactIdUtils.toId(a) + " reference = " + relative(reference) + + " actual = null"; } return "diffoscope " + relative(reference) + " " + relative(actual); } private String getRepositoryFilename(Artifact a) { - String path = artifactRepositoryLayout.pathOf(a); + String path = session.getRepositorySession().getLocalRepositoryManager().getPathForLocalArtifact(a); return path.substring(path.lastIndexOf('/')); } diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/JdkToolchainUtil.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/JdkToolchainUtil.java index c6a044f..b12c6ca 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/JdkToolchainUtil.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/JdkToolchainUtil.java @@ -22,12 +22,11 @@ import java.util.ArrayList; import java.util.List; -import org.apache.maven.shared.utils.StringUtils; -import org.apache.maven.shared.utils.cli.CommandLineException; -import org.apache.maven.shared.utils.cli.CommandLineUtils; -import org.apache.maven.shared.utils.cli.Commandline; -import org.apache.maven.shared.utils.cli.StreamConsumer; import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.codehaus.plexus.util.cli.StreamConsumer; /** * A helper to get JDK version from a JDK toolchain. @@ -42,8 +41,8 @@ static String getJavaVersion(Toolchain toolchain) { LineConsumer out = new LineConsumer(); LineConsumer err = new LineConsumer(); CommandLineUtils.executeCommandLine(cl, out, err); - version = StringUtils.join(err.getLines().iterator(), ":"); - if (StringUtils.isEmpty(version)) { + version = String.join(":", err.getLines()); + if (version == null || version.trim().isEmpty()) { version = "unable to detect..."; } } catch (CommandLineException cle) { diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReferenceBuildinfoUtil.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReferenceBuildinfoUtil.java index d14184c..e7892a0 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReferenceBuildinfoUtil.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReferenceBuildinfoUtil.java @@ -26,6 +26,8 @@ import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.StandardCopyOption; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -36,23 +38,21 @@ import java.util.jar.Manifest; import java.util.zip.ZipEntry; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; +import org.apache.commons.io.IOUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.rtinfo.RuntimeInformation; -import org.apache.maven.shared.utils.io.FileUtils; -import org.apache.maven.shared.utils.io.IOUtil; import org.eclipse.aether.AbstractForwardingRepositorySystemSession; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.ArtifactProperties; import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.ArtifactResult; /** @@ -81,32 +81,24 @@ class ReferenceBuildinfoUtil { private final Map artifacts; - private final ArtifactFactory artifactFactory; - private final RepositorySystem repoSystem; private final RepositorySystemSession repoSession; - private final ArtifactHandlerManager artifactHandlerManager; - private final RuntimeInformation rtInformation; ReferenceBuildinfoUtil( Log log, File referenceDir, Map artifacts, - ArtifactFactory artifactFactory, RepositorySystem repoSystem, RepositorySystemSession repoSession, - ArtifactHandlerManager artifactHandlerManager, RuntimeInformation rtInformation) { this.log = log; this.referenceDir = referenceDir; this.artifacts = artifacts; - this.artifactFactory = artifactFactory; this.repoSystem = repoSystem; this.repoSession = repoSession; - this.artifactHandlerManager = artifactHandlerManager; this.rtInformation = rtInformation; } @@ -135,7 +127,7 @@ File downloadOrCreateReferenceBuildinfo( referenceArtifacts.put(artifact, file); // guess Java version and OS - if ((javaVersion == null) && JAR_TYPES.contains(artifact.getType())) { + if ((javaVersion == null) && JAR_TYPES.contains(artifact.getProperty(ArtifactProperties.TYPE, "jar"))) { ReproducibleEnv env = extractEnv(file, artifact); if ((env != null) && (env.javaVersion != null)) { javaVersion = env.javaVersion; @@ -146,61 +138,63 @@ File downloadOrCreateReferenceBuildinfo( currentOsName = currentEnv.osName; } } - } catch (ArtifactNotFoundException e) { + } catch (ArtifactResolutionException e) { log.warn("Reference artifact not found " + artifact); } } - // generate buildinfo from reference artifacts - referenceBuildinfo = getReference(null, buildinfoFile); - try (PrintWriter p = new PrintWriter(new BufferedWriter( - new OutputStreamWriter(Files.newOutputStream(referenceBuildinfo.toPath()), StandardCharsets.UTF_8)))) { - BuildInfoWriter bi = new BuildInfoWriter(log, p, mono, artifactHandlerManager, rtInformation); - - if (javaVersion != null || osName != null) { - p.println("# effective build environment information"); - if (javaVersion != null) { - p.println("java.version=" + javaVersion); - log.info("Reference build java.version: " + javaVersion); - if (!javaVersion.equals(currentJavaVersion)) { - log.error("Current build java.version: " + currentJavaVersion); + try { + // generate buildinfo from reference artifacts + referenceBuildinfo = getReference(null, buildinfoFile); + try (PrintWriter p = new PrintWriter(new BufferedWriter(new OutputStreamWriter( + Files.newOutputStream(referenceBuildinfo.toPath()), StandardCharsets.UTF_8)))) { + BuildInfoWriter bi = new BuildInfoWriter(log, p, mono, rtInformation); + + if (javaVersion != null || osName != null) { + p.println("# effective build environment information"); + if (javaVersion != null) { + p.println("java.version=" + javaVersion); + log.info("Reference build java.version: " + javaVersion); + if (!javaVersion.equals(currentJavaVersion)) { + log.error("Current build java.version: " + currentJavaVersion); + } } - } - if (osName != null) { - p.println("os.name=" + osName); - log.info("Reference build os.name: " + osName); + if (osName != null) { + p.println("os.name=" + osName); + log.info("Reference build os.name: " + osName); - // check against current line separator - if (!osName.equals(currentOsName)) { - log.error("Current build os.name: " + currentOsName); - } - String expectedLs = osName.startsWith("Windows") ? "\r\n" : "\n"; - if (!expectedLs.equals(System.lineSeparator())) { - log.warn("Current System.lineSeparator() does not match reference build OS"); - - String ls = System.getProperty("line.separator"); - if (!ls.equals(System.lineSeparator())) { - log.warn("System.lineSeparator() != System.getProperty( \"line.separator\" ): " - + "too late standard system property update..."); + // check against current line separator + if (!osName.equals(currentOsName)) { + log.error("Current build os.name: " + currentOsName); + } + String expectedLs = osName.startsWith("Windows") ? "\r\n" : "\n"; + if (!expectedLs.equals(System.lineSeparator())) { + log.warn("Current System.lineSeparator() does not match reference build OS"); + + String ls = System.getProperty("line.separator"); + if (!ls.equals(System.lineSeparator())) { + log.warn("System.lineSeparator() != System.getProperty( \"line.separator\" ): " + + "too late standard system property update..."); + } } } } - } - for (Map.Entry entry : artifacts.entrySet()) { - Artifact artifact = entry.getKey(); - String prefix = entry.getValue(); - File referenceFile = referenceArtifacts.get(artifact); - if (referenceFile != null) { - bi.printFile(prefix, artifact.getGroupId(), referenceFile); + for (Map.Entry entry : artifacts.entrySet()) { + Artifact artifact = entry.getKey(); + String prefix = entry.getValue(); + File referenceFile = referenceArtifacts.get(artifact); + if (referenceFile != null) { + bi.printFile(prefix, artifact.getGroupId(), referenceFile); + } } - } - if (p.checkError()) { - throw new MojoExecutionException("Write error to " + referenceBuildinfo); - } + if (p.checkError()) { + throw new MojoExecutionException("Write error to " + referenceBuildinfo); + } - log.info("Minimal buildinfo generated from downloaded artifacts: " + referenceBuildinfo); + log.info("Minimal buildinfo generated from downloaded artifacts: " + referenceBuildinfo); + } } catch (IOException e) { throw new MojoExecutionException("Error creating file " + referenceBuildinfo, e); } @@ -248,7 +242,7 @@ private String extractOsName(Artifact a, JarFile jar) { return null; } try (InputStream in = jar.getInputStream(zipEntry)) { - String content = IOUtil.toString(in, StandardCharsets.UTF_8.name()); + String content = IOUtils.toString(in, StandardCharsets.UTF_8); log.debug("Manifest content: " + content); if (content.contains("\r\n")) { return "Windows (from pom.properties newline)"; @@ -262,15 +256,15 @@ private String extractOsName(Artifact a, JarFile jar) { } private File downloadReferenceBuildinfo(RemoteRepository repo, MavenProject project) throws MojoExecutionException { - Artifact buildinfo = artifactFactory.createArtifactWithClassifier( - project.getGroupId(), project.getArtifactId(), project.getVersion(), "buildinfo", ""); + Artifact buildinfo = new DefaultArtifact( + project.getGroupId(), project.getArtifactId(), null, "buildinfo", project.getVersion()); try { File file = downloadReference(repo, buildinfo); log.info("Reference buildinfo file found, copied to " + file); return file; - } catch (ArtifactNotFoundException e) { + } catch (ArtifactResolutionException e) { log.info("Reference buildinfo file not found: " + "it will be generated from downloaded reference artifacts"); } @@ -279,17 +273,10 @@ private File downloadReferenceBuildinfo(RemoteRepository repo, MavenProject proj } private File downloadReference(RemoteRepository repo, Artifact artifact) - throws MojoExecutionException, ArtifactNotFoundException { + throws MojoExecutionException, ArtifactResolutionException { try { ArtifactRequest request = new ArtifactRequest(); - request.setArtifact(new DefaultArtifact( - artifact.getGroupId(), - artifact.getArtifactId(), - artifact.getClassifier(), - (artifact.getArtifactHandler() != null) - ? artifact.getArtifactHandler().getExtension() - : artifact.getType(), - artifact.getVersion())); + request.setArtifact(artifact); request.setRepositories(Collections.singletonList(repo)); ArtifactResult result = @@ -297,12 +284,16 @@ private File downloadReference(RemoteRepository repo, Artifact artifact) File resultFile = result.getArtifact().getFile(); File destFile = getReference(artifact.getGroupId(), resultFile); - FileUtils.copyFile(resultFile, destFile); + Files.copy( + resultFile.toPath(), + destFile.toPath(), + LinkOption.NOFOLLOW_LINKS, + StandardCopyOption.REPLACE_EXISTING); return destFile; - } catch (org.eclipse.aether.resolution.ArtifactResolutionException are) { + } catch (ArtifactResolutionException are) { if (are.getResult().isMissing()) { - throw new ArtifactNotFoundException("Artifact not found " + artifact, artifact); + throw are; } throw new MojoExecutionException("Error resolving reference artifact " + artifact, are); } catch (IOException ioe) { @@ -310,14 +301,14 @@ private File downloadReference(RemoteRepository repo, Artifact artifact) } } - private File getReference(String groupId, File file) { + private File getReference(String groupId, File file) throws IOException { File dir; if (groupId == null) { dir = referenceDir; } else { dir = new File(referenceDir, groupId); if (!dir.isDirectory()) { - dir.mkdir(); + Files.createDirectories(dir.toPath()); } } return new File(dir, file.getName()); diff --git a/src/site/apt/plugin-issues.apt b/src/site/apt/plugin-issues.apt index daccf6b..a2d9339 100644 --- a/src/site/apt/plugin-issues.apt +++ b/src/site/apt/plugin-issues.apt @@ -34,57 +34,59 @@ Usage *---------+-------------------------------------------------------------------+-------+--------------+ | | <> | <> | <> *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-archetype-plugin/}maven-archetype-plugin}} | 3.2.0 | +| org.apache.maven.plugins | {{{/plugins/maven-archetype-plugin/}maven-archetype-plugin}} | 3.2.0 | https://issues.apache.org/jira/browse/ARCHETYPE-590 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-assembly-plugin/}maven-assembly-plugin}} | 3.2.0 | +| org.apache.maven.plugins | {{{/plugins/maven-assembly-plugin/}maven-assembly-plugin}} | 3.2.0 | https://issues.apache.org/jira/browse/MASSEMBLY-921 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-jar-plugin/}maven-jar-plugin}} | 3.2.0 | +| org.apache.maven.plugins | {{{/plugins/maven-jar-plugin/}maven-jar-plugin}} | 3.2.0 | https://issues.apache.org/jira/browse/MJAR-263 https://issues.apache.org/jira/browse/MJAR-275 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-ejb-plugin/}maven-ejb-plugin}} | 3.1.0 | +| org.apache.maven.plugins | {{{/plugins/maven-ejb-plugin/}maven-ejb-plugin}} | 3.1.0 | https://issues.apache.org/jira/browse/MEJB-128 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-plugin-plugin/}maven-plugin-plugin}} | 3.5.1 | +| org.apache.maven.plugins | {{{/plugins/maven-plugin-plugin/}maven-plugin-plugin}} | 3.5.1 | https://issues.apache.org/jira/browse/MPLUGIN-326 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-remote-resources-plugin/}maven-remote-resources-plugin}} | 1.7.0 | +| org.apache.maven.plugins | {{{/plugins/maven-remote-resources-plugin/}maven-remote-resources-plugin}} | 1.7.0 | https://issues.apache.org/jira/browse/MRRESOURCES-114 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-shade-plugin/}maven-shade-plugin}} | 3.2.3 | +| org.apache.maven.plugins | {{{/plugins/maven-shade-plugin/}maven-shade-plugin}} | 3.5.2 | https://issues.apache.org/jira/browse/MSHADE-352 https://issues.apache.org/jira/browse/MSHADE-420 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-source-plugin/}maven-source-plugin}} | 3.2.1 | +| org.apache.maven.plugins | {{{/plugins/maven-source-plugin/}maven-source-plugin}} | 3.2.1 | https://issues.apache.org/jira/browse/MSOURCES-123 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-war-plugin/}maven-war-plugin}} | 3.3.1 | +| org.apache.maven.plugins | {{{/plugins/maven-war-plugin/}maven-war-plugin}} | 3.3.1 | https://issues.apache.org/jira/browse/MWAR-432 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-ear-plugin/}maven-ear-plugin}} | 3.1.0 | +| org.apache.maven.plugins | {{{/plugins/maven-ear-plugin/}maven-ear-plugin}} | 3.1.0 | https://issues.apache.org/jira/browse/MEAR-280 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-rar-plugin/}maven-rar-plugin}} | 3.0.0 | +| org.apache.maven.plugins | {{{/plugins/maven-rar-plugin/}maven-rar-plugin}} | 3.0.0 | https://issues.apache.org/jira/browse/MRAR-86 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.maven.plugins | {{{/plugins/maven-acr-plugin/}maven-acr-plugin}} | 3.2.0 | +| org.apache.maven.plugins | {{{/plugins/maven-acr-plugin/}maven-acr-plugin}} | 3.2.0 | https://issues.apache.org/jira/browse/MACR-53 plugin-specific groupId +*--------+--------------------------------------------------------------------+-------+--------------+ +| io.quarkus | quarkus-extension-maven-plugin | 3.9.0 | https://github.com/quarkusio/quarkus/issues/38364 *--------+--------------------------------------------------------------------+-------+--------------+ | org.antlr | antlr3-maven-plugin | - | no fixed release available, see {{{https://github.com/antlr/antlr3/pull/209}reference}} *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.felix | maven-bundle-plugin | 5.1.9 | +| org.apache.felix | maven-bundle-plugin | 5.1.9 | https://issues.apache.org/jira/browse/FELIX-6495 https://issues.apache.org/jira/browse/FELIX-6496 https://issues.apache.org/jira/browse/FELIX-6602 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.karaf.tooling | karaf-maven-plugin | 4.3.7 | +| org.apache.karaf.tooling | karaf-maven-plugin | 4.3.7 | https://issues.apache.org/jira/browse/KARAF-7367 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.nifi | nifi-nar-maven-plugin | 1.3.4 | +| org.apache.nifi | nifi-nar-maven-plugin | 1.3.4 | https://issues.apache.org/jira/browse/NIFI-9857 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.apache.servicemix.tooling | depends-maven-plugin | 1.5.0 | +| org.apache.servicemix.tooling | depends-maven-plugin | 1.5.0 | https://issues.apache.org/jira/browse/SM-5021 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.codehaus.plexus | plexus-component-metadata | 2.1.0 | +| org.codehaus.plexus | plexus-component-metadata | 2.1.0 | https://github.com/codehaus-plexus/plexus-containers/issues/27 don't fail on one plugin for jaxb because plugin can be configured to avoid issue https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/doc/BUILDSPEC.md#avoiding-timestamps-in-jaxb-generated-content and other non-listed plugins using jaxb/xjc have same issues: failing at check-buildplan level just cause noise to usersorg.codehaus.mojo+jaxb2-maven-plugin=fail:https://github.com/mojohaus/jaxb2-maven-plugin *--------+--------------------------------------------------------------------+-------+--------------+ -| org.codehaus.mojo | jaxb2-maven-plugin | - | no fixed release available, see {{{https://github.com/mojohaus/jaxb2-maven-plugin}reference}} +| org.codehaus.mojo | properties-maven-plugin | 1.1.0 | https://github.com/mojohaus/properties-maven-plugin/pull/75org.codehaus.mojo+flatten-maven-plugin=fail:https://github.com/mojohaus/flatten-maven-plugin/issues/256 no issue in flatten-maven-plugin: t's a question of choice of Maven version: with 3.8.2+, it writes groupId then artifactId, with 3.8.1- it writes artifactId then groupId *--------+--------------------------------------------------------------------+-------+--------------+ -| org.codehaus.mojo | properties-maven-plugin | 1.1.0 | +| org.cyclonedx | cyclonedx-maven-plugin | 2.7.9 | https://github.com/CycloneDX/cyclonedx-maven-plugin/pull/353 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.eclipse.sisu | sisu-maven-plugin | 0.3.4 | +| org.eclipse.sisu | sisu-maven-plugin | 0.3.4 | https://github.com/eclipse/sisu.inject/pull/5 *--------+--------------------------------------------------------------------+-------+--------------+ | org.eclipse.jetty | jetty-jspc-maven-plugin | - | no fixed release available, see {{{https://github.com/eclipse/jetty.project/}reference}} *--------+--------------------------------------------------------------------+-------+--------------+ -| org.glassfish.hk2 | hk2-inhabitant-generator | 3.0.5 | +| org.glassfish.hk2 | hk2-inhabitant-generator | 3.0.5 | https://github.com/eclipse-ee4j/glassfish-hk2/pull/821 *--------+--------------------------------------------------------------------+-------+--------------+ | org.jboss.jandex | jandex-maven-plugin | - | no fixed release available, see {{{https://github.com/wildfly/jandex-maven-plugin/pull/35}reference}} *--------+--------------------------------------------------------------------+-------+--------------+ -| org.moditect | moditect-maven-plugin | 1.1.0 | +| org.moditect | moditect-maven-plugin | 1.2.0.Final | https://github.com/moditect/moditect/pull/211 https://github.com/moditect/moditect/pull/189 https://github.com/moditect/moditect/pull/222 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.springframework.boot | spring-boot-maven-plugin | 2.7.1 | +| org.springframework.boot | spring-boot-maven-plugin | 2.7.1 | https://github.com/spring-projects/spring-boot/issues/21005 *--------+--------------------------------------------------------------------+-------+--------------+ -| org.vafer | jdeb | 1.10 | +| org.vafer | jdeb | 1.10 | https://github.com/tcurdt/jdeb/pull/363 *----------+------------------------------------------------------------------+-------+--------------+ diff --git a/src/test/java/org/apache/maven/plugins/artifact/buildinfo/NotReproduciblePluginsDocumentationTest.java b/src/test/java/org/apache/maven/plugins/artifact/buildinfo/NotReproduciblePluginsDocumentationTest.java index 9c43e2a..62c5019 100644 --- a/src/test/java/org/apache/maven/plugins/artifact/buildinfo/NotReproduciblePluginsDocumentationTest.java +++ b/src/test/java/org/apache/maven/plugins/artifact/buildinfo/NotReproduciblePluginsDocumentationTest.java @@ -20,8 +20,10 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; -import org.apache.maven.shared.utils.io.FileUtils; +import org.junit.Test; /** * Test class to update src/site/apt/plugin-issues.apt with content extracted from @@ -31,9 +33,10 @@ public class NotReproduciblePluginsDocumentationTest { private static final String LS = System.lineSeparator(); private static final String DELIMITER = "~~ content generated by NotReproduciblePluginsDocumentationTest"; + @Test public void testBasic() throws IOException { File pluginIssuesApt = new File("src/site/apt/plugin-issues.apt"); - String content = FileUtils.fileRead(pluginIssuesApt, "UTF-8"); + String content = new String(Files.readAllBytes(pluginIssuesApt.toPath()), StandardCharsets.UTF_8); content = content.substring(0, content.indexOf(DELIMITER) + DELIMITER.length()); StringBuilder sb = new StringBuilder(content); @@ -44,9 +47,12 @@ public void testBasic() throws IOException { sb.append( "| | <> | <> | <>"); String groupId = null; - for (String line : FileUtils.loadFile( - new File( - "src/main/resources/org/apache/maven/plugins/artifact/buildinfo/not-reproducible-plugins.properties"))) { + for (String line : Files.readAllLines(new File( + "src/main/resources/org/apache/maven/plugins/artifact/buildinfo/not-reproducible-plugins.properties") + .toPath())) { + if (line.trim().isEmpty()) { + continue; + } if (!line.startsWith("#")) { sb.append(LS + "*--------+--------------------------------------------------------------------+-------+--------------+" @@ -80,6 +86,6 @@ public void testBasic() throws IOException { + "*----------+------------------------------------------------------------------+-------+--------------+" + LS); - FileUtils.fileWrite(pluginIssuesApt, "UTF-8", sb.toString()); + Files.write(pluginIssuesApt.toPath(), sb.toString().getBytes(StandardCharsets.UTF_8)); } }