链接到Eclipse中生成的Java protobuf代码 [英] Linking to generated Java protobuf code in Eclipse

查看:396
本文介绍了链接到Eclipse中生成的Java protobuf代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在尝试构建的工作流程

Here's the workflow that I'm trying to build


  • 使用脚本编译我的proto文件,将生成的src放在指定的目录

  • 链接到Eclipse中生成的类

  • 编译我的项目

我可以使用Eclipse CDT轻松地为C ++执行此操作:在我的项目中,我选择File-> New-> Other并选择General下的File。然后我点击Advanced并选择链接到系统文件。

I am easily able to do this for C++ using Eclipse CDT: In my project I choose File->New->Other and choose File under General. Then I click on Advanced and select link to system file.

我还没有发现如何为Java做这个。一旦回答这里建议创建另一个带有生成代码的项目,并使其成为我项目的依赖项。这有效,但似乎是多余的。

I haven't discovered how to do this for Java, though. Once answer here suggests creating another project with the generated code and make that a dependency to my project. This works but seems redundant.

有没有办法直接将生成的protobuf Java类链接到我的项目?

Is there a way to directly link the generated protobuf Java classes to my project?

推荐答案

Java并没有真正的链接阶段。你的两个选择是:

Well Java doesn't really have a "link" phase. Your two options are really:


  • 在Eclipse之外构建生成的代码,然后添加对相关目录或jar文件的引用

  • 在Eclipse中包含生成的代码(例如,通过包含包含生成代码的目录的源路径)并让Eclipse将其与其余代码一起构建。

我怀疑第一个选项会让生成的代码更容易远离实际来源,但第二个选项可能使浏览生成的源更容易,并将所有内容打包。

I suspect that the first option will make it easier to keep the generated code well away from your real source, but the second option may make it easier to browse the generated source, and package everything up.

这篇关于链接到Eclipse中生成的Java protobuf代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆