Copilot commented on code in PR #1343:
URL: 
https://github.com/apache/maven-assembly-plugin/pull/1343#discussion_r3695487693


##########
src/it/projects/multimodule/module-attachment-classifier/verify.groovy:
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+import java.util.jar.JarFile
+
+def modulesDirectory = new File(basedir, 
'assembly/target/assembly-1.0-bin/modules')
+def attachment = new File(modulesDirectory, 'producer-tests.jar')
+
+assert attachment.isFile() : "The attached test JAR is missing: ${attachment}"
+
+def jar = new JarFile(attachment)
+try {
+    assert jar.getEntry('attachment-marker.txt') != null :
+            'The selected artifact does not contain the attachment marker.'
+} finally {
+    jar.close()
+}
+
+assert !new File(modulesDirectory, 'producer.jar').exists() :
+        'The main module artifact was included instead of its attachment.'

Review Comment:
   The negative assertion only checks for `producer.jar`, but with the 
configured `outputFileNameMapping` the main artifact (classifier empty) could 
be written under a different name (e.g., with a dangling dash), so the test may 
not catch the wrong artifact being selected. It’s safer to assert that the 
modules directory contains only `producer-tests.jar`.



##########
src/it/projects/multimodule/multimodule-wholeReactorFromChild/verify.bsh:
##########
@@ -39,4 +39,14 @@ if ( new File( basedir, 
"child4/target/child4-1.0-bin/lib/child2.jar" ).exists()
     result = false;
 }
 
+File libDirectory = new File( basedir, "child4/target/child4-1.0-bin/lib" );
+File[] includedArtifacts = libDirectory.listFiles();
+
+if ( includedArtifacts == null || includedArtifacts.length != 2 )
+{
+    System.out.println( "Only the two selected module artifacts should be 
present when includeDependencies=false." );
+    System.out.println( "Files found: " + Arrays.toString( includedArtifacts ) 
);
+    result = false;

Review Comment:
   `Arrays.toString(...)` is used without importing `java.util.Arrays` (only 
`java.io.*` is imported), which can cause the verify script to fail at runtime 
and fail the IT for the wrong reason.



-- 
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]

Reply via email to