mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
reduce dir.resolve for default config files
This commit is contained in:
@@ -55,7 +55,7 @@ public class JpsGlobalLoader extends JpsLoaderBase {
|
||||
|
||||
public static void loadGlobalSettings(JpsGlobal global, String optionsPath) throws IOException {
|
||||
Path optionsDir = Paths.get(FileUtil.toCanonicalPath(optionsPath));
|
||||
new JpsGlobalLoader(global, Collections.emptyMap()).loadGlobalComponents(optionsDir, new PathVariablesSerializer());
|
||||
new JpsGlobalLoader(global, Collections.emptyMap()).loadGlobalComponents(optionsDir, optionsDir.resolve("other.xml"), new PathVariablesSerializer());
|
||||
Map<String, String> pathVariables = JpsModelSerializationDataService.computeAllPathVariables(global);
|
||||
new JpsGlobalLoader(global, pathVariables).load(optionsDir);
|
||||
}
|
||||
@@ -69,19 +69,20 @@ public class JpsGlobalLoader extends JpsLoaderBase {
|
||||
}
|
||||
|
||||
private void load(@NotNull Path optionsDir) {
|
||||
Path defaultConfigFile = optionsDir.resolve("other.xml");
|
||||
LOG.debug("Loading config from " + optionsDir.toAbsolutePath());
|
||||
for (JpsGlobalExtensionSerializer serializer : SERIALIZERS) {
|
||||
loadGlobalComponents(optionsDir, serializer);
|
||||
loadGlobalComponents(optionsDir, defaultConfigFile, serializer);
|
||||
}
|
||||
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
|
||||
for (JpsGlobalExtensionSerializer serializer : extension.getGlobalExtensionSerializers()) {
|
||||
loadGlobalComponents(optionsDir, serializer);
|
||||
loadGlobalComponents(optionsDir, defaultConfigFile, serializer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadGlobalComponents(@NotNull Path optionsDir, JpsGlobalExtensionSerializer serializer) {
|
||||
loadComponents(optionsDir, "other.xml", serializer, myGlobal);
|
||||
private void loadGlobalComponents(@NotNull Path optionsDir, @NotNull Path defaultConfigFile, JpsGlobalExtensionSerializer serializer) {
|
||||
loadComponents(optionsDir, defaultConfigFile.getParent(), serializer, myGlobal);
|
||||
}
|
||||
|
||||
public static class PathVariablesSerializer extends JpsGlobalExtensionSerializer {
|
||||
|
||||
@@ -51,11 +51,11 @@ public abstract class JpsLoaderBase {
|
||||
}
|
||||
|
||||
protected <E extends JpsElement> void loadComponents(@NotNull Path dir,
|
||||
final String defaultFileName,
|
||||
@NotNull Path defaultConfigFile,
|
||||
JpsElementExtensionSerializerBase<E> serializer,
|
||||
final E element) {
|
||||
String fileName = serializer.getConfigFileName();
|
||||
Path configFile = dir.resolve(fileName != null ? fileName : defaultFileName);
|
||||
Path configFile = fileName == null ? defaultConfigFile : dir.resolve(fileName);
|
||||
Runnable timingLog = TimingLog.startActivity("loading: " + configFile.getFileName() + ":" + serializer.getComponentName());
|
||||
Element componentTag = JDomSerializationUtil.findComponent(loadRootElement(configFile), serializer.getComponentName());
|
||||
if (componentTag != null) {
|
||||
|
||||
@@ -117,10 +117,11 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
|
||||
private void loadFromDirectory(@NotNull Path dir) {
|
||||
myProject.setName(getDirectoryBaseProjectName(dir));
|
||||
JpsSdkType<?> projectSdkType = loadProjectRoot(loadRootElement(dir.resolve("misc.xml")));
|
||||
Path defaultConfigFile = dir.resolve("misc.xml");
|
||||
JpsSdkType<?> projectSdkType = loadProjectRoot(loadRootElement(defaultConfigFile));
|
||||
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
|
||||
for (JpsProjectExtensionSerializer serializer : extension.getProjectExtensionSerializers()) {
|
||||
loadComponents(dir, "misc.xml", serializer, myProject);
|
||||
loadComponents(dir, defaultConfigFile, serializer, myProject);
|
||||
}
|
||||
}
|
||||
loadModules(loadRootElement(dir.resolve("modules.xml")), projectSdkType);
|
||||
|
||||
Reference in New Issue
Block a user