Skip to content

Commit

Permalink
[MRESOLVER-392] Remove change detection logic on install (#351)
Browse files Browse the repository at this point in the history
Still, make possible to restore the "skip if missing" as I find no reasonong for it, but my guess is that it may be about some legacy code somewhere, most probably adding Metadata without backing file (as in Maven2 metadata was added by hand).

---

https://issues.apache.org/jira/browse/MRESOLVER-392
  • Loading branch information
cstamas authored Oct 27, 2023
1 parent 76137bb commit 72ddff2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
import org.eclipse.aether.repository.LocalRepositoryManager;
import org.eclipse.aether.spi.io.FileProcessor;
import org.eclipse.aether.spi.synccontext.SyncContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static java.util.Objects.requireNonNull;

Expand All @@ -60,9 +58,6 @@
@Singleton
@Named
public class DefaultInstaller implements Installer {

private static final Logger LOGGER = LoggerFactory.getLogger(DefaultInstaller.class);

private final FileProcessor fileProcessor;

private final RepositoryEventDispatcher repositoryEventDispatcher;
Expand Down Expand Up @@ -179,18 +174,8 @@ private void install(RepositorySystemSession session, RequestTrace trace, Artifa
throw new IllegalStateException("cannot install " + dstFile + " to same path");
}

boolean copy = "pom".equals(artifact.getExtension())
|| srcFile.lastModified() != dstFile.lastModified()
|| srcFile.length() != dstFile.length()
|| !srcFile.exists();

if (!copy) {
LOGGER.debug("Skipped re-installing {} to {}, seems unchanged", srcFile, dstFile);
} else {
fileProcessor.copy(srcFile, dstFile);
dstFile.setLastModified(srcFile.lastModified());
}

fileProcessor.copy(srcFile, dstFile);
dstFile.setLastModified(srcFile.lastModified());
lrm.add(session, new LocalArtifactRegistration(artifact));
} catch (Exception e) {
exception = e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.eclipse.aether.metadata.Metadata.Nature;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -324,6 +325,7 @@ private void checkEvents(String msg, Artifact artifact, boolean failed) {
}

@Test
@Disabled("Naive change detection is removed (MRESOLVER-392)")
void testDoNotUpdateUnchangedArtifact() throws InstallationException {
request.addArtifact(artifact);
installer.install(session, request);
Expand Down

0 comments on commit 72ddff2

Please sign in to comment.