use of org.jetbrains.plugins.gradle.DefaultExternalDependencyId in project intellij-community by JetBrains.
the class GradleProjectResolverUtil method buildDependencies.
public static void buildDependencies(@NotNull ProjectResolverContext resolverCtx, @NotNull Map<String, Pair<DataNode<GradleSourceSetData>, ExternalSourceSet>> sourceSetMap, @NotNull final Map<String, String> artifactsMap, @NotNull DataNode<? extends ExternalEntityData> ownerDataNode, @NotNull Collection<ExternalDependency> dependencies, @Nullable DataNode<ProjectData> ideProject) throws IllegalStateException {
Map<ExternalDependencyId, ExternalDependency> dependencyMap = ContainerUtil.newHashMap();
Queue<ExternalDependency> queue = ContainerUtil.newLinkedList(dependencies);
while (!queue.isEmpty()) {
final ExternalDependency dependency = queue.remove();
ExternalDependency seenDependency = dependencyMap.get(dependency.getId());
if (seenDependency != null) {
if (dependency instanceof ExternalLibraryDependency) {
if (seenDependency instanceof ExternalLibraryDependency && !FileUtil.filesEqual(((ExternalLibraryDependency) seenDependency).getFile(), ((ExternalLibraryDependency) dependency).getFile())) {
DefaultExternalMultiLibraryDependency mergedDependency = new DefaultExternalMultiLibraryDependency();
mergedDependency.setName(dependency.getId().getName());
mergedDependency.setGroup(dependency.getId().getGroup());
mergedDependency.setVersion(dependency.getId().getVersion());
mergedDependency.setPackaging(dependency.getId().getPackaging());
mergedDependency.setClassifier(dependency.getId().getClassifier());
mergedDependency.setScope(dependency.getScope());
mergedDependency.setClasspathOrder(dependency.getClasspathOrder());
mergedDependency.getDependencies().addAll(dependency.getDependencies());
mergedDependency.getFiles().addAll(ContainerUtil.packNullables(((ExternalLibraryDependency) seenDependency).getFile(), ((ExternalLibraryDependency) dependency).getFile()));
mergedDependency.getSources().addAll((ContainerUtil.packNullables(((ExternalLibraryDependency) seenDependency).getSource(), ((ExternalLibraryDependency) dependency).getSource())));
mergedDependency.getJavadoc().addAll((ContainerUtil.packNullables(((ExternalLibraryDependency) seenDependency).getJavadoc(), ((ExternalLibraryDependency) dependency).getJavadoc())));
dependencyMap.put(dependency.getId(), mergedDependency);
continue;
} else if (seenDependency instanceof DefaultExternalMultiLibraryDependency) {
DefaultExternalMultiLibraryDependency mergedDependency = (DefaultExternalMultiLibraryDependency) seenDependency;
mergedDependency.getFiles().addAll(ContainerUtil.packNullables(((ExternalLibraryDependency) dependency).getFile()));
mergedDependency.getSources().addAll(ContainerUtil.packNullables(((ExternalLibraryDependency) dependency).getSource()));
mergedDependency.getJavadoc().addAll(ContainerUtil.packNullables(((ExternalLibraryDependency) dependency).getJavadoc()));
continue;
}
}
DependencyScope prevScope = seenDependency.getScope() == null ? DependencyScope.COMPILE : DependencyScope.valueOf(seenDependency.getScope());
DependencyScope currentScope = dependency.getScope() == null ? DependencyScope.COMPILE : DependencyScope.valueOf(dependency.getScope());
if (prevScope.isForProductionCompile())
continue;
if (prevScope.isForProductionRuntime() && currentScope.isForProductionRuntime())
continue;
}
dependencyMap.put(new DefaultExternalDependencyId(dependency.getId()), dependency);
queue.addAll(dependency.getDependencies());
}
doBuildDependencies(resolverCtx, sourceSetMap, artifactsMap, dependencyMap, ownerDataNode, dependencies, ideProject);
}
use of org.jetbrains.plugins.gradle.DefaultExternalDependencyId in project intellij-community by JetBrains.
the class ExternalProjectSerializer method configureKryo.
private void configureKryo() {
myKryo.setAutoReset(true);
myKryo.setRegistrationRequired(true);
Log.set(Log.LEVEL_WARN);
myKryo.register(ArrayList.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new ArrayList();
}
});
myKryo.register(HashMap.class, new MapSerializer() {
@Override
protected Map create(Kryo kryo, Input input, Class<Map> type) {
return new HashMap();
}
});
myKryo.register(HashSet.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new HashSet();
}
});
myKryo.register(File.class, new FileSerializer());
myKryo.register(DefaultExternalProject.class, new FieldSerializer<DefaultExternalProject>(myKryo, DefaultExternalProject.class) {
@Override
protected DefaultExternalProject create(Kryo kryo, Input input, Class<DefaultExternalProject> type) {
return new DefaultExternalProject();
}
});
myKryo.register(DefaultExternalTask.class, new FieldSerializer<DefaultExternalTask>(myKryo, DefaultExternalTask.class) {
@Override
protected DefaultExternalTask create(Kryo kryo, Input input, Class<DefaultExternalTask> type) {
return new DefaultExternalTask();
}
});
myKryo.register(DefaultExternalPlugin.class, new FieldSerializer<DefaultExternalPlugin>(myKryo, DefaultExternalPlugin.class) {
@Override
protected DefaultExternalPlugin create(Kryo kryo, Input input, Class<DefaultExternalPlugin> type) {
return new DefaultExternalPlugin();
}
});
myKryo.register(DefaultExternalSourceSet.class, new FieldSerializer<DefaultExternalSourceSet>(myKryo, DefaultExternalSourceSet.class) {
@Override
protected DefaultExternalSourceSet create(Kryo kryo, Input input, Class<DefaultExternalSourceSet> type) {
return new DefaultExternalSourceSet();
}
});
myKryo.register(DefaultExternalSourceDirectorySet.class, new FieldSerializer<DefaultExternalSourceDirectorySet>(myKryo, DefaultExternalSourceDirectorySet.class) {
@Override
protected DefaultExternalSourceDirectorySet create(Kryo kryo, Input input, Class<DefaultExternalSourceDirectorySet> type) {
return new DefaultExternalSourceDirectorySet();
}
});
myKryo.register(DefaultExternalFilter.class, new FieldSerializer<DefaultExternalFilter>(myKryo, DefaultExternalFilter.class) {
@Override
protected DefaultExternalFilter create(Kryo kryo, Input input, Class<DefaultExternalFilter> type) {
return new DefaultExternalFilter();
}
});
myKryo.register(ExternalSystemSourceType.class, new DefaultSerializers.EnumSerializer(ExternalSystemSourceType.class));
myKryo.register(DefaultExternalProjectDependency.class, new FieldSerializer<DefaultExternalProjectDependency>(myKryo, DefaultExternalProjectDependency.class) {
@Override
protected DefaultExternalProjectDependency create(Kryo kryo, Input input, Class<DefaultExternalProjectDependency> type) {
return new DefaultExternalProjectDependency();
}
});
myKryo.register(DefaultFileCollectionDependency.class, new FieldSerializer<DefaultFileCollectionDependency>(myKryo, DefaultFileCollectionDependency.class) {
@Override
protected DefaultFileCollectionDependency create(Kryo kryo, Input input, Class<DefaultFileCollectionDependency> type) {
return new DefaultFileCollectionDependency();
}
});
myKryo.register(DefaultExternalLibraryDependency.class, new FieldSerializer<DefaultExternalLibraryDependency>(myKryo, DefaultExternalLibraryDependency.class) {
@Override
protected DefaultExternalLibraryDependency create(Kryo kryo, Input input, Class<DefaultExternalLibraryDependency> type) {
return new DefaultExternalLibraryDependency();
}
});
myKryo.register(DefaultUnresolvedExternalDependency.class, new FieldSerializer<DefaultUnresolvedExternalDependency>(myKryo, DefaultUnresolvedExternalDependency.class) {
@Override
protected DefaultUnresolvedExternalDependency create(Kryo kryo, Input input, Class<DefaultUnresolvedExternalDependency> type) {
return new DefaultUnresolvedExternalDependency();
}
});
myKryo.register(DefaultExternalDependencyId.class, new FieldSerializer<DefaultExternalDependencyId>(myKryo, DefaultExternalDependencyId.class) {
@Override
protected DefaultExternalDependencyId create(Kryo kryo, Input input, Class<DefaultExternalDependencyId> type) {
return new DefaultExternalDependencyId();
}
});
myKryo.register(LinkedHashSet.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new LinkedHashSet();
}
});
myKryo.register(HashSet.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new HashSet();
}
});
myKryo.register(THashSet.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new THashSet();
}
});
myKryo.register(Set.class, new CollectionSerializer() {
@Override
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
return new HashSet();
}
});
myKryo.register(THashMap.class, new MapSerializer() {
@Override
protected Map create(Kryo kryo, Input input, Class<Map> type) {
return new THashMap();
}
});
}
Aggregations