This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-archetype.git
commit b870339817f3f4266b97bace88e28f42893ff798 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Sat Oct 31 17:42:23 2026 +0000 Replace commons-io with JDK and plexus-utils --- archetype-common/pom.xml | 4 ---- .../common/DefaultArchetypeArtifactManager.java | 4 ++-- .../archetype/creator/FilesetArchetypeCreator.java | 4 +--- .../repositorycrawler/DefaultRepositoryCrawler.java | 21 +++++++++++++++++---- .../apache/maven/archetype/old/ArchetypeTest.java | 2 +- maven-archetype-plugin/pom.xml | 4 ---- .../maven/archetype/mojos/IntegrationTestMojo.java | 4 ++-- pom.xml | 5 ----- 8 files changed, 23 insertions(+), 25 deletions(-) diff --git a/archetype-common/pom.xml b/archetype-common/pom.xml index a6c239bd..c58795f0 100644 --- a/archetype-common/pom.xml +++ b/archetype-common/pom.xml @@ -109,10 +109,6 @@ <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java b/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java index 4aabe474..3412ac4e 100644 --- a/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java +++ b/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java @@ -39,7 +39,6 @@ import java.util.TreeMap; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import org.apache.commons.io.IOUtils; import org.apache.maven.archetype.downloader.DownloadException; import org.apache.maven.archetype.downloader.Downloader; import org.apache.maven.archetype.exception.UnknownArchetype; @@ -47,6 +46,7 @@ import org.apache.maven.archetype.metadata.ArchetypeDescriptor; import org.apache.maven.archetype.metadata.io.xpp3.ArchetypeDescriptorXpp3Reader; import org.apache.maven.archetype.old.descriptor.ArchetypeDescriptorBuilder; import org.apache.maven.model.Model; +import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; @@ -196,7 +196,7 @@ public class DefaultArchetypeArtifactManager implements ArchetypeArtifactManager public String getPostGenerationScript(File archetypeFile) throws UnknownArchetype { try (ZipFile zipFile = getArchetypeZipFile(archetypeFile)) { Reader reader = getDescriptorReader(zipFile, Constants.ARCHETYPE_POST_GENERATION_SCRIPT); - return reader == null ? null : IOUtils.toString(reader); + return reader == null ? null : IOUtil.toString(reader); } catch (IOException e) { throw new UnknownArchetype(e); } diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java b/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java index ea3bde9a..e6d59a0f 100644 --- a/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java +++ b/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java @@ -79,8 +79,6 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.apache.commons.io.IOUtils.write; - /** * Create a 2.x Archetype project from a project. Since 2.0-alpha-5, an integration-test named "basic" is created along * the archetype itself to provide immediate test when building the archetype. @@ -1288,7 +1286,7 @@ public class FilesetArchetypeCreator implements ArchetypeCreator { } try (OutputStream os = Files.newOutputStream(outputFile.toPath())) { - write(content, os, fileEncoding); + os.write(content.getBytes(fileEncoding)); } } } diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/repositorycrawler/DefaultRepositoryCrawler.java b/archetype-common/src/main/java/org/apache/maven/archetype/repositorycrawler/DefaultRepositoryCrawler.java index 0464a1f3..07b8d707 100644 --- a/archetype-common/src/main/java/org/apache/maven/archetype/repositorycrawler/DefaultRepositoryCrawler.java +++ b/archetype-common/src/main/java/org/apache/maven/archetype/repositorycrawler/DefaultRepositoryCrawler.java @@ -24,10 +24,16 @@ import javax.inject.Singleton; import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; import java.io.Writer; +import java.nio.file.FileVisitOption; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; -import org.apache.commons.io.FileUtils; import org.apache.maven.archetype.catalog.Archetype; import org.apache.maven.archetype.catalog.ArchetypeCatalog; import org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Writer; @@ -58,9 +64,16 @@ public class DefaultRepositoryCrawler implements RepositoryCrawler { } ArchetypeCatalog catalog = new ArchetypeCatalog(); - @SuppressWarnings("unchecked") - Iterator<File> jars = - FileUtils.listFiles(repository, new String[] {"jar"}, true).iterator(); + List<File> jarFiles; + try (Stream<Path> paths = Files.walk(repository.toPath(), FileVisitOption.FOLLOW_LINKS)) { + jarFiles = paths.filter(Files::isRegularFile) + .filter(path -> path.getFileName().toString().endsWith(".jar")) + .map(Path::toFile) + .collect(Collectors.toList()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + Iterator<File> jars = jarFiles.iterator(); while (jars.hasNext()) { File jar = jars.next(); diff --git a/archetype-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java b/archetype-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java index 953b543b..411c32fb 100644 --- a/archetype-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java +++ b/archetype-common/src/test/java/org/apache/maven/archetype/old/ArchetypeTest.java @@ -32,7 +32,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.io.FileUtils; import org.apache.maven.archetype.ArchetypeGenerationRequest; import org.apache.maven.archetype.ArchetypeVelocityEngine; import org.apache.maven.archetype.exception.InvalidPackaging; @@ -42,6 +41,7 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.velocity.VelocityContext; import org.apache.velocity.context.Context; import org.codehaus.plexus.testing.PlexusTest; +import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; diff --git a/maven-archetype-plugin/pom.xml b/maven-archetype-plugin/pom.xml index 9cdfea2d..cc2ecdb3 100644 --- a/maven-archetype-plugin/pom.xml +++ b/maven-archetype-plugin/pom.xml @@ -139,10 +139,6 @@ <artifactId>commons-collections4</artifactId> <version>4.6.0</version> </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> <dependency> <groupId>org.junit.jupiter</groupId> diff --git a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/IntegrationTestMojo.java b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/IntegrationTestMojo.java index 42948ef5..d31d0bb5 100644 --- a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/IntegrationTestMojo.java +++ b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/IntegrationTestMojo.java @@ -447,7 +447,7 @@ public class IntegrationTestMojo extends AbstractMojo { File basedir = new File(goalFile.getParentFile(), "project"); - org.apache.commons.io.FileUtils.deleteDirectory(basedir); + FileUtils.deleteDirectory(basedir); FileUtils.mkdir(basedir.toString()); @@ -615,7 +615,7 @@ public class IntegrationTestMojo extends AbstractMojo { File archetypeItDirectory = new File(project.getBuild().getDirectory(), "archetype-it"); if (archetypeItDirectory.exists()) { - org.apache.commons.io.FileUtils.deleteDirectory(archetypeItDirectory); + FileUtils.deleteDirectory(archetypeItDirectory); } archetypeItDirectory.mkdir(); File userSettings; diff --git a/pom.xml b/pom.xml index a45ce355..fe8421cc 100644 --- a/pom.xml +++ b/pom.xml @@ -164,11 +164,6 @@ <artifactId>maven-executor</artifactId> <version>1.0.0</version> </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>2.22.0</version> - </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-interactivity-api</artifactId>
