use of com.intellij.openapi.roots.CompilerProjectExtension in project intellij-community by JetBrains.
the class ArtifactUtil method getDefaultArtifactOutputPath.
@Nullable
public static String getDefaultArtifactOutputPath(@NotNull String artifactName, @NotNull final Project project) {
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(project);
if (extension == null)
return null;
String outputUrl = extension.getCompilerOutputUrl();
if (outputUrl == null || outputUrl.length() == 0) {
final VirtualFile baseDir = project.getBaseDir();
if (baseDir == null)
return null;
outputUrl = baseDir.getUrl() + "/out";
}
return VfsUtilCore.urlToPath(outputUrl) + "/artifacts/" + FileUtil.sanitizeFileName(artifactName);
}
use of com.intellij.openapi.roots.CompilerProjectExtension in project intellij-community by JetBrains.
the class ProjectOpenProcessorBase method doOpenProject.
@Nullable
public Project doOpenProject(@NotNull VirtualFile virtualFile, Project projectToClose, boolean forceOpenInNewFrame) {
try {
getBuilder().setUpdate(false);
final WizardContext wizardContext = new WizardContext(null);
if (virtualFile.isDirectory()) {
final String[] supported = getSupportedExtensions();
for (VirtualFile file : getFileChildren(virtualFile)) {
if (canOpenFile(file, supported)) {
virtualFile = file;
break;
}
}
}
wizardContext.setProjectFileDirectory(virtualFile.getParent().getPath());
if (!doQuickImport(virtualFile, wizardContext))
return null;
if (wizardContext.getProjectName() == null) {
if (wizardContext.getProjectStorageFormat() == StorageScheme.DEFAULT) {
wizardContext.setProjectName(IdeBundle.message("project.import.default.name", getName()) + ProjectFileType.DOT_DEFAULT_EXTENSION);
} else {
wizardContext.setProjectName(IdeBundle.message("project.import.default.name.dotIdea", getName()));
}
}
Project defaultProject = ProjectManager.getInstance().getDefaultProject();
Sdk jdk = ProjectRootManager.getInstance(defaultProject).getProjectSdk();
if (jdk == null) {
jdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(JavaSdk.getInstance());
}
wizardContext.setProjectJdk(jdk);
final String dotIdeaFilePath = wizardContext.getProjectFileDirectory() + File.separator + Project.DIRECTORY_STORE_FOLDER;
final String projectFilePath = wizardContext.getProjectFileDirectory() + File.separator + wizardContext.getProjectName() + ProjectFileType.DOT_DEFAULT_EXTENSION;
File dotIdeaFile = new File(dotIdeaFilePath);
File projectFile = new File(projectFilePath);
String pathToOpen;
if (wizardContext.getProjectStorageFormat() == StorageScheme.DEFAULT) {
pathToOpen = projectFilePath;
} else {
pathToOpen = dotIdeaFile.getParent();
}
boolean shouldOpenExisting = false;
boolean importToProject = true;
if (projectFile.exists() || dotIdeaFile.exists()) {
if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
shouldOpenExisting = true;
importToProject = true;
} else {
String existingName;
if (dotIdeaFile.exists()) {
existingName = "an existing project";
pathToOpen = dotIdeaFile.getParent();
} else {
existingName = "'" + projectFile.getName() + "'";
pathToOpen = projectFilePath;
}
int result = Messages.showYesNoCancelDialog(projectToClose, IdeBundle.message("project.import.open.existing", existingName, projectFile.getParent(), virtualFile.getName()), IdeBundle.message("title.open.project"), IdeBundle.message("project.import.open.existing.openExisting"), IdeBundle.message("project.import.open.existing.reimport"), CommonBundle.message("button.cancel"), Messages.getQuestionIcon());
if (result == Messages.CANCEL)
return null;
shouldOpenExisting = result == Messages.YES;
importToProject = !shouldOpenExisting;
}
}
final Project projectToOpen;
if (shouldOpenExisting) {
try {
projectToOpen = ProjectManagerEx.getInstanceEx().loadProject(pathToOpen);
} catch (Exception e) {
return null;
}
} else {
projectToOpen = ProjectManagerEx.getInstanceEx().newProject(wizardContext.getProjectName(), pathToOpen, true, false);
}
if (projectToOpen == null)
return null;
if (importToProject) {
if (!getBuilder().validate(projectToClose, projectToOpen)) {
return null;
}
projectToOpen.save();
ApplicationManager.getApplication().runWriteAction(() -> {
Sdk jdk1 = wizardContext.getProjectJdk();
if (jdk1 != null) {
NewProjectUtil.applyJdkToProject(projectToOpen, jdk1);
}
String projectDirPath = wizardContext.getProjectFileDirectory();
String path = StringUtil.endsWithChar(projectDirPath, '/') ? projectDirPath + "classes" : projectDirPath + "/classes";
CompilerProjectExtension extension = CompilerProjectExtension.getInstance(projectToOpen);
if (extension != null) {
extension.setCompilerOutputUrl(getUrl(path));
}
});
getBuilder().commit(projectToOpen, null, ModulesProvider.EMPTY_MODULES_PROVIDER);
}
if (!forceOpenInNewFrame) {
NewProjectUtil.closePreviousProject(projectToClose);
}
ProjectUtil.updateLastProjectLocation(pathToOpen);
ProjectManagerEx.getInstanceEx().openProject(projectToOpen);
return projectToOpen;
} finally {
getBuilder().cleanup();
}
}
use of com.intellij.openapi.roots.CompilerProjectExtension in project intellij-plugins by JetBrains.
the class OsgiRunConfigurationEditor method resetEditorFrom.
@Override
protected void resetEditorFrom(@NotNull OsgiRunConfiguration osgiRunConfiguration) {
myRunConfiguration = osgiRunConfiguration;
myVmOptions.setText(osgiRunConfiguration.getVmParameters());
myProgramParameters.setText(osgiRunConfiguration.getProgramParameters());
myFrameworkInstances.setSelectedItem(osgiRunConfiguration.getInstanceToUse());
myClassPathAllBundles.setSelected(osgiRunConfiguration.isIncludeAllBundlesInClassPath());
if (myCurrentRunPropertiesEditor != null) {
myCurrentRunPropertiesEditor.resetEditorFrom(osgiRunConfiguration);
}
// I deliberately set the list of modules as the last step here as
// the framework specific modules are cleaned out when you change the framework instance
// so the framework instance should be changed first
List<SelectedBundle> modules = osgiRunConfiguration.getBundlesToDeploy();
RunConfigurationTableModel model = getTableModel();
while (model.getRowCount() > 0) {
model.removeBundleAt(0);
}
for (SelectedBundle module : modules) {
model.addBundle(module);
}
myBundlesTable.getColumnModel().getColumn(1).setPreferredWidth(200);
myFrameworkStartLevel.setValue(osgiRunConfiguration.getFrameworkStartLevel());
myDefaultStartLevel.setValue(osgiRunConfiguration.getDefaultStartLevel());
boolean useUserDefinedFields = !osgiRunConfiguration.isGenerateWorkingDir();
myWorkingDirField.setText(osgiRunConfiguration.getWorkingDir());
if (myWorkingDirField.getText().length() == 0) {
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(myProject);
if (extension != null) {
final VirtualFilePointer outputDirPointer = extension.getCompilerOutputPointer();
if (outputDirPointer != null) {
myWorkingDirField.setText(VfsUtilCore.urlToPath(outputDirPointer.getUrl() + "/run.osgi/"));
}
}
}
myWorkingDirField.setEnabled(useUserDefinedFields);
myUserDefinedDir.setSelected(useUserDefinedFields);
myOsmorcControlledDir.setSelected(!useUserDefinedFields);
myJrePathEditor.setPathOrName(osgiRunConfiguration.getAlternativeJrePath(), osgiRunConfiguration.isUseAlternativeJre());
}
use of com.intellij.openapi.roots.CompilerProjectExtension in project android by JetBrains.
the class NewProjectSetupTest method verifyCompilerOutputUrl.
private void verifyCompilerOutputUrl() {
CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(getProject());
assertNotNull(compilerProjectExtension);
assertNotNull(compilerProjectExtension.getCompilerOutputUrl());
}
use of com.intellij.openapi.roots.CompilerProjectExtension in project android by JetBrains.
the class NewProjectSetupTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Project project = getProject();
LanguageLevelProjectExtension.getInstance(project).setLanguageLevel(JDK_1_6);
CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(project);
assertNotNull(compilerProjectExtension);
assertNull(compilerProjectExtension.getCompilerOutputUrl());
ProjectTypeService.setProjectType(project, null);
myNewProjectSetup = new NewProjectSetup();
}
Aggregations