【问题标题】:My RCP plugin refuse to load我的 RCP 插件拒绝加载
【发布时间】:2016-04-16 19:26:43
【问题描述】:

我正在制作一个小的 Eclipse 插件。当我在 Eclipse RCP 中启动它时,一切正常。但是当我将它作为功能导出并安装在标准 Eclipse 上时,我得到了这个错误:

插件 foo.bar 无法加载类 foo.bar.Editor.

我已搜索生成的功能和插件 jar,Editor.class 位于 bin/foo/bar/Editor.class 内。

那么问题是什么?

这是我的插件 build.properties :

bin.includes = META-INF/,\
               plugin.xml,\
               icons/,\
               bin/info/
jars.compile.order = cucumber-core-1.2.4.jar,\
                     cucumber-html-0.2.3.jar,\
                     cucumber-java-1.2.4.jar,\
                     cucumber-junit-1.2.4.jar,\
                     cucumber-jvm-deps-1.0.5.jar,\
                     gherkin-2.12.2.jar
src.includes = src/,\
               icons/,\
               plugin.xml,\
               META-INF/,\
               .project,\
               .classpath,\
               .settings/,\
               build.properties

这是我的 MANIFEST.MF

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Cucumber
Bundle-SymbolicName: foo.bar.cucumber;singleton:=true
Bundle-Version: 2.0.0.Final
Bundle-Activator: foo.bar.cucumber.Activator
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.jface.text;bundle-version="3.9.2",
 org.eclipse.ui.editors;bundle-version="3.8.200",
 org.eclipse.swt,
 org.eclipse.text,
 org.eclipse.osgi,
 org.eclipse.equinox.registry,
 org.eclipse.jdt.core,
 org.eclipse.core.resources,
 Cucumber;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Import-Package: cucumber.api.java.fr,
 org.eclipse.ui.texteditor,
 org.eclipse.ui.texteditor.templates
Export-Package: foo.bar.cucumber,
 foo.bar.cucumber.contentAssist,
 foo.bar.cucumber.synthaxColoring

我的插件.xml

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.editors">
      <editor
            class="foo.bar.cucumber.Editor"
            default="false"
            extensions="feature"
            icon="icons/cukes.gif"
            id="foo.bar.cucumber.editor"
            name="Cucumber editor">
      </editor>
   </extension>
   <extension
         point="org.eclipse.ui.editors.templates">
      <contextType
            class="org.eclipse.jface.text.templates.TemplateContextType"
            id="foo.bar.cucumber.contentAssist.template.contextType"
            name="Default Context Type">
      </contextType>
      <template
            autoinsert="true"
            contextTypeId="foo.bar.cucumber.contentAssist.template.contextType"
            description="Template d&apos;une fonctionnalité"
            icon="icons/cukes.gif"
            id="foo.bar.cucumber.contentAssist.template.feature"
            name="Fonctionnalité">
         <pattern>
            #language:fr
Fonctionnalité : ${description_de_la_fonctionnalité}

    Scénario : ${description_du_scénario}
        Soit 
        Et
        Alors
         </pattern>
      </template>
      <template
            autoinsert="true"
            contextTypeId="foo.bar.cucumber.contentAssist.template.contextType"
            description="Template d&apos;un scénario"
            icon="icons/cukes.gif"
            id="foo.bar.cucumber.contentAssist.template.scenario"
            name="Scénario">
         <pattern>
            Scénario : ${description_du_scénario}
        Soit 
        Et
        Alors
         </pattern>
      </template>
   </extension>

</plugin>

【问题讨论】:

    标签: java eclipse eclipse-plugin eclipse-rcp


    【解决方案1】:

    假设您的源代码位于 src 文件夹中,输出类位于 bin 文件夹中,build.properties 应包含以下内容:

    source.. = src/
    output.. = bin/
    bin.includes = META-INF/,\
                   .,\
                   icons/,\
                   plugin.xml
    

    (加上你的 jar.compile.order)

    如果您希望将这些 jars 包含在插件中,它们也需要列在“bin.includes”中。

    【讨论】:

    • 这行不通。现在我将 foo.bar.Editor.class 放到插件 Jar 的根目录中,而不是在 bin 目录中。这个更好。但是 Eclipse 仍然坚持找不到 Editor 类
    • 编辑您的问题并为插件添加您的 MANIFEST.MF 和 plugin.xml
    猜你喜欢
    • 2020-11-09
    • 1970-01-01
    • 2017-04-04
    • 2015-05-10
    • 2021-08-21
    • 1970-01-01
    • 1970-01-01
    • 2011-03-08
    • 2020-08-01
    相关资源
    最近更新 更多