Skip to content

Commit

Permalink
Fix the ipc sync context when MVND_DAEMON_STORAGE is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jul 29, 2021
1 parent c63c57a commit 2ccf8a5
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -18,6 +18,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PreDestroy;
import javax.inject.Named;
Expand All @@ -26,6 +27,7 @@
import org.eclipse.aether.SyncContext;
import org.eclipse.aether.impl.SyncContextFactory;
import org.eclipse.sisu.Priority;
import org.mvndaemon.mvnd.common.BuildProperties;
import org.mvndaemon.mvnd.common.Environment;

/**
Expand All @@ -41,8 +43,11 @@ public class IpcSyncContextFactory implements SyncContextFactory {
@Override
public SyncContext newInstance(RepositorySystemSession session, boolean shared) {
Path repository = session.getLocalRepository().getBasedir().toPath();
Path logPath = Environment.MVND_DAEMON_STORAGE.asPath();
String mvndHome = Environment.MVND_HOME.asOptional().orElse(null);
Path logPath = Optional.ofNullable(System.getProperty(Environment.MVND_DAEMON_STORAGE.getProperty()))
.map(Paths::get)
.orElseGet(() -> Environment.USER_HOME.asPath()
.resolve(".m2/mvnd/registry/" + BuildProperties.getInstance().getVersion()));
String mvndHome = Environment.MVND_HOME.asString();
Path syncPath = mvndHome != null ? Paths.get(mvndHome).resolve("bin") : null;
IpcClient client = clients.computeIfAbsent(repository, r -> new IpcClient(r, logPath, syncPath));
return new IpcSyncContext(client, shared);
Expand Down

0 comments on commit 2ccf8a5

Please sign in to comment.