gnodet-bot commented on code in PR #13490: URL: https://github.com/apache/maven/pull/13490#discussion_r4317496163
########## impl/maven-classworlds/src/test/java/org/codehaus/plexus/classworlds/TestJarGenerator.java: ########## @@ -0,0 +1,554 @@ +/* + * 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. + */ +package org.codehaus.plexus.classworlds; + +import javax.tools.DiagnosticCollector; +import javax.tools.FileObject; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; + +/** + * Generates test fixture JARs at test time using the JDK's {@code javac} and {@code jar} tools, + * eliminating the need to commit pre-compiled binary JARs to version control. + * + * <p>All JARs are written to {@code target/test-jars/} under the module base directory. + * The generator is idempotent: if the directory already exists and is non-empty it is wiped + * and rebuilt to ensure freshness. Review Comment: 💡 **Misleading Javadoc: “wiped and rebuilt” doesn’t match the implementation.** The constructor calls `Files.createDirectories(outputDir)` (a no-op if the directory exists), and `jar()` calls `Files.newOutputStream(out)` which truncates-and-overwrites each file individually. No directory-level deletion happens — leftover JARs from a previous run whose names are no longer generated (e.g. if a JAR name changes) would survive silently. The description should match the actual behaviour: ```suggestion * <p>All JARs are written to {@code target/test-jars/} under the module base directory. * The generator is idempotent: existing JARs are overwritten on each run. Note that * JARs from a previous run whose names are no longer generated are not deleted. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
