use of com.intellij.pom.java.LanguageLevel in project intellij-plugins by JetBrains.
the class BndProjectImporter method setupProject.
public void setupProject() {
LanguageLevel sourceLevel = LanguageLevel.parse(myWorkspace.getProperty(JAVAC_SOURCE));
if (sourceLevel != null) {
LanguageLevelProjectExtension.getInstance(myProject).setLanguageLevel(sourceLevel);
}
String targetLevel = myWorkspace.getProperty(JAVAC_TARGET);
CompilerConfiguration.getInstance(myProject).setProjectBytecodeTarget(targetLevel);
// compilation options (see Project#getCommonJavac())
JpsJavaCompilerOptions javacOptions = JavacConfiguration.getOptions(myProject, JavacConfiguration.class);
javacOptions.DEBUGGING_INFO = booleanProperty(myWorkspace.getProperty("javac.debug", "true"));
javacOptions.DEPRECATION = booleanProperty(myWorkspace.getProperty("java.deprecation"));
javacOptions.ADDITIONAL_OPTIONS_STRING = myWorkspace.getProperty("java.options", "");
}
use of com.intellij.pom.java.LanguageLevel in project intellij-plugins by JetBrains.
the class BndProjectImporter method createModule.
private ModifiableRootModel createModule(ModifiableModuleModel moduleModel, Project project, LanguageLevel projectLevel) throws Exception {
String name = project.getName();
Module module = moduleModel.findModuleByName(name);
if (module == null) {
String path = project.getBase().getPath() + File.separator + name + ModuleFileType.DOT_DEFAULT_EXTENSION;
module = moduleModel.newModule(path, StdModuleTypes.JAVA.getId());
}
ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
for (ContentEntry entry : rootModel.getContentEntries()) {
rootModel.removeContentEntry(entry);
}
for (OrderEntry entry : rootModel.getOrderEntries()) {
if (!(entry instanceof ModuleJdkOrderEntry || entry instanceof ModuleSourceOrderEntry)) {
rootModel.removeOrderEntry(entry);
}
}
rootModel.inheritSdk();
ContentEntry contentEntry = rootModel.addContentEntry(url(project.getBase()));
for (File src : project.getSourcePath()) {
contentEntry.addSourceFolder(url(src), false);
}
File testSrc = project.getTestSrc();
if (testSrc != null) {
contentEntry.addSourceFolder(url(testSrc), true);
}
contentEntry.addExcludeFolder(url(project.getTarget()));
LanguageLevel sourceLevel = LanguageLevel.parse(project.getProperty(JAVAC_SOURCE));
if (sourceLevel == projectLevel)
sourceLevel = null;
rootModel.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(sourceLevel);
CompilerModuleExtension compilerExt = rootModel.getModuleExtension(CompilerModuleExtension.class);
compilerExt.inheritCompilerOutputPath(false);
compilerExt.setExcludeOutput(true);
compilerExt.setCompilerOutputPath(url(project.getSrcOutput()));
compilerExt.setCompilerOutputPathForTests(url(project.getTestOutput()));
String targetLevel = project.getProperty(JAVAC_TARGET);
CompilerConfiguration.getInstance(myProject).setBytecodeTargetLevel(module, targetLevel);
OsmorcFacet facet = OsmorcFacet.getInstance(module);
if (project.isNoBundles() && facet != null) {
FacetUtil.deleteFacet(facet);
facet = null;
} else if (!project.isNoBundles() && facet == null) {
facet = FacetUtil.addFacet(module, OsmorcFacetType.getInstance());
}
if (facet != null) {
OsmorcFacetConfiguration facetConfig = facet.getConfiguration();
facetConfig.setManifestGenerationMode(ManifestGenerationMode.Bnd);
facetConfig.setBndFileLocation(FileUtil.getRelativePath(path(project.getBase()), path(project.getPropertiesFile()), '/'));
Map.Entry<String, Attrs> bsn = project.getBundleSymbolicName();
File bundle = project.getOutputFile(bsn != null ? bsn.getKey() : name, project.getBundleVersion());
facetConfig.setJarFileLocation(path(bundle), OutputPathType.SpecificOutputPath);
facetConfig.setDoNotSynchronizeWithMaven(true);
}
return rootModel;
}
use of com.intellij.pom.java.LanguageLevel in project intellij-plugins by JetBrains.
the class BndProjectImporter method createProjectStructure.
private void createProjectStructure() {
if (myProject.isDisposed()) {
return;
}
ApplicationManager.getApplication().runWriteAction(() -> {
LanguageLevel projectLevel = LanguageLevelProjectExtension.getInstance(myProject).getLanguageLevel();
Map<Project, ModifiableRootModel> rootModels = ContainerUtil.newHashMap();
ModifiableModuleModel moduleModel = ModuleManager.getInstance(myProject).getModifiableModel();
LibraryTable.ModifiableModel libraryModel = ProjectLibraryTable.getInstance(myProject).getModifiableModel();
try {
for (Project project : myProjects) {
try {
rootModels.put(project, createModule(moduleModel, project, projectLevel));
} catch (Exception e) {
// should not happen, since project.prepare() is already called
LOG.error(e);
}
}
for (Project project : myProjects) {
try {
setDependencies(moduleModel, libraryModel, rootModels.get(project), project);
} catch (Exception e) {
// should not happen, since project.prepare() is already called
LOG.error(e);
}
}
} finally {
libraryModel.commit();
ModifiableModelCommitter.multiCommit(rootModels.values(), moduleModel);
}
});
}
Aggregations