Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[MRESOLVER-392] Remove change detection logic on install #351

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix wrong interpretation of existing code
  • Loading branch information
cstamas committed Oct 27, 2023
commit a021596a56ebbb5485cf44a6126d047ca464ec0d
Original file line number Diff line number Diff line change
@@ -50,9 +50,6 @@
import org.eclipse.aether.repository.LocalRepositoryManager;
import org.eclipse.aether.spi.io.FileProcessor;
import org.eclipse.aether.spi.synccontext.SyncContextFactory;
import org.eclipse.aether.util.ConfigUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static java.util.Objects.requireNonNull;

@@ -61,25 +58,6 @@
@Singleton
@Named
public class DefaultInstaller implements Installer {

/**
* The key in the repository session's {@link RepositorySystemSession#getConfigProperties()
* configuration properties} used to restore legacy 1.x behaviour: ignore install request that has source
* file missing.
*
* @since 2.0.0
*/
static final String CONFIG_PROP_IGNORE_MISSING_FILE_INSTALL = "aether.installer.ignoreMissingFileInstall";

/**
* The default value for {@link #CONFIG_PROP_IGNORE_MISSING_FILE_INSTALL}, {@code false}.
*
* @since 2.0.0
*/
static final boolean CONFIG_PROP_IGNORE_MISSING_FILE_INSTALL_DEFAULT = false;

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

private final FileProcessor fileProcessor;

private final RepositoryEventDispatcher repositoryEventDispatcher;
@@ -112,9 +90,6 @@ public InstallResult install(RepositorySystemSession session, InstallRequest req

private InstallResult install(SyncContext syncContext, RepositorySystemSession session, InstallRequest request)
throws InstallationException {
boolean ignoreMissingFileInstall = ConfigUtils.getBoolean(
session, CONFIG_PROP_IGNORE_MISSING_FILE_INSTALL_DEFAULT, CONFIG_PROP_IGNORE_MISSING_FILE_INSTALL);

InstallResult result = new InstallResult(request);

RequestTrace trace = RequestTrace.newChild(request.getTrace(), request);
@@ -144,7 +119,7 @@ private InstallResult install(SyncContext syncContext, RepositorySystemSession s

iterator.set(artifact);

install(ignoreMissingFileInstall, session, trace, artifact);
install(session, trace, artifact);
result.addArtifact(artifact);
}

@@ -185,8 +160,7 @@ private List<? extends MetadataGenerator> getMetadataGenerators(
return generators;
}

private void install(
boolean ignoreMissingFileInstall, RepositorySystemSession session, RequestTrace trace, Artifact artifact)
private void install(RepositorySystemSession session, RequestTrace trace, Artifact artifact)
throws InstallationException {
final LocalRepositoryManager lrm = session.getLocalRepositoryManager();
final File srcFile = artifact.getFile();
@@ -200,13 +174,8 @@ private void install(
throw new IllegalStateException("cannot install " + dstFile + " to same path");
}

if (ignoreMissingFileInstall && !srcFile.exists()) {
LOGGER.debug("Skipped installing {} to {}, source is missing", 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;
Original file line number Diff line number Diff line change
@@ -346,21 +346,6 @@ public long copy(File src, File target, ProgressListener listener) throws IOExce
installer.install(session, request);
}

@Test
void testMissingSourceFails() {
artifact = artifact.setFile(new File("nonexistent artifact"));
request.addArtifact(artifact);
assertThrows(InstallationException.class, () -> installer.install(session, request));
}

@Test
void testMissingSourceSilentlySkippedIfSet() throws InstallationException {
session.setConfigProperty(DefaultInstaller.CONFIG_PROP_IGNORE_MISSING_FILE_INSTALL, true);
artifact = artifact.setFile(new File("nonexistent artifact"));
request.addArtifact(artifact);
installer.install(session, request);
}

@Test
void testSetArtifactTimestamps() throws InstallationException {
artifact.getFile().setLastModified(artifact.getFile().lastModified() - 60000);