mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
project model: distinguish libraries imported from external models
This information can be used to show a warning if user tries to manually change roots of a library imported from an external model in the Project Structure dialog (IDEA-171948). This information won't be saved in library configuration files until we implement functionality to store such libraries separately (and enable 'store.imported.project.elements.separately' registry key), because otherwise it would lead to massive changes in files under .idea/libraries.
This commit is contained in:
+8
-2
@@ -17,6 +17,7 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.projectRoot;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryImpl;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
@@ -62,8 +63,13 @@ public class LibrariesModifiableModel implements LibraryTableBase.ModifiableMode
|
||||
|
||||
@Override
|
||||
public Library createLibrary(String name, @Nullable PersistentLibraryKind type) {
|
||||
final Library library = getLibrariesModifiableModel().createLibrary(name, type);
|
||||
//createLibraryEditor(library); \
|
||||
return createLibrary(name, type, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Library createLibrary(String name, @Nullable PersistentLibraryKind type, @Nullable ProjectModelExternalSource externalSource) {
|
||||
final Library library = getLibrariesModifiableModel().createLibrary(name, type, externalSource);
|
||||
//createLibraryEditor(library);
|
||||
final BaseLibrariesConfigurable configurable = ProjectStructureConfigurable.getInstance(myProject).getConfigurableFor(library);
|
||||
configurable.createLibraryNode(library);
|
||||
return library;
|
||||
|
||||
+3
@@ -21,6 +21,7 @@ import com.intellij.openapi.externalSystem.model.project.ModuleData;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.packaging.artifacts.ModifiableArtifactModel;
|
||||
@@ -59,6 +60,8 @@ public interface IdeModifiableModelsProvider extends IdeModelsProvider {
|
||||
|
||||
Library createLibrary(String name);
|
||||
|
||||
Library createLibrary(String name, @Nullable ProjectModelExternalSource externalSource);
|
||||
|
||||
void removeLibrary(Library library);
|
||||
|
||||
ModalityState getModalityStateForQuestionDialogs();
|
||||
|
||||
+6
@@ -37,8 +37,10 @@ import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ExternalProjectSystemRegistry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
@@ -794,6 +796,10 @@ public class ExternalSystemApiUtil {
|
||||
return (T)loader.loadClass(clazz.getName()).newInstance();
|
||||
}
|
||||
|
||||
public static ProjectModelExternalSource toExternalSource(@NotNull ProjectSystemId systemId) {
|
||||
return ExternalProjectSystemRegistry.getInstance().getSourceById(systemId.getId());
|
||||
}
|
||||
|
||||
@Contract(value = "_, null -> false", pure=true)
|
||||
public static boolean isExternalSystemAwareModule(@NotNull ProjectSystemId systemId, @Nullable Module module) {
|
||||
return module != null && !module.isDisposed() && systemId.getId().equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY));
|
||||
|
||||
+5
@@ -236,6 +236,11 @@ public abstract class AbstractIdeModifiableModelsProvider extends IdeModelsProvi
|
||||
return getModifiableProjectLibrariesModel().createLibrary(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Library createLibrary(String name, @Nullable ProjectModelExternalSource externalSource) {
|
||||
return getModifiableProjectLibrariesModel().createLibrary(name, null, externalSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLibrary(Library library) {
|
||||
getModifiableProjectLibrariesModel().removeLibrary(library);
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public class LibraryDataService extends AbstractProjectDataService<LibraryData,
|
||||
syncPaths(toImport, library, modelsProvider);
|
||||
return;
|
||||
}
|
||||
library = modelsProvider.createLibrary(libraryName);
|
||||
library = modelsProvider.createLibrary(libraryName, ExternalSystemApiUtil.toExternalSource(toImport.getOwner()));
|
||||
final Library.ModifiableModel libraryModel = modelsProvider.getModifiableLibraryModel(library);
|
||||
registerPaths(toImport.isUnresolved(), libraryFiles, libraryModel, libraryName);
|
||||
}
|
||||
|
||||
+27
-4
@@ -39,14 +39,37 @@ public class ExternalProjectSystemRegistryImpl implements ExternalProjectSystemR
|
||||
return getSourceById(externalSystemId);
|
||||
}
|
||||
if ("true".equals(module.getOptionValue(IS_MAVEN_MODULE_KEY))) {
|
||||
return getSourceById("Maven");
|
||||
return getSourceById(MAVEN_EXTERNAL_SOURCE_ID);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
private ProjectModelExternalSource getSourceById(String id) {
|
||||
//todo[nik] specify display name explicitly instead, the current code is copied from ProjectSystemId constructor
|
||||
return myExternalSources.computeIfAbsent(id, (sourceId) -> () -> StringUtil.capitalize(sourceId.toLowerCase(Locale.US)));
|
||||
public ProjectModelExternalSource getSourceById(String id) {
|
||||
return myExternalSources.computeIfAbsent(id, ProjectModelExternalSourceImpl::new);
|
||||
}
|
||||
|
||||
private static class ProjectModelExternalSourceImpl implements ProjectModelExternalSource {
|
||||
private final String myId;
|
||||
private final String myDisplayName;
|
||||
|
||||
public ProjectModelExternalSourceImpl(String id) {
|
||||
myId = id;
|
||||
//todo[nik] specify display name explicitly instead, the current code is copied from ProjectSystemId constructor
|
||||
myDisplayName = StringUtil.capitalize(myId.toLowerCase(Locale.US));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return myDisplayName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getId() {
|
||||
return myId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -29,9 +30,16 @@ public interface ExternalProjectSystemRegistry {
|
||||
return ServiceManager.getService(ExternalProjectSystemRegistry.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
ProjectModelExternalSource getSourceById(String id);
|
||||
|
||||
@Nullable
|
||||
ProjectModelExternalSource getExternalSource(Module module);
|
||||
|
||||
/**
|
||||
* These fields are temporary added to API until we have proper extension points for different external systems.
|
||||
*/
|
||||
String MAVEN_EXTERNAL_SOURCE_ID = "Maven";
|
||||
String EXTERNAL_SYSTEM_ID_KEY = "external.system.id";
|
||||
String IS_MAVEN_MODULE_KEY = "org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule";
|
||||
}
|
||||
|
||||
+3
@@ -28,4 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface ProjectModelExternalSource {
|
||||
@NotNull
|
||||
String getDisplayName();
|
||||
|
||||
@NotNull
|
||||
String getId();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.roots.libraries;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ProjectModelElement;
|
||||
import com.intellij.openapi.roots.RootProvider;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -27,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public interface Library extends JDOMExternalizable, Disposable {
|
||||
public interface Library extends JDOMExternalizable, Disposable, ProjectModelElement {
|
||||
Library[] EMPTY_ARRAY = new Library[0];
|
||||
|
||||
@Nullable String getName();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.roots.libraries;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -71,6 +72,8 @@ public interface LibraryTable {
|
||||
|
||||
Library createLibrary(String name, @Nullable PersistentLibraryKind type);
|
||||
|
||||
Library createLibrary(String name, @Nullable PersistentLibraryKind type, @Nullable ProjectModelExternalSource externalSource);
|
||||
|
||||
void removeLibrary(@NotNull Library library);
|
||||
|
||||
void commit();
|
||||
|
||||
+3
-2
@@ -55,9 +55,10 @@ public class ModuleLibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl imple
|
||||
myScope = scope;
|
||||
}
|
||||
|
||||
ModuleLibraryOrderEntryImpl(String name, final PersistentLibraryKind kind, @NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl projectRootManager) {
|
||||
ModuleLibraryOrderEntryImpl(String name, final PersistentLibraryKind kind, @NotNull RootModelImpl rootModel,
|
||||
@NotNull ProjectRootManagerImpl projectRootManager, ProjectModelExternalSource externalSource) {
|
||||
super(rootModel, projectRootManager);
|
||||
myLibrary = LibraryTableImplUtil.createModuleLevelLibrary(name, kind, getRootModel());
|
||||
myLibrary = LibraryTableImplUtil.createModuleLevelLibrary(name, kind, getRootModel(), externalSource);
|
||||
doinit();
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -21,6 +21,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
@@ -90,8 +91,13 @@ public class ModuleLibraryTable implements LibraryTable, LibraryTableBase.Modifi
|
||||
}
|
||||
|
||||
@Override
|
||||
public Library createLibrary(String name, @Nullable PersistentLibraryKind kind) {
|
||||
LibraryOrderEntry orderEntry = new ModuleLibraryOrderEntryImpl(name, kind, myRootModel, myProjectRootManager);
|
||||
public Library createLibrary(String name, @Nullable PersistentLibraryKind type) {
|
||||
return createLibrary(name, type, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Library createLibrary(String name, @Nullable PersistentLibraryKind kind, @Nullable ProjectModelExternalSource externalSource) {
|
||||
LibraryOrderEntry orderEntry = new ModuleLibraryOrderEntryImpl(name, kind, myRootModel, myProjectRootManager, externalSource);
|
||||
myRootModel.addOrderEntry(orderEntry);
|
||||
return orderEntry.getLibrary();
|
||||
}
|
||||
|
||||
+30
-8
@@ -20,13 +20,12 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ComponentSerializationUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.RootProvider;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.impl.RootModelImpl;
|
||||
import com.intellij.openapi.roots.impl.RootProviderBaseImpl;
|
||||
import com.intellij.openapi.roots.libraries.*;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.StandardFileSystems;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -64,6 +63,7 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi
|
||||
@NonNls public static final String PROPERTIES_ELEMENT = "properties";
|
||||
private static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters();
|
||||
private static final String EXCLUDED_ROOTS_TAG = "excluded";
|
||||
private static final String EXTERNAL_SYSTEM_ID_ATTRIBUTE = "external-system-id";
|
||||
private String myName;
|
||||
private final LibraryTable myLibraryTable;
|
||||
private final Map<OrderRootType, VirtualFilePointerContainer> myRoots;
|
||||
@@ -78,15 +78,22 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi
|
||||
private boolean myDisposed;
|
||||
private final Disposable myPointersDisposable = Disposer.newDisposable();
|
||||
private final JarDirectoryWatcher myRootsWatcher = JarDirectoryWatcherFactory.getInstance().createWatcher(myJarDirectories, myRootProvider);
|
||||
private final ProjectModelExternalSource myExternalSource;
|
||||
|
||||
LibraryImpl(LibraryTable table, @NotNull Element element, ModifiableRootModel rootModel) throws InvalidDataException {
|
||||
this(table, rootModel, null, element.getAttributeValue(LIBRARY_NAME_ATTR), findPersistentLibraryKind(element));
|
||||
this(table, rootModel, null, element.getAttributeValue(LIBRARY_NAME_ATTR), findPersistentLibraryKind(element), findExternalSource(element));
|
||||
readProperties(element);
|
||||
myJarDirectories.readExternal(element);
|
||||
readRoots(element);
|
||||
myRootsWatcher.updateWatchedRoots();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ProjectModelExternalSource findExternalSource(Element element) {
|
||||
@Nullable String externalSourceId = element.getAttributeValue(EXTERNAL_SYSTEM_ID_ATTRIBUTE);
|
||||
return externalSourceId != null ? ExternalProjectSystemRegistry.getInstance().getSourceById(externalSourceId) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PersistentLibraryKind<?> findPersistentLibraryKind(@NotNull Element element) {
|
||||
String typeString = element.getAttributeValue(LIBRARY_TYPE_ATTR);
|
||||
@@ -98,15 +105,16 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi
|
||||
return (PersistentLibraryKind<?>)kind;
|
||||
}
|
||||
|
||||
LibraryImpl(String name, @Nullable final PersistentLibraryKind<?> kind, LibraryTable table, ModifiableRootModel rootModel) {
|
||||
this(table, rootModel, null, name, kind);
|
||||
LibraryImpl(String name, @Nullable final PersistentLibraryKind<?> kind, LibraryTable table, ModifiableRootModel rootModel,
|
||||
ProjectModelExternalSource externalSource) {
|
||||
this(table, rootModel, null, name, kind, externalSource);
|
||||
if (kind != null) {
|
||||
myProperties = kind.createDefaultProperties();
|
||||
}
|
||||
}
|
||||
|
||||
private LibraryImpl(@NotNull LibraryImpl from, LibraryImpl newSource, ModifiableRootModel rootModel) {
|
||||
this(from.myLibraryTable, rootModel, newSource, from.myName, from.myKind);
|
||||
this(from.myLibraryTable, rootModel, newSource, from.myName, from.myKind, from.myExternalSource);
|
||||
from.checkDisposed();
|
||||
|
||||
if (from.myKind != null && from.myProperties != null) {
|
||||
@@ -126,13 +134,15 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi
|
||||
}
|
||||
|
||||
// primary
|
||||
private LibraryImpl(LibraryTable table, ModifiableRootModel rootModel, LibraryImpl newSource, String name, @Nullable final PersistentLibraryKind<?> kind) {
|
||||
private LibraryImpl(LibraryTable table, ModifiableRootModel rootModel, LibraryImpl newSource, String name,
|
||||
@Nullable final PersistentLibraryKind<?> kind, @Nullable ProjectModelExternalSource externalSource) {
|
||||
super(true);
|
||||
myLibraryTable = table;
|
||||
myRootModel = rootModel;
|
||||
mySource = newSource;
|
||||
myKind = kind;
|
||||
myName = name;
|
||||
myExternalSource = externalSource;
|
||||
//init roots depends on my myKind
|
||||
myRoots = initRoots();
|
||||
Disposer.register(this, myRootsWatcher);
|
||||
@@ -279,6 +289,12 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ProjectModelExternalSource getExternalSource() {
|
||||
return myExternalSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
readName(element);
|
||||
@@ -355,6 +371,12 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (myExternalSource != null && Registry.is("store.imported.project.elements.separately")) {
|
||||
//we can add this attribute only if the library configuration will be stored separately, otherwise we will get modified files in .idea/libraries.
|
||||
element.setAttribute(EXTERNAL_SYSTEM_ID_ATTRIBUTE, myExternalSource.getId());
|
||||
}
|
||||
|
||||
ArrayList<OrderRootType> storableRootTypes = new ArrayList<>();
|
||||
storableRootTypes.addAll(Arrays.asList(OrderRootType.getAllTypes()));
|
||||
if (myKind != null) {
|
||||
|
||||
+8
-2
@@ -22,6 +22,7 @@ import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.PersistentLibraryKind;
|
||||
@@ -268,7 +269,7 @@ public abstract class LibraryTableBase implements PersistentStateComponent<Eleme
|
||||
@NonNls final String libraryPrefix = "library.";
|
||||
final String libPath = System.getProperty(libraryPrefix + name);
|
||||
if (libPath != null) {
|
||||
final LibraryImpl libraryFromProperty = new LibraryImpl(name, null, LibraryTableBase.this, null);
|
||||
final LibraryImpl libraryFromProperty = new LibraryImpl(name, null, LibraryTableBase.this, null, null);
|
||||
libraryFromProperty.addRoot(libPath, OrderRootType.CLASSES);
|
||||
return libraryFromProperty;
|
||||
}
|
||||
@@ -293,8 +294,13 @@ public abstract class LibraryTableBase implements PersistentStateComponent<Eleme
|
||||
|
||||
@Override
|
||||
public Library createLibrary(String name, @Nullable PersistentLibraryKind kind) {
|
||||
return createLibrary(name, kind, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Library createLibrary(String name, @Nullable PersistentLibraryKind kind, @Nullable ProjectModelExternalSource externalSource) {
|
||||
assertWritable();
|
||||
final LibraryImpl library = new LibraryImpl(name, kind, LibraryTableBase.this, null);
|
||||
final LibraryImpl library = new LibraryImpl(name, kind, LibraryTableBase.this, null, externalSource);
|
||||
myLibraries.add(library);
|
||||
myLibraryByNameCache = null;
|
||||
return library;
|
||||
|
||||
+4
-4
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.openapi.roots.impl.libraries;
|
||||
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource;
|
||||
import com.intellij.openapi.roots.impl.RootModelImpl;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.PersistentLibraryKind;
|
||||
@@ -45,9 +46,8 @@ public class LibraryTableImplUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Library createModuleLevelLibrary(@Nullable String name,
|
||||
PersistentLibraryKind kind,
|
||||
@NotNull RootModelImpl rootModel) {
|
||||
return new LibraryImpl(name, kind, null, rootModel);
|
||||
public static Library createModuleLevelLibrary(@Nullable String name, PersistentLibraryKind kind, @NotNull RootModelImpl rootModel,
|
||||
@Nullable ProjectModelExternalSource externalSource) {
|
||||
return new LibraryImpl(name, kind, null, rootModel, externalSource);
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -16,6 +16,7 @@
|
||||
package com.intellij.project.model.impl.library;
|
||||
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource;
|
||||
import com.intellij.openapi.roots.RootProvider;
|
||||
import com.intellij.openapi.roots.impl.RootProviderBaseImpl;
|
||||
import com.intellij.openapi.roots.impl.libraries.JarDirectories;
|
||||
@@ -34,6 +35,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryRoot;
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType;
|
||||
@@ -132,6 +134,12 @@ public class JpsLibraryDelegate implements LibraryEx {
|
||||
return myRootProvider;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ProjectModelExternalSource getExternalSource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
+6
@@ -16,6 +16,7 @@
|
||||
package com.intellij.project.model.impl.library;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
@@ -142,6 +143,11 @@ public class JpsLibraryTableImpl implements LibraryTable, Disposable {
|
||||
|
||||
@Override
|
||||
public Library createLibrary(String name, @Nullable PersistentLibraryKind type) {
|
||||
return createLibrary(name, type, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Library createLibrary(String name, @Nullable PersistentLibraryKind type, @Nullable ProjectModelExternalSource externalSource) {
|
||||
throw new UnsupportedOperationException("'createLibrary' not implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -1041,6 +1041,10 @@ store.basedir.parent.detection=true
|
||||
store.save.use.modificationCount=true
|
||||
store.track.module.root.manager.changes=false
|
||||
|
||||
store.imported.project.elements.separately=false
|
||||
store.imported.project.elements.separately.description=Store configuration files for parts of project (modules/libraries/artifacts) which were\
|
||||
automatically created by IDE during importing from Maven/Gradle separately from regular configuration files in .idea directory (https://youtrack.jetbrains.com/issue/IDEA-171877)
|
||||
|
||||
ide.ui.composite.editor.for.combobox.description=Allows to use composite components based on JPanel as a ComboBox editor
|
||||
ide.ui.composite.editor.for.combobox=true
|
||||
|
||||
|
||||
+1
-1
@@ -322,7 +322,7 @@ public class MavenModuleImporter {
|
||||
|
||||
Library library = myModifiableModelsProvider.getLibraryByName(libraryName);
|
||||
if (library == null) {
|
||||
library = myModifiableModelsProvider.createLibrary(libraryName);
|
||||
library = myModifiableModelsProvider.createLibrary(libraryName, MavenRootModelAdapter.getMavenExternalSource());
|
||||
}
|
||||
libraryModel = myModifiableModelsProvider.getModifiableLibraryModel(library);
|
||||
|
||||
|
||||
+5
-2
@@ -33,7 +33,6 @@ import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.util.Processor;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -338,7 +337,7 @@ public class MavenRootModelAdapter {
|
||||
|
||||
Library library = provider.getLibraryByName(libraryName);
|
||||
if (library == null) {
|
||||
library = provider.createLibrary(libraryName);
|
||||
library = provider.createLibrary(libraryName, getMavenExternalSource());
|
||||
}
|
||||
Library.ModifiableModel libraryModel = provider.getModifiableLibraryModel(library);
|
||||
|
||||
@@ -457,6 +456,10 @@ public class MavenRootModelAdapter {
|
||||
return library != null && MavenArtifact.isMavenLibrary(library.getName());
|
||||
}
|
||||
|
||||
public static ProjectModelExternalSource getMavenExternalSource() {
|
||||
return ExternalProjectSystemRegistry.getInstance().getSourceById(ExternalProjectSystemRegistry.MAVEN_EXTERNAL_SOURCE_ID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static OrderEntry findLibraryEntry(@NotNull Module m, @NotNull MavenArtifact artifact) {
|
||||
String name = artifact.getLibraryName();
|
||||
|
||||
Reference in New Issue
Block a user