简体   繁体   English

Eclipse PDE构建/导出插件/功能/更新站点不支持文件编码 - 如何禁止重新编译

[英]Eclipse PDE build/export plugin/feature/update site does not honor file encoding - how to forbid recompiling

I have written a nice plugin, which incoporates some generated java sources. 我写了一个很好的插件,它包含了一些生成的java源代码。

I can build the project just fine. 我可以很好地构建项目。 I can run it in a run configuration that launches another eclipse and it works to my liking. 我可以在运行配置中运行它,启动另一个eclipse,它可以根据自己的喜好运行。

So I thought: time to make it install-able. 所以我想:时间让它可以安装。

Hence I created a feature project and an update site project, and build and export that and it looks like it works fine. 因此,我创建了一个功能项目和一个更新站点项目,并构建和导出它,看起来它工作正常。 I can even "Install" it from my update site, or export the plugin directly in the running workbench. 我甚至可以从我的更新站点“安装”它,或直接在正在运行的工作台中导出插件。 I see that it is installed but if I try to open a file that would activate my plugin, it throws exceptions. 我看到它已安装但如果我尝试打开一个会激活我的插件的文件,它会抛出异常。 Specifically, it tells me there are "unresolved compilation problems". 具体来说,它告诉我有“未解决的编译问题”。

After long searching, rebuilding (no errors), retesting again and again I find a logs.zip file, with a directory whose name resembles that of my plugin and therein a 54k file (mind you, it's 2011 and disk space is extremely scarce, obviously) with the funny name @dot.log . 经过长时间的搜索,重建(没有错误),一次又一次地重新测试我找到一个logs.zip文件,其目录的名称类似于我的插件,其中有一个54k文件(请注意,它是2011年,磁盘空间非常稀缺,显然,有趣的名字@dot.log How desperate one must be to look in such a file?! 看这样的文件一定是多么绝望?! But, surprise, surprise, it turns out there are 54k error messages like the following: 但是,令人惊讶的是,它出现了54k错误消息,如下所示:

# 02.12.11 19:58:55 MEZ
# Eclipse Compiler for Java(TM) 0.B76_R37x, 3.7.1, Copyright IBM Corp 2000, 2011. All rights reserved.
----------
1. ERROR in X:\dev\frege\FregIDE\src\frege\IO.java (at line 1451)
final public static Consts ij = new Consts();
                            ^
Syntax error on token "Invalid Character", delete this token

The "Invalid Characters" are, of course, perfectly legal java identifier characters, it's just that they are not ASCII letters. 当然,“无效字符”是完全合法的java标识符字符,只是它们不是ASCII字母。 This is why I have all files set to UTF-8, have set UTF-8 as default encoding, and as said before, with normal build it works perfectly. 这就是为什么我将所有文件设置为UTF-8,将UTF-8设置为默认编码,并且如前所述,正常构建它完美地工作。

Is there a way to prevent eclipse from recompiling everything when I export the update site, the feature or the plugin. 当我导出更新站点,功能或插件时,有没有办法阻止eclipse重新编译所有内容。 This is what I would prefer most as everything is already compiled and recompilation takes another minute or so. 这是我最喜欢的,因为一切都已编译,重新编译需要一分钟左右。 (There is even a flag "Use class files compiled in the workspace." but it seems to do nothing - it just recompiles.) (甚至还有一个标志“使用在工作区中编译的类文件。”但它似乎什么都不做 - 它只是重新编译。)

Alternative: Can I somehow modify the script it uses to build that? 替代方案:我可以以某种方式修改它用于构建它的脚本吗? I can't find the ant script he uses to build. 我找不到他用来构建的蚂蚁脚本。 If I could look up the javac step and put encoding UTF-8 there (that is what I expect to be the problem.) There is an "Save as Ant script" checkbox, but the Ant file does only contain: 如果我可以查找javac步骤并将编码UTF-8放在那里(这就是我期望的问题。)有一个“另存为Ant脚本”复选框,但Ant文件只包含:

<?xml version="1.0" encoding="UTF-8"?>
<project default="feature_export" name="build">
<target name="feature_export">
    <pde.exportFeatures destination="x:\dev\frege\FregeUpdateSite"
                                exportSource="false" exportType="directory" 
                                features="FregeFeature" useJARFormat="true"/>
</target>
</project>

How can I make eclipse use the correct settings for the compile build if I can't prevent it from compiling? 如果我不能阻止它编译,我如何让eclipse使用编译版本的正确设置?

If you are using the "pde.exportFeatures" task to export from a workspace, then I believe there is an attribute "useWorkspaceCompiledClasses" to use the binaries from the workspace. 如果您使用“pde.exportFeatures”任务从工作区导出,那么我相信有一个属性“useWorkspaceCompiledClasses”来使用工作区中的二进制文件。 This is equivalent to the check box in the export wizard. 这相当于导出向导中的复选框。

Note that the pde.exportFeatures task is an export from the UI and is different from a headless PDE/Build . 请注意,pde.exportFeatures任务是从UI导出的,与无头PDE / Build不同 The properties that Francis refers to are for headless PDE/Build. 弗朗西斯所指的属性是无头PDE / Build。 During an export, PDE/UI manages these for you and you can't change them. 在导出期间,PDE / UI会为您管理这些内容,您无法更改它们。

The plug-in and feature specific properties will affect the UI export as well as the headless build. 插件和功能特定属性将影响UI导出以及无头构建。 (I got the link incorrect in my comment on Francis' answer). (我在弗朗西斯回答的评论中得到的链接不正确)。

I would recommend setting the encoding in the plugin's build.properties file instead of reusing the workspace binaries. 我建议在插件的build.properties文件中设置编码,而不是重用工作区二进制文件。 I would also suggest setting up a real PDE/Build headless build instead of the export from UI task. 我还建议设置一个真正的PDE / Build无头构建,而不是从UI任务导出。

You can use the build.properties file that's part of the PDE build to set the compiler options for the compile that's done in the build: http://help.eclipse.org/indigo/topic/org.eclipse.pde.doc.user/reference/pde_builder_config.htm (use the -encoding option) 您可以使用作为PDE构建的一部分的build.properties文件来为在构建中完成的编译设置编译器选项: http//help.eclipse.org/indigo/topic/org.eclipse.pde.doc。 user / reference / pde_builder_config.htm (使用-encoding选项)

There is no way that I know of to use the class files from your workspace in the build. 我不知道在构建中使用工作区中的类文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM