Copilot commented on code in PR #453:
URL: 
https://github.com/apache/maven-build-cache-extension/pull/453#discussion_r3104912489


##########
src/test/java/org/apache/maven/buildcache/its/Issue449Test.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.apache.maven.buildcache.its;
+
+import org.apache.commons.lang3.SystemUtils;
+import org.apache.maven.buildcache.its.junit.IntegrationTest;
+import org.apache.maven.it.VerificationException;
+import org.apache.maven.it.Verifier;
+import org.junit.jupiter.api.Test;
+
+import static java.util.Arrays.asList;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
+
+@IntegrationTest("src/test/projects/issue-449-artifact-restore")
+class Issue449Test {
+
+    @Test
+    void installAfterCleanCompileShouldWork(Verifier verifier) throws 
VerificationException {
+        assumeFalse(SystemUtils.IS_OS_WINDOWS);
+
+        verifier.setAutoclean(false);
+
+        verifier.setLogFileName("../log-0.txt");
+        verifier.executeGoals(asList("clean", "compile"));
+        verifier.verifyErrorFreeLog();
+        verifier.verifyTextInLog("Saved Build to local file");
+        verifier.verifyTextInLog("Local build was not found");
+
+        verifier.setLogFileName("../log-1.txt");
+        verifier.executeGoals(asList("clean", "install"));
+        verifier.verifyErrorFreeLog();
+        verifier.verifyTextInLog("Found cached build, restoring");
+        verifier.verifyTextInLog("Saved Build to local file");
+    }

Review Comment:
   The test currently asserts log messages and error-free execution, but it 
doesn't assert that the JAR was actually installed. Adding a 
verifyArtifactPresent(...) (and/or a check that the installed artifact is a 
file/zip) would make the test directly cover the regression from #449 
(directory being treated as the main artifact).



##########
src/test/projects/issue-449-artifact-restore/.mvn/maven-build-cache-config.xml:
##########
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!---
+ 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.
+-->
+<cache xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.2.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0 
https://maven.apache.org/xsd/build-cache-config-1.2.0.xsd";>

Review Comment:
   The schemaLocation namespace URI (1.0.0) does not match the document 
namespace (1.2.0). With validateXml enabled, this can lead to the config not 
validating/being interpreted against the intended schema. Align schemaLocation 
to 1.2.0 (as in other test projects).
   ```suggestion
          xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.2.0 
https://maven.apache.org/xsd/build-cache-config-1.2.0.xsd";>
   ```



##########
src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java:
##########
@@ -470,7 +472,10 @@ public ArtifactRestorationReport 
restoreProjectArtifacts(CacheResult cacheResult
             }
             // Actually modify project at the end in case something went wrong 
during restoration,
             // in which case, the project is unmodified and we continue with 
normal build.
-            if (restoredProjectArtifact != null) {
+            //
+            // Also, only restore the project artifact, if it was an actually 
fully build JAR,

Review Comment:
   Typo/grammar in the new comment: "fully build" should be "fully built".
   ```suggestion
               // Also, only restore the project artifact, if it was an 
actually fully built JAR,
   ```



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