简体   繁体   English

导出Eclipse可部署插件和片段时出错

[英]Errors in exporting eclipse deployable plug-ins and fragments

I have an eclipse plug-in working fine within eclipse environment. 我有一个Eclipse插件,在Eclipse环境中工作正常。

I wanted to export it into a jar file, so I chose Export > Deployable plug-ins and fragments. 我想将其导出到jar文件中,因此选择了“导出”>“可部署的插件和片段”。

在此处输入图片说明

I could get a jar file, but an error was reported. 我可以得到一个jar文件,但是报告了一个错误。

在此处输入图片说明

Opening the log file, it reports that I have 1242 problems (191 errors, 1051 warnings). 打开日志文件,它报告我有1242个问题(191个错误,1051个警告)。 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. 我有2049条警告,但是在eclipse IDE中编译插件时没有错误。

ADDED 添加

The main project references two other projects, and references many external libraries. 主项目引用了另外两个项目,并引用了许多外部库。 I attach the package view and Java build path. 我附加了程序包视图和Java构建路径。

在此处输入图片说明在此处输入图片说明

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. 但是,核心问题是项目apimatchingoriginanalysis不是eclipse插件,而是java项目。 As a result, those two projects were not included in the final jar file to break the build. 结果,这两个项目没有包含在最终的jar文件中以破坏构建。

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. 我通过将src目录符号链接到主eclipse插件项目中来解决此问题。

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. 在“ Java构建路径/源”选项卡中,我添加了这两个包含的项目作为源。 Eclipse Java Missing required source folder: 'src' Eclipse Java缺少必需的源文件夹:“ src”

Now I have eclipse plugin jar file without error. 现在,我的eclipse插件jar文件没有错误。

在此处输入图片说明在此处输入图片说明

Then click F-5 to refresh the project explorer and check they are java src directory. 然后单击F-5刷新项目资源管理器,并检查它们是否为java src目录。

Select the included projects in Build tab. 在“构建”选项卡中选择包含的项目。

在此处输入图片说明

Updating bin.include and source.. in build.properties tab is important. 在build.properties选项卡中更新bin.includesource..很重要。 One should understand that in bin.include the ordering is also critical. 应该理解,在bin.include的顺序也很关键。 lib/cdtparser.jar and lib/cdtcore.jar should be placed prior to the user of them - origin analysis/ . lib / cdtparser.jar和lib / cdtcore.jar应该放在它们的用户之前-origin origin analysis/

在此处输入图片说明

Copying jar files for included project into main project 将包含项目的jar文件复制到主项目中

I also had to copy some jar files in those projects file into the main project, and select them in Binary Build tab. 我还必须将那些项目文件中的一些jar文件复制到主项目中,然后在Binary Build选项卡中选择它们。

在此处输入图片说明

And add tim in Runtime/Classpath tab. 并在“运行时/类路径”选项卡中添加tim。

在此处输入图片说明

Select the JavaSE-1.6 in Execution Environments. 在执行环境中选择JavaSE-1.6。

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. 在将项目导入Eclipse之后 ,有了这篇文章“必须重写超类方法”错误的提示,我删除了J2SE-1.5来解决此问题。

在此处输入图片说明

You can not add third party libraries into class path of Java when developing a plug-in. 开发插件时,不能将第三方库添加到Java的类路径中。 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 . 这是构建标准Java应用程序的方法,但是插件是一种OSGi捆绑软件,它本身具有类加载的规则

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, 在您的插件的MANIFEST.MF中添加以下声明,

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

Check those links [1] , [2] for understanding it. 检查那些链接[1][2]以了解它。

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; 此类是从引用的jar转换还是在实际的插件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/ 您似乎有很多固定的文件夹,并且想知道build.properties文件是否显示任何警告,并且还在build.properties源文件中为每个源文件夹定义了此警告。

  3. Your external jar libraries appear to be in a folder that is of type source which is not correct. 您的外部jar库似乎位于来源类型不正确的文件夹中。 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. 它应该是一个非源文件夹(您可以通过包图标装饰器将其告知源文件夹),并且应确保在清单编辑器中确保在运行时检查了lib,以便在构建中包含jar。 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. 要将其取消标记为源文件夹,请在导航器视图中选择下拉菜单,转到过滤器,然后取消选中.resources,然后将在该文件中显示.classpath文件,您将看到该文件夹​​为kind =“ src”(我相信)删除。

  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 同样,您似乎将普通Java应用程序的Java构建路径配置与OSGI中运行的插件混淆了,该OSGI不是通过Java构建路径配置的,而是您的manifest.editor。因此,根据经验,如果它的插件甚至不打扰配置Java构建路径,因为OSGI不同,这也可能导致问题

在“选项”中选择“使用工作空间中编译的类文件”对我有用。

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

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