我如何使用Eclipse的新的Xtend语言在我的Andr​​oid项目? [英] How can I use Eclipse's new Xtend language in my Android project?

查看:265
本文介绍了我如何使用Eclipse的新的Xtend语言在我的Andr​​oid项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写Java类中的Xtend语言(仅仅是因为它的方式更简洁),并把它编译回落到Java类,而我可以在我的Java项目中使用。就像CoffeeScript的。我怎样才能做到这一点?

I'd like to write Java classes in the Xtend language (simply because its way more terse), and have it compile back down into Java classes of which I can use in my Java project. Just like coffeescript. How can I do this?

我试图创建一个文件的Xtend正如我将用一个新的类做的,但是我得到这个错误:

I tried creating an Xtend file just as I would do with a new class, however I get this error:

强制性库包org.eclipse.xtext.xbase.lib在类路径中没有找到。

Mandatory library bundle 'org.eclipse.xtext.xbase.lib' not found on the classpath.

这将禁用智能感知(自动完成)。此外,即使我得到了工作,我该怎么把它编译成Java类?

This disables intellisense (autocompletion). Also, even if I do get that working, how can I have it compile to a Java class?

推荐答案

尝试过同样的事情,我可以证实,使自然的Xtend并增加三个库的Xtend(前面提到的,org.eclipse.xtext.xtend2。库','​​org.eclipse.xtext.xbase.lib'和'com.google.inject)到项目的库使的Xtend code编译,至少。不过,我也有与R类的麻烦。

Having tried the same thing, I can confirm that enabling the Xtend Nature and adding the three Xtend libraries (mentioned earlier, 'org.eclipse.xtext.xtend2.lib', 'org.eclipse.xtext.xbase.lib' and 'com.google.inject') to the project's libraries makes the Xtend code compile, at least. However, I am also having trouble with the R class.

在仔细检查,它看起来像R类的问题不在于它被设在不同的目录。复制文件到主源代码目录使用不同的名称不会改变任何东西。相反,它看起来像问题是与R类是一个的静态最后的类,包含多个的静态最后的子类。如果我创建一个包装提及R.layout.main(例如)内的普通方法进行简单的纯Java包装类,并调用从我的Xtend code,则它接受它,并愉快地编译。

On closer inspection, it looks like the problem with the R class is not with it being located in a different directory. Copying the file to the main source dir with a different name doesn't change anything. Rather, it looks like the problem is with the R class being a static final class, containing several static final subclasses. If I create a simple plain-Java wrapper class that wraps a reference to R.layout.main (for example) inside a normal method, and call that from my Xtend code, then it does accept it and happily compiles.

在此之后,下一个问题我碰到了Android的编译器抱怨重复about.html和plugin.properties中的文件在org.eclipse.xtext.xtend2.lib','org.eclipse.xtext.xbase.lib '和'com.google.inject'。是相对容易解决,通过从两个三.jar文件的去除那些文件。我不知道,如果它打破东西以后,但至少现在我的Xtend code运行在Android模拟器工作片段。

After that, the next issue I came across was the Android compiler complaining about duplicate about.html and plugin.properties files in 'org.eclipse.xtext.xtend2.lib', 'org.eclipse.xtext.xbase.lib' and 'com.google.inject'. That is relatively easy to fix, by removing those files from two of the three .jar files. I'm not sure if it breaks anything later on, but now at least I have a working snippet of Xtend code running on the Android emulator.

这篇关于我如何使用Eclipse的新的Xtend语言在我的Andr​​oid项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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