Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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.

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. 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:

# 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. 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.

Is there a way to prevent eclipse from recompiling everything when I export the update site, the feature or the plugin. 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:

<?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?

like image 815
Ingo Avatar asked Dec 03 '11 02:12

Ingo


2 Answers

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. 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. The properties that Francis refers to are for headless PDE/Build. During an export, PDE/UI manages these for you and you can't change them.

The plug-in and feature specific properties will affect the UI export as well as the headless build. (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. I would also suggest setting up a real PDE/Build headless build instead of the export from UI task.

like image 73
Andrew Niefer Avatar answered Sep 28 '22 05:09

Andrew Niefer


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)

There is no way that I know of to use the class files from your workspace in the build.

like image 32
Francis Upton IV Avatar answered Sep 28 '22 06:09

Francis Upton IV