use of com.intellij.openapi.projectRoots.SdkAdditionalData in project intellij-community by JetBrains.
the class PythonCommandLineState method getAddedPaths.
public static List<String> getAddedPaths(Sdk pythonSdk) {
List<String> pathList = new ArrayList<>();
final SdkAdditionalData sdkAdditionalData = pythonSdk.getSdkAdditionalData();
if (sdkAdditionalData instanceof PythonSdkAdditionalData) {
final Set<VirtualFile> addedPaths = ((PythonSdkAdditionalData) sdkAdditionalData).getAddedPathFiles();
for (VirtualFile file : addedPaths) {
addToPythonPath(file, pathList);
}
}
return pathList;
}
use of com.intellij.openapi.projectRoots.SdkAdditionalData in project intellij-community by JetBrains.
the class PyRemotePackageManagerImpl method getPythonProcessOutput.
@NotNull
@Override
protected ProcessOutput getPythonProcessOutput(@NotNull String helperPath, @NotNull List<String> args, boolean askForSudo, boolean showProgress, @Nullable final String workingDir) throws ExecutionException {
final Sdk sdk = getSdk();
final String homePath = sdk.getHomePath();
if (homePath == null) {
throw new ExecutionException("Cannot find Python interpreter for SDK " + sdk.getName());
}
final SdkAdditionalData sdkData = sdk.getSdkAdditionalData();
if (sdkData instanceof PyRemoteSdkAdditionalDataBase) {
//remote interpreter
final PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
RemoteSdkCredentials remoteSdkCredentials;
if (CaseCollector.useRemoteCredentials((PyRemoteSdkAdditionalDataBase) sdkData)) {
try {
remoteSdkCredentials = ((RemoteSdkAdditionalData) sdkData).getRemoteSdkCredentials(false);
} catch (InterruptedException e) {
LOG.error(e);
remoteSdkCredentials = null;
} catch (ExecutionException e) {
throw analyzeException(e, helperPath, args);
}
if (manager != null && remoteSdkCredentials != null) {
if (askForSudo) {
askForSudo = !manager.ensureCanWrite(null, remoteSdkCredentials, remoteSdkCredentials.getInterpreterPath());
}
} else {
throw new PyExecutionException(PythonRemoteInterpreterManager.WEB_DEPLOYMENT_PLUGIN_IS_DISABLED, helperPath, args);
}
}
if (manager != null) {
final List<String> cmdline = new ArrayList<>();
cmdline.add(homePath);
cmdline.add(RemoteFile.detectSystemByPath(homePath).createRemoteFile(helperPath).getPath());
cmdline.addAll(Collections2.transform(args, new Function<String, String>() {
@Override
public String apply(@Nullable String input) {
return quoteIfNeeded(input);
}
}));
ProcessOutput processOutput;
do {
final PyRemoteSdkAdditionalDataBase remoteSdkAdditionalData = (PyRemoteSdkAdditionalDataBase) sdkData;
final PyRemotePathMapper pathMapper = manager.setupMappings(null, remoteSdkAdditionalData, null);
try {
processOutput = PyRemoteProcessStarterManagerUtil.getManager(remoteSdkAdditionalData).executeRemoteProcess(null, ArrayUtil.toStringArray(cmdline), workingDir, manager, remoteSdkAdditionalData, pathMapper, askForSudo, true);
} catch (InterruptedException e) {
throw new ExecutionException(e);
}
if (askForSudo && processOutput.getStderr().contains("sudo: 3 incorrect password attempts")) {
continue;
}
break;
} while (true);
return processOutput;
} else {
throw new PyExecutionException(PythonRemoteInterpreterManager.WEB_DEPLOYMENT_PLUGIN_IS_DISABLED, helperPath, args);
}
} else {
throw new PyExecutionException("Invalid remote SDK", helperPath, args);
}
}
use of com.intellij.openapi.projectRoots.SdkAdditionalData in project intellij-community by JetBrains.
the class PythonSdkDetailsStep method getVEnvCallback.
@NotNull
private AbstractCreateVirtualEnvDialog.VirtualEnvCallback getVEnvCallback() {
return new CreateVirtualEnvDialog.VirtualEnvCallback() {
@Override
public void virtualEnvCreated(Sdk sdk, boolean associateWithProject) {
if (associateWithProject) {
SdkAdditionalData additionalData = sdk.getSdkAdditionalData();
if (additionalData == null) {
additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(sdk.getHomePath()));
((ProjectJdkImpl) sdk).setSdkAdditionalData(additionalData);
}
if (myNewProject) {
((PythonSdkAdditionalData) additionalData).associateWithNewProject();
} else {
((PythonSdkAdditionalData) additionalData).associateWithProject(myProject);
}
}
mySdkAddedCallback.consume(sdk);
}
};
}
use of com.intellij.openapi.projectRoots.SdkAdditionalData in project android by JetBrains.
the class DependenciesModuleSetupStep method addExtraSdkLibrariesAsDependencies.
/**
* Sets the 'useLibrary' libraries or SDK add-ons as library dependencies.
* <p>
* These libraries are set at the project level, which makes it impossible to add them to a IDE SDK definition because the IDE SDK is
* global to the whole IDE. To work around this limitation, we set these libraries as module dependencies instead.
* </p>
*/
private void addExtraSdkLibrariesAsDependencies(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull AndroidProject androidProject) {
ModifiableRootModel moduleModel = modelsProvider.getModifiableRootModel(module);
Sdk sdk = moduleModel.getSdk();
// If we got here, SDK will *NOT* be null.
assert sdk != null;
String suffix = null;
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdk);
if (sdkData != null) {
SdkAdditionalData data = sdk.getSdkAdditionalData();
if (data instanceof AndroidSdkAdditionalData) {
AndroidSdkAdditionalData androidSdkData = (AndroidSdkAdditionalData) data;
suffix = androidSdkData.getBuildTargetHashString();
}
}
if (suffix == null) {
// In practice, we won't get here. A proper Android SDK has been already configured by now, and the suffix won't be null.
suffix = androidProject.getCompileTarget();
}
Set<String> currentIdeSdkFilePaths = Sets.newHashSetWithExpectedSize(5);
for (VirtualFile sdkFile : sdk.getRootProvider().getFiles(CLASSES)) {
// We need to convert the VirtualFile to java.io.File, because the path of the VirtualPath is using 'jar' protocol and it won't match
// the path returned by AndroidProject#getBootClasspath().
File sdkFilePath = virtualToIoFile(sdkFile);
currentIdeSdkFilePaths.add(sdkFilePath.getPath());
}
Collection<String> bootClasspath = androidProject.getBootClasspath();
for (String library : bootClasspath) {
if (isNotEmpty(library) && !currentIdeSdkFilePaths.contains(library)) {
// Library is not in the SDK IDE definition. Add it as library and make the module depend on it.
File binaryPath = new File(library);
String name = binaryPath.isFile() ? getNameWithoutExtension(binaryPath) : sanitizeFileName(library);
// Include compile target as part of the name, to ensure the library name is unique to this Android platform.
// e.g. maps-android-23, effects-android-23 (it follows the library naming convention: library-version
name = name + "-" + suffix;
myDependenciesSetup.setUpLibraryDependency(module, modelsProvider, name, COMPILE, binaryPath);
}
}
}
use of com.intellij.openapi.projectRoots.SdkAdditionalData in project android by JetBrains.
the class GradleSyncTest method sdkCreationForAddons.
// https://code.google.com/p/android/issues/detail?id=185313
@Test
public void sdkCreationForAddons() throws IOException {
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
Project project = ideFrame.getProject();
Module appModule = ideFrame.getModule("app");
GradleBuildFile buildFile = GradleBuildFile.get(appModule);
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
runWriteCommandAction(project, () -> buildFile.setValue(BuildFileKey.COMPILE_SDK_VERSION, "Google Inc.:Google APIs:24"));
}
});
ideFrame.requestProjectSync().waitForGradleProjectSyncToFinish();
Sdk sdk = ModuleRootManager.getInstance(appModule).getSdk();
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdk);
SdkAdditionalData data = sdk.getSdkAdditionalData();
assertThat(data).isInstanceOf(AndroidSdkAdditionalData.class);
AndroidSdkAdditionalData androidSdkData = (AndroidSdkAdditionalData) data;
IAndroidTarget buildTarget = androidSdkData.getBuildTarget(sdkData);
// By checking that there are no additional libraries in the SDK, we are verifying that an additional SDK was not created for add-ons.
assertThat(buildTarget.getAdditionalLibraries()).hasSize(0);
}
Aggregations