use of org.jetbrains.idea.devkit.build.PluginBuildConfiguration in project intellij-community by JetBrains.
the class ChunkBuildPluginExtension method process.
public void process(Project project, ModuleChunk chunk, GenerationOptions genOptions, CompositeGenerator generator) {
final Module[] modules = chunk.getModules();
if (isPlugins(modules)) {
final BuildTargetsFactory factory = BuildTargetsFactory.getInstance();
final Module module = modules[0];
PluginBuildConfiguration buildProperties = PluginBuildConfiguration.getInstance(module);
final Set<Library> libs = new HashSet<>();
PluginBuildUtil.getLibraries(module, libs);
@NonNls String jarPath = chunk.getBaseDir().getPath() + "/" + chunk.getName();
if (libs.isEmpty()) {
jarPath += ".jar";
} else {
jarPath += ".zip";
}
generator.add(new Property(PluginBuildProperties.getJarPathProperty(chunk.getName()), GenerationUtils.toRelativePath(jarPath, chunk, genOptions)), 1);
generator.add(factory.createComment(DevKitBundle.message("ant.build.jar.comment", chunk.getName())), 1);
generator.add(new BuildJarTarget(chunk, genOptions, buildProperties));
}
}
use of org.jetbrains.idea.devkit.build.PluginBuildConfiguration in project intellij-community by JetBrains.
the class PluginModuleType method getPluginXml.
@Nullable
public static XmlFile getPluginXml(Module module) {
if (module == null)
return null;
if (!isOfType(module)) {
for (final ContentEntry entry : ModuleRootManager.getInstance(module).getContentEntries()) {
for (final SourceFolder folder : entry.getSourceFolders(JavaModuleSourceRootTypes.PRODUCTION)) {
final VirtualFile file = folder.getFile();
if (file == null)
continue;
final String packagePrefix = folder.getPackagePrefix();
final String prefixPath = packagePrefix.isEmpty() ? "" : packagePrefix.replace('.', '/') + '/';
final String relativePath = prefixPath + PluginDescriptorConstants.PLUGIN_XML_PATH;
final VirtualFile pluginXmlVF = file.findFileByRelativePath(relativePath);
if (pluginXmlVF != null) {
final PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(pluginXmlVF);
if (psiFile instanceof XmlFile) {
return (XmlFile) psiFile;
}
}
}
}
return null;
}
final PluginBuildConfiguration buildConfiguration = PluginBuildConfiguration.getInstance(module);
if (buildConfiguration == null)
return null;
final ConfigFile configFile = buildConfiguration.getPluginXmlConfigFile();
return configFile != null ? configFile.getXmlFile() : null;
}
use of org.jetbrains.idea.devkit.build.PluginBuildConfiguration in project intellij-community by JetBrains.
the class PluginModuleBuilder method setupRootModel.
public void setupRootModel(final ModifiableRootModel rootModel) throws ConfigurationException {
super.setupRootModel(rootModel);
String contentEntryPath = getContentEntryPath();
if (contentEntryPath == null)
return;
String resourceRootPath = contentEntryPath + "/resources";
VirtualFile contentRoot = LocalFileSystem.getInstance().findFileByPath(contentEntryPath);
if (contentRoot == null)
return;
ContentEntry contentEntry = MarkRootActionBase.findContentEntry(rootModel, contentRoot);
if (contentEntry != null) {
contentEntry.addSourceFolder(VfsUtilCore.pathToUrl(resourceRootPath), JavaResourceRootType.RESOURCE);
}
final String defaultPluginXMLLocation = resourceRootPath + "/META-INF/plugin.xml";
final Module module = rootModel.getModule();
final Project project = module.getProject();
StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> {
final PluginBuildConfiguration buildConfiguration = PluginBuildConfiguration.getInstance(module);
if (buildConfiguration != null) {
buildConfiguration.setPluginXmlPathAndCreateDescriptorIfDoesntExist(defaultPluginXMLLocation);
}
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(defaultPluginXMLLocation);
if (file != null) {
FileEditorManager.getInstance(project).openFile(file, true);
}
});
}
use of org.jetbrains.idea.devkit.build.PluginBuildConfiguration in project intellij-community by JetBrains.
the class PluginModuleTestCase method setPluginXml.
protected void setPluginXml(@TestDataFile String pluginXml) {
final VirtualFile file = myFixture.copyFileToProject(pluginXml, "META-INF/plugin.xml");
final PluginBuildConfiguration pluginBuildConfiguration = PluginBuildConfiguration.getInstance(myModule);
assertNotNull(pluginBuildConfiguration);
pluginBuildConfiguration.setPluginXmlFromVirtualFile(file);
}
Aggregations