mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
eclipse: store package prefix in .eml (IDEA-100086); jps: update content entries after .classpath was read to make sure test folders/package prefix set up correctly
This commit is contained in:
@@ -28,6 +28,8 @@ public interface IdeaXml {
|
||||
@NonNls String SOURCE_FOLDER_TAG = "sourceFolder";
|
||||
@NonNls String CONTENT_ENTRY_TAG = "contentEntry";
|
||||
@NonNls String TEST_FOLDER_TAG = "testFolder";
|
||||
@NonNls String PACKAGE_PREFIX_TAG = "packagePrefix";
|
||||
@NonNls String PACKAGE_PREFIX_VALUE_ATTR = "value";
|
||||
@NonNls String EXCLUDE_FOLDER_TAG = "excludeFolder";
|
||||
@NonNls String FOR_TESTS_ATTR = "forTests";
|
||||
@NonNls String TRUE_VALUE = "true";
|
||||
|
||||
+9
-5
@@ -35,6 +35,15 @@ public abstract class AbstractIdeaSpecificSettings<T, C, SdkType> {
|
||||
|
||||
setupCompilerOutputs(root, model);
|
||||
|
||||
updateEntries(root, model);
|
||||
|
||||
setupJdk(root, model, projectSdkType);
|
||||
setupLibraryRoots(root, model);
|
||||
overrideModulesScopes(root, model);
|
||||
readLibraryLevels(root, levels);
|
||||
}
|
||||
|
||||
public void updateEntries(Element root, T model) {
|
||||
final List entriesElements = root.getChildren(IdeaXml.CONTENT_ENTRY_TAG);
|
||||
if (!entriesElements.isEmpty()) {
|
||||
for (Object o : entriesElements) {
|
||||
@@ -46,11 +55,6 @@ public abstract class AbstractIdeaSpecificSettings<T, C, SdkType> {
|
||||
readContentEntry(root, entries[0], model);
|
||||
}
|
||||
}
|
||||
|
||||
setupJdk(root, model, projectSdkType);
|
||||
setupLibraryRoots(root, model);
|
||||
overrideModulesScopes(root, model);
|
||||
readLibraryLevels(root, levels);
|
||||
}
|
||||
|
||||
protected abstract void readLibraryLevels(Element root, Map<String, String> levels);
|
||||
|
||||
+11
-2
@@ -48,15 +48,24 @@ public class JpsEclipseClasspathSerializer extends JpsModuleClasspathSerializer
|
||||
final String eml = module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX;
|
||||
final File emlFile = new File(baseModulePath, eml);
|
||||
final Map<String, String> levels = new HashMap<String, String>();
|
||||
final JpsIdeaSpecificSettings settings;
|
||||
final Element root;
|
||||
if (emlFile.isFile()) {
|
||||
final Document emlDocument = JDOMUtil.loadDocument(emlFile);
|
||||
final Element root = emlDocument.getRootElement();
|
||||
new JpsIdeaSpecificSettings(expander).readIDEASpecific(root, module, projectSdkType, levels);
|
||||
root = emlDocument.getRootElement();
|
||||
settings = new JpsIdeaSpecificSettings(expander);
|
||||
settings.readIDEASpecific(root, module, projectSdkType, levels);
|
||||
} else {
|
||||
settings = null;
|
||||
root = null;
|
||||
}
|
||||
|
||||
final Document document = JDOMUtil.loadDocument(classpathFile);
|
||||
final JpsEclipseClasspathReader reader = new JpsEclipseClasspathReader(classpathDir, paths, new HashSet<String>(), levels);
|
||||
reader.readClasspath(module, null, document.getRootElement(), expander);//todo
|
||||
if (settings != null) {
|
||||
settings.updateEntries(root, module);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.info(e);
|
||||
|
||||
+13
@@ -24,6 +24,7 @@ import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.eclipse.IdeaXml;
|
||||
import org.jetbrains.idea.eclipse.conversion.AbstractIdeaSpecificSettings;
|
||||
import org.jetbrains.jps.model.JpsSimpleElement;
|
||||
import org.jetbrains.jps.model.java.*;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
|
||||
import org.jetbrains.jps.model.module.JpsDependenciesList;
|
||||
@@ -159,6 +160,18 @@ class JpsIdeaSpecificSettings extends AbstractIdeaSpecificSettings<JpsModule, St
|
||||
model.getExcludeRootsList().addUrl(excludeUrl);
|
||||
}
|
||||
}
|
||||
|
||||
for (Object o : root.getChildren(IdeaXml.PACKAGE_PREFIX_TAG)) {
|
||||
Element ppElement = (Element)o;
|
||||
final String prefix = ppElement.getAttributeValue(IdeaXml.PACKAGE_PREFIX_VALUE_ATTR);
|
||||
final String url = ppElement.getAttributeValue(IdeaXml.URL_ATTR);
|
||||
for (JpsModuleSourceRoot sourceRoot : model.getSourceRoots()) {
|
||||
if (Comparing.strEqual(sourceRoot.getUrl(), url)) {
|
||||
((JpsSimpleElement)sourceRoot.getProperties()).setData(new JavaSourceRootProperties(prefix));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static JpsJavaExtensionService getService() {
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -230,6 +231,18 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
entry.addSourceFolder(url, true);
|
||||
}
|
||||
|
||||
for (Object o : root.getChildren(IdeaXml.PACKAGE_PREFIX_TAG)) {
|
||||
Element ppElement = (Element)o;
|
||||
final String prefix = ppElement.getAttributeValue(IdeaXml.PACKAGE_PREFIX_VALUE_ATTR);
|
||||
final String url = ppElement.getAttributeValue(IdeaXml.URL_ATTR);
|
||||
for (SourceFolder folder : entry.getSourceFolders()) {
|
||||
if (Comparing.strEqual(folder.getUrl(), url)) {
|
||||
folder.setPackagePrefix(prefix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final String url = entry.getUrl();
|
||||
for (Object o : root.getChildren(IdeaXml.EXCLUDE_FOLDER_TAG)) {
|
||||
final String excludeUrl = ((Element)o).getAttributeValue(IdeaXml.URL_ATTR);
|
||||
@@ -278,6 +291,14 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
element.setAttribute(IdeaXml.URL_ATTR, sourceFolder.getUrl());
|
||||
isModified = true;
|
||||
}
|
||||
final String packagePrefix = sourceFolder.getPackagePrefix();
|
||||
if (!StringUtil.isEmptyOrSpaces(packagePrefix)) {
|
||||
Element element = new Element(IdeaXml.PACKAGE_PREFIX_TAG);
|
||||
contentEntryElement.addContent(element);
|
||||
element.setAttribute(IdeaXml.URL_ATTR, sourceFolder.getUrl());
|
||||
element.setAttribute(IdeaXml.PACKAGE_PREFIX_VALUE_ATTR, packagePrefix);
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
final VirtualFile entryFile = entry.getFile();
|
||||
|
||||
Reference in New Issue
Block a user