Copilot commented on code in PR #563:
URL: https://github.com/apache/maven-jar-plugin/pull/563#discussion_r3613660183


##########
src/it/MJAR-557-detect-mjar/verify.groovy:
##########
@@ -0,0 +1,29 @@
+/*
+ * 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.*;
+
+def jarFile = new File(basedir, 
'target/mjar-557-detect-multi-release-1.0-SNAPSHOT.jar')
+assert jarFile.exists()
+assert jarFile.isFile()
+
+def mrjar = new JarFile(jarFile)
+def manifest = mrjar.manifest.mainAttributes
+
+assert manifest.getValue(Attributes.Name.MULTI_RELEASE) == "true"

Review Comment:
   The `JarFile` is never closed. On Windows in particular, leaving the JAR 
file handle open can cause file-locking issues during test cleanup or 
subsequent steps. Wrap `JarFile` usage in a `try/finally` that calls 
`mrjar.close()`, or use Groovy's `withCloseable { ... }` to ensure the handle 
is always released.



##########
src/it/MJAR-557-detect-mjar/src/main/resources/META-INF/versions/9/test.txt:
##########
@@ -0,0 +1 @@
+Test file for multi-release JAR detection

Review Comment:
   The PR description mentions detecting 
`META-INF/versions/9/module-info.class` in the class output, but the IT fixture 
currently adds a resource text file (`test.txt`). If the intent is 'any entry 
under `META-INF/versions/` triggers `Multi-Release: true`', consider updating 
the PR description to match; otherwise, adjust the fixture/project so it more 
closely reflects the described `module-info.class` scenario.



##########
src/it/MJAR-557-detect-mjar/verify.groovy:
##########
@@ -0,0 +1,29 @@
+/*
+ * 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.*;
+
+def jarFile = new File(basedir, 
'target/mjar-557-detect-multi-release-1.0-SNAPSHOT.jar')
+assert jarFile.exists()
+assert jarFile.isFile()
+
+def mrjar = new JarFile(jarFile)
+def manifest = mrjar.manifest.mainAttributes
+
+assert manifest.getValue(Attributes.Name.MULTI_RELEASE) == "true"

Review Comment:
   This assertion will be more actionable if it includes an assertion message 
(e.g., showing the actual `Multi-Release` value or that the attribute was 
missing). Adding a message makes IT failures significantly easier to diagnose 
from CI logs.



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