【问题标题】:Eclipse RCP Fragment How to Build library.jarEclipse RCP 片段如何构建 library.jar
【发布时间】:2017-03-07 19:44:34
【问题描述】:

these instructions 之后,我有一个插件片段,它向主机插件贡献了一个 jar 文件。它通过创建文件library.jar 来工作,该文件在build.properties 中指定并与包含要构建的源的目录相关联。

这一切都按预期工作,除了我不知道如何在 Eclipse 中创建 library.jar。当我运行指向我的片段项目并将其包含为模块的 Maven 构建时,文件library.jar 将显示在项目目录中。但是在eclipse中构建或清理项目不会创建文件。

我希望其他开发人员能够在他们的 Eclipse 工作区中生成 library.jar 而无需运行 Maven 构建。我真的很惊讶 Maven 构建在插件项目本身中创建了libary.jar,而不仅仅是在构建目标中创建的产品中。应该有一种方法可以让 Eclipse 在不运行 Maven 构建的情况下执行此操作。

编辑:

build.properties:

bin.includes = META-INF/,\
               library.jar
source.library.jar = src/

清单.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Custom
Bundle-SymbolicName: org.python.pydev.custom
Bundle-Version: 1.0.0.qualifier
Fragment-Host: org.python.pydev;bundle-version="5.1.2"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-PatchFragment: true
Bundle-ClassPath: library.jar,
 .
Require-Bundle: org.python.pydev.debug;bundle-version="5.5.0",
 org.eclipse.cdt.debug.core;bundle-version="8.0.0",
 org.apache.log4j

【问题讨论】:

    标签: maven build eclipse-plugin eclipse-rcp


    【解决方案1】:

    build.properties 文件看起来像这样时,Eclipse 将构建 library.jar 而不是将类文件放在正常位置:

    bin.includes = META-INF/,\
                   library.jar
    source.library.jar = src/
    

    bin.includes 中的 library.jar 条目替换了正常的 . 条目。

    source.library.jar 条目表示直接将src 中的Java 文件放在library.jar 中。

    您的 MANIFEST.MF 中的 Bundle-Classpath 条目应该是:

    Bundle-ClassPath: library.jar
    

    (所以没有'.'条目)

    【讨论】:

    • 谢谢,但这正是我在 build.properties 中所拥有的。 bin.includes 条目上有一条警告,上面写着:插件的类路径库 '.'没有相应的源构建条目。那是红鲱鱼吗?我的 .classpath 配置与其他项目相同,没有出现此警告。因为它是一个片段,所以这里不同吗?我按照此处的说明 (blog.ankursharma.org/2009/11/source-and-output.html) 无济于事。
    • 我也在build.properties中尝试了很多东西,比如“output.library.jar = .”。然后它抱怨: / 不是输出文件夹。但我以为我是在告诉它让它成为一个输出文件夹。
    • 您可能需要在 MANIFEST.MF 中正确设置 Bundle-Classpath - 请参阅更新后的答案
    • 删除 . Bundle-ClassPath 中的条目确实使 build.properties 中的警告消失。但是当我在eclipse中构建或清理项目时,library.jar仍然没有出现。
    • 只有在构建RCP或导出插件时才会出现在插件jar/目录中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-24
    • 2015-10-04
    • 1970-01-01
    • 1970-01-01
    • 2019-01-14
    • 2017-05-25
    相关资源
    最近更新 更多