Search in sources :

Example 1 with PluginBuildConfiguration

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));
    }
}
Also used : NonNls(org.jetbrains.annotations.NonNls) PluginBuildConfiguration(org.jetbrains.idea.devkit.build.PluginBuildConfiguration) Library(com.intellij.openapi.roots.libraries.Library) Module(com.intellij.openapi.module.Module) Property(com.intellij.compiler.ant.taskdefs.Property) HashSet(java.util.HashSet)

Example 2 with PluginBuildConfiguration

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SourceFolder(com.intellij.openapi.roots.SourceFolder) XmlFile(com.intellij.psi.xml.XmlFile) ConfigFile(com.intellij.util.descriptors.ConfigFile) ContentEntry(com.intellij.openapi.roots.ContentEntry) PluginBuildConfiguration(org.jetbrains.idea.devkit.build.PluginBuildConfiguration) PsiFile(com.intellij.psi.PsiFile) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with PluginBuildConfiguration

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);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ContentEntry(com.intellij.openapi.roots.ContentEntry) PluginBuildConfiguration(org.jetbrains.idea.devkit.build.PluginBuildConfiguration)

Example 4 with PluginBuildConfiguration

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PluginBuildConfiguration(org.jetbrains.idea.devkit.build.PluginBuildConfiguration)

Aggregations

PluginBuildConfiguration (org.jetbrains.idea.devkit.build.PluginBuildConfiguration)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ContentEntry (com.intellij.openapi.roots.ContentEntry)2 Property (com.intellij.compiler.ant.taskdefs.Property)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 SourceFolder (com.intellij.openapi.roots.SourceFolder)1 Library (com.intellij.openapi.roots.libraries.Library)1 PsiFile (com.intellij.psi.PsiFile)1 XmlFile (com.intellij.psi.xml.XmlFile)1 ConfigFile (com.intellij.util.descriptors.ConfigFile)1 HashSet (java.util.HashSet)1 NonNls (org.jetbrains.annotations.NonNls)1 Nullable (org.jetbrains.annotations.Nullable)1