mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
make ArtifactRepositoryManager stateless and reuse the same manager instance across modules (part of IDEA-285617)
GitOrigin-RevId: 72e12d3053f4446dc2dba259065e9aee3cca6c4f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
49460670be
commit
2d309063e7
@@ -103,7 +103,7 @@ public final class ArtifactRepositoryManager {
|
||||
}
|
||||
|
||||
private static class RepositorySystemSessionFactory {
|
||||
private final RepositorySystemSession defaultSession;
|
||||
private final RepositorySystemSession sessionTemplate;
|
||||
|
||||
RepositorySystemSessionFactory(@NotNull File localRepositoryPath,
|
||||
@NotNull ProgressConsumer progressConsumer,
|
||||
@@ -153,11 +153,11 @@ public final class ArtifactRepositoryManager {
|
||||
session.setProxySelector(ourProxySelector);
|
||||
session.setOffline(offline);
|
||||
session.setReadOnly();
|
||||
this.defaultSession = session;
|
||||
sessionTemplate = session;
|
||||
}
|
||||
|
||||
RepositorySystemSession getDefaultSession() {
|
||||
return defaultSession;
|
||||
RepositorySystemSession createDefaultSession() {
|
||||
return new DefaultRepositorySystemSession(sessionTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,25 +165,23 @@ public final class ArtifactRepositoryManager {
|
||||
* @see ArtifactDependencyNode#isRejected()
|
||||
*/
|
||||
RepositorySystemSession createVerboseSession() {
|
||||
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(defaultSession);
|
||||
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(sessionTemplate);
|
||||
session.setConfigProperty(ConflictResolver.CONFIG_PROP_VERBOSE, Boolean.TRUE);
|
||||
session.setReadOnly();
|
||||
return session;
|
||||
}
|
||||
|
||||
RepositorySystemSession createSession(@NotNull List<String> excludedDependencies) {
|
||||
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(sessionTemplate);
|
||||
if (excludedDependencies.isEmpty()) {
|
||||
return defaultSession;
|
||||
}
|
||||
else {
|
||||
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(defaultSession);
|
||||
session.setDependencySelector(new AndDependencySelector(
|
||||
session.getDependencySelector(),
|
||||
new ExclusionDependencySelector(exclusions(excludedDependencies)))
|
||||
);
|
||||
session.setReadOnly();
|
||||
return session;
|
||||
}
|
||||
session.setDependencySelector(new AndDependencySelector(
|
||||
session.getDependencySelector(),
|
||||
new ExclusionDependencySelector(exclusions(excludedDependencies)))
|
||||
);
|
||||
session.setReadOnly();
|
||||
return session;
|
||||
}
|
||||
|
||||
@SuppressWarnings("SSBasedInspection")
|
||||
@@ -296,7 +294,7 @@ public final class ArtifactRepositoryManager {
|
||||
requests = builder.getRequests();
|
||||
}
|
||||
else {
|
||||
session = mySessionFactory.getDefaultSession();
|
||||
session = mySessionFactory.createDefaultSession();
|
||||
requests = new ArrayList<>();
|
||||
for (Artifact artifact : toArtifacts(groupId, artifactId, constraints, Collections.singleton(kind))) {
|
||||
if (ourVersioning.parseVersionConstraint(artifact.getVersion()).getRange() != null) {
|
||||
@@ -418,7 +416,7 @@ public final class ArtifactRepositoryManager {
|
||||
@NotNull
|
||||
public List<Version> getAvailableVersions(String groupId, String artifactId, String versionConstraint, final ArtifactKind artifactKind) throws Exception {
|
||||
final VersionRangeResult result = ourSystem.resolveVersionRange(
|
||||
mySessionFactory.getDefaultSession(), createVersionRangeRequest(groupId, artifactId, asVersionConstraint(versionConstraint), artifactKind)
|
||||
mySessionFactory.createDefaultSession(), createVersionRangeRequest(groupId, artifactId, asVersionConstraint(versionConstraint), artifactKind)
|
||||
);
|
||||
return result.getVersions();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class DependencyResolvingBuilder extends ModuleLevelBuilder{
|
||||
private static final String MAVEN_REPOSITORY_PATH_VAR = "MAVEN_REPOSITORY";
|
||||
private static final String DEFAULT_MAVEN_REPOSITORY_PATH = ".m2/repository";
|
||||
|
||||
private static final Key<ArtifactRepositoryManager> MANAGER_KEY = Key.create("_artifact_repository_manager_");
|
||||
private static final Key<ArtifactRepositoryManager> MANAGER_KEY = GlobalContextKey.create("_artifact_repository_manager_");
|
||||
private static final Key<Exception> RESOLVE_ERROR_KEY = Key.create("_artifact_repository_resolve_error_");
|
||||
public static final String RESOLUTION_PARALLELISM_PROPERTY = "org.jetbrains.jps.incremental.dependencies.resolution.parallelism";
|
||||
|
||||
@@ -281,7 +281,7 @@ public class DependencyResolvingBuilder extends ModuleLevelBuilder{
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ArtifactRepositoryManager getRepositoryManager(final CompileContext context) {
|
||||
public static synchronized ArtifactRepositoryManager getRepositoryManager(final CompileContext context) {
|
||||
ArtifactRepositoryManager manager = MANAGER_KEY.get(context);
|
||||
if (manager == null) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user