use of org.osmorc.facet.OsmorcFacetConfiguration in project intellij-plugins by JetBrains.
the class BundleManifestCache method getManifest.
@Nullable
public BundleManifest getManifest(@NotNull Module module) {
OsmorcFacet facet = OsmorcFacet.getInstance(module);
if (facet == null)
return null;
CachedValue<BundleManifest> value = myCache.get(facet);
if (value == null) {
value = myManager.createCachedValue(() -> {
OsmorcFacetConfiguration configuration = facet.getConfiguration();
BundleManifest manifest = null;
List<Object> dependencies = ContainerUtil.newSmartList(configuration);
switch(configuration.getManifestGenerationMode()) {
case Manually:
{
PsiFile manifestFile = findInModuleRoots(facet.getModule(), configuration.getManifestLocation());
if (manifestFile instanceof ManifestFile) {
manifest = readManifest((ManifestFile) manifestFile);
dependencies.add(manifestFile);
} else {
dependencies.add(PsiModificationTracker.MODIFICATION_COUNT);
}
break;
}
case OsmorcControlled:
{
Map<String, String> map = ContainerUtil.newHashMap(configuration.getAdditionalPropertiesAsMap());
map.put(Constants.BUNDLE_SYMBOLICNAME, configuration.getBundleSymbolicName());
map.put(Constants.BUNDLE_VERSION, configuration.getBundleVersion());
map.put(Constants.BUNDLE_ACTIVATOR, configuration.getBundleActivator());
manifest = new BundleManifest(map);
break;
}
case Bnd:
{
PsiFile bndFile = findInModuleRoots(facet.getModule(), configuration.getBndFileLocation());
if (bndFile != null) {
manifest = readProperties(bndFile);
dependencies.add(bndFile);
} else {
dependencies.add(PsiModificationTracker.MODIFICATION_COUNT);
}
break;
}
case Bundlor:
// not supported
break;
}
return CachedValueProvider.Result.create(manifest, dependencies);
}, false);
myCache.put(facet, value);
}
return value.getValue();
}
use of org.osmorc.facet.OsmorcFacetConfiguration 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;
}
Aggregations