IDEA-CR-62933: #BDIDE-901 Disable SNAPSHOT artifacts from central repo

(cherry picked from commit 35c95d8283313b1d5463269504b95c8c41516271)

GitOrigin-RevId: 0b0644a3fab4a1de811c3e257f5884ca6b2180af
This commit is contained in:
Nikita Ashihmin
2020-05-25 14:47:39 +03:00
committed by intellij-monorepo-bot
parent 33afa59ac6
commit 8784692c6c
3 changed files with 36 additions and 16 deletions
@@ -51,7 +51,6 @@ import java.util.*;
*
* instance of this component should be managed by the code which requires dependency resolution functionality
* all necessary params like path to local repo should be passed in constructor
*
*/
public class ArtifactRepositoryManager {
private static final VersionScheme ourVersioning = new GenericVersionScheme();
@@ -322,9 +321,20 @@ public class ArtifactRepositoryManager {
return result.getVersions();
}
public static RemoteRepository createRemoteRepository(final String id, final String url) {
public static RemoteRepository createRemoteRepository(final String id,
final String url) {
return createRemoteRepository(id, url, true);
}
public static RemoteRepository createRemoteRepository(final String id,
final String url,
boolean allowSnapshots) {
// for maven repos repository type should be 'default'
return new RemoteRepository.Builder(id, "default", url).setProxy(ourProxySelector.getProxy(url)).build();
RemoteRepository.Builder builder = new RemoteRepository.Builder(id, "default", url);
if (!allowSnapshots) {
builder.setSnapshotPolicy(new RepositoryPolicy(false, null, null));
}
return builder.setProxy(ourProxySelector.getProxy(url)).build();
}
public static RemoteRepository createRemoteRepository(RemoteRepository prototype) {
@@ -477,7 +477,9 @@ public class JarRepositoryManager {
final ArrayList<RemoteRepository> remotes = new ArrayList<>();
for (RemoteRepositoryDescription repository : myRepositories) {
remotes.add(ArtifactRepositoryManager.createRemoteRepository(repository.getId(), repository.getUrl()));
remotes.add(
ArtifactRepositoryManager.createRemoteRepository(repository.getId(), repository.getUrl(), repository.isAllowSnapshots())
);
}
try {
return perform(indicator, new ArtifactRepositoryManager(getLocalRepositoryPath(), remotes, new ProgressConsumer() {
@@ -5,6 +5,7 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Objects;
/**
* @author Eugene Zhuravlev
@@ -27,11 +28,20 @@ public class RemoteRepositoryDescription {
private final String myId;
private final String myName;
private final String myUrl;
private final boolean myAllowSnapshots;
public RemoteRepositoryDescription(@NotNull String id, @NotNull String name, @NotNull String url) {
this(id, name, url, true);
}
public RemoteRepositoryDescription(@NotNull String id,
@NotNull String name,
@NotNull String url,
boolean allowSnapshots) {
myId = id;
myName = name;
myUrl = url;
myAllowSnapshots = allowSnapshots;
}
public String getId() {
@@ -46,30 +56,28 @@ public class RemoteRepositoryDescription {
return myUrl;
}
public boolean isAllowSnapshots() {
return myAllowSnapshots;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RemoteRepositoryDescription that = (RemoteRepositoryDescription)o;
if (!myId.equals(that.myId)) return false;
if (!myName.equals(that.myName)) return false;
if (!myUrl.equals(that.myUrl)) return false;
return true;
return myAllowSnapshots == that.myAllowSnapshots &&
myId.equals(that.myId) &&
myName.equals(that.myName) &&
myUrl.equals(that.myUrl);
}
@Override
public int hashCode() {
int result = myId.hashCode();
result = 31 * result + myName.hashCode();
result = 31 * result + myUrl.hashCode();
return result;
return Objects.hash(myId, myName, myUrl, myAllowSnapshots);
}
@Override
public String toString() {
return myId + ":" + myName + ":" + myUrl;
return myId + ":" + myName + ":" + myUrl + " (snapshots=" + myAllowSnapshots + ")";
}
}