3

I have an eclipse plug-in working fine within eclipse environment.

I wanted to export it into a jar file, so I chose Export > Deployable plug-ins and fragments.

enter image description here

I could get a jar file, but an error was reported.

enter image description here

Opening the log file, it reports that I have 1242 problems (191 errors, 1051 warnings). This is some copy from the error log.

2. ERROR in /Users/LSclipse/src/lsclipse/LSDiffRunner.java (at line 61)
    import edu.washington.cs.induction.OnePipeLineScript;
           ^^^
The import edu cannot be resolved
----------
3. ERROR in /Users/LSclipse/src/lsclipse/LSDiffRunner.java (at line 261)
    OnePipeLineScript.getMatchingForRefFinder(projName, proj1, proj1Loc
    ^^^^^^^^^^^^^^^^^
OnePipeLineScript cannot be resolved

Why I got errors? I had 2049 warnings, but no error when I compile the plugin in eclipse IDE.

ADDED

The main project references two other projects, and references many external libraries. I attach the package view and Java build path.

enter image description here enter image description here

prosseek
  • 182,215
  • 215
  • 566
  • 871
  • Did you directly add third party library into class path for building them in IDE? – Kane Dec 21 '12 at 03:20
  • Well, I'm not sure about the 'directly add third party library into class path'. I added the screen capture of Java build path in my OP. – prosseek Dec 21 '12 at 03:27

4 Answers4

4

There were multiple issues involved for this problem. However, the core issue was that the project apimatching and originanalysis were not eclipse plugins but just java projects. As a result, those two projects were not included in the final jar file to break the build.

Symbolic linking the two projects into the main project

I solved this issue by symbolic link the src directory into the main eclipse plugin project.

ln -s /workspace/seal/edu.ucsc.originanalysis/src /LSclipse/originanalysis
ln -s /workspace/seal/edu.ucsc.apimatching/src /LSclipse/apimatching

From the Java Build Path/Source tab, I added those two included projects as source. Eclipse Java Missing required source folder: 'src'

Now I have eclipse plugin jar file without error.

enter image description here enter image description here

Then click F-5 to refresh the project explorer and check they are java src directory.

Select the included projects in Build tab.

enter image description here

Updating bin.include and source.. in build.properties tab is important. One should understand that in bin.include the ordering is also critical. lib/cdtparser.jar and lib/cdtcore.jar should be placed prior to the user of them - origin analysis/.

enter image description here

Copying jar files for included project into main project

I also had to copy some jar files in those projects file into the main project, and select them in Binary Build tab.

enter image description here

And add tim in Runtime/Classpath tab.

enter image description here

Select the JavaSE-1.6 in Execution Environments.

I have lots of "Must Override a Superclass Method" errors. With the hint from this post - 'Must Override a Superclass Method' Errors after importing a project into Eclipse , I removed the J2SE-1.5 to resolve this issue.

enter image description here

Community
  • 1
  • 1
prosseek
  • 182,215
  • 215
  • 566
  • 871
  • Glad to hear, if my answer helped you get on the right path please accept! Wrapping non plugin code as jars and including in plugins and adding to the plugin classpath is common practice – Duncan Krebs Dec 24 '12 at 01:43
  • 1
    Well, the main reason that exporting didn't work was that the Linked Folder was not properly included and setup. I solved the issue using symbolic link. I think it makes sense to use jar, but for my purposes, using symbolic link is much simpler and easier to get my jobs done. Thanks for your kind answer, though. – prosseek Dec 24 '12 at 16:16
1

You can not add third party libraries into class path of Java when developing a plug-in. It is the way to build standard Java application, but plug-in is a kind of OSGi bundle that has itself rule for class loading.

The correct way is adding third party libraries into the class path of your plug-in.

Add below declaration into MANIFEST.MF of your plug-in,

Bundle-ClassPath: lib/log4j-1.2.7.jar,
 xml-apis.jar,
 ...

Check those links [1], [2] for understanding it.

Kane
  • 8,035
  • 7
  • 46
  • 75
  • I checked MANIFEST.MF to find that Bundle-ClassPath is correctly declared. – prosseek Dec 21 '12 at 12:44
  • How about those libraries are in build.properties? For example, `bin.includes=lib/xml-apis.jar ` – Kane Dec 21 '12 at 13:53
  • Everything is there in build.properties also. In the exporting the bundle process, the ANT build file is generated and executed. The log file says that I got a bunch of errors in the compilation. I don't know why I got those errors when everything's fine in eclipse IDE? – prosseek Dec 21 '12 at 15:03
1

This is what have a question on and see as potential solutions to potential problems.

  1. Is this class comfing from a referenced jar or is it in the actual plugin edu.washington.cs.induction.OnePipeLineScript;

  2. You seem to have a lot of soure folders and wondering if your build.properties file is showing any warnings and that you also have this defined for each of the source folders in your build.properties source.. = src/

  3. Your external jar libraries appear to be in a folder that is of type source which is not correct. It should be a non-source folder (which you can tell a source folder by the package icon decorator) and you should make sure in your manifest editor that for runtime you have the lib checked so that it includes the jars in the build. To unmark it as a source folder select the drop down menu in your navigator view go to filters and uncheck .resources which will then show the .classpath file in that file you will see the folder to be kind="src" (i believe) remove that.

  4. Somehow it also looks like you have linked source folders which is a practice I would not suggest and am not sure if that will cause problems when exporting the plugin. If you can avoid linked source folders that would be better.

Also it seems like you are confusing java build path configuration for plain java applications with plugins running in OSGI which is not configured through java build path but your manifest.editor So as a rule of thumb if its a plugin don't even bother trying to configure the java build path because OSGI is different, that could be causing issues as well

Duncan Krebs
  • 3,366
  • 2
  • 33
  • 53
-1

Select "Use class files complied in the workspace" in Options works for me.

Community
  • 1
  • 1