External project storage — JPS support libraries

This commit is contained in:
Vladimir Krivosheev
2017-05-29 15:19:32 +02:00
parent a23f2a431a
commit 135eee942e
3 changed files with 22 additions and 5 deletions

View File

@@ -1141,7 +1141,7 @@ public class BuildManager implements Disposable {
}
if (StreamProviderKt.isExternalStorageEnabled()) {
cmdLine.addParameter("-Dexternal.project.config=" + ProjectUtil.getExternalConfigurationDir(project));
cmdLine.addParameter("-D" + GlobalOptions.EXTERNAL_PROJECT_CONFIG + "=" + ProjectUtil.getExternalConfigurationDir(project));
}
final String shouldGenerateIndex = System.getProperty(GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,4 +38,9 @@ public interface GlobalOptions {
String JPS_SYSTEM_BUILDER_ID = "JPS";
// notification about the files changed during compilation, but not compiled in current compilation session
String JPS_UNPROCESSED_FS_CHANGES_MESSAGE_ID = "!unprocessed_fs_changes_detected!";
/**
* The path to external project config directory (used for external system projects).
*/
String EXTERNAL_PROJECT_CONFIG = "external.project.config";
}

View File

@@ -130,6 +130,13 @@ public class JpsProjectLoader extends JpsLoaderBase {
for (Path libraryFile : listXmlFiles(dir.resolve("libraries"))) {
loadProjectLibraries(loadRootElement(libraryFile));
}
Path externalConfigDir = resolveExternalProjectConfig("project");
if (externalConfigDir != null) {
LOG.info("External project config dir is used: " + externalConfigDir);
loadProjectLibraries(loadRootElement(externalConfigDir.resolve("libraries.xml")));
}
timingLog.run();
Runnable artifactsTimingLog = TimingLog.startActivity("loading artifacts");
@@ -245,15 +252,20 @@ public class JpsProjectLoader extends JpsLoaderBase {
timingLog.run();
}
@Nullable
private static Path resolveExternalProjectConfig(@NotNull String subDirName) {
String externalProjectConfigDir = System.getProperty("external.project.config");
return StringUtil.isEmptyOrSpaces(externalProjectConfigDir) ? null : Paths.get(externalProjectConfigDir, subDirName);
}
@NotNull
public static List<JpsModule> loadModules(@NotNull List<Path> moduleFiles, @Nullable final JpsSdkType<?> projectSdkType,
@NotNull final Map<String, String> pathVariables) {
List<JpsModule> modules = new ArrayList<>();
List<Future<Pair<Path, Element>>> futureModuleFilesContents = new ArrayList<>();
String externalProjectConfigDir = System.getProperty("external.project.config");
Path externalModuleDir = StringUtil.isEmptyOrSpaces(externalProjectConfigDir) ? null : Paths.get(externalProjectConfigDir, "modules");
Path externalModuleDir = resolveExternalProjectConfig("modules");
if (externalModuleDir != null) {
LOG.info("External project config dir is used: " + externalProjectConfigDir);
LOG.info("External project config dir is used for modules: " + externalModuleDir);
}
for (Path file : moduleFiles) {