在 Scala 和 Gradle 中使用 AndroidAnnotations [英] Using AndroidAnnotations with Scala and Gradle
问题描述
是否可以将 AndroidAnnotations 与 Scala 编程语言和 Gradle 构建系统一起使用?当我尝试将 AndroidAnnotations 集成到我现有的 Android/Scala/Gradle 项目中时,编译失败,因为找不到生成的下划线类(例如 MyActivity_).
Is it possible to use AndroidAnnotations with the Scala programming language and the Gradle build system? When I try to integrate AndroidAnnotations into my existing Android/Scala/Gradle project, then compilation fails because the generated underscore classes (e.g. MyActivity_) cannot be found.
以下是一些有用的起点和参考资料:
Here are some useful starting points and references:
- http://www.scala-lang.org/node/4773(2010-01-06)
- http://www.scala-lang.org/sid/5(2010-01-27)
- http://code.google.com/p/androidannotations/wiki/Configuring (2011-07-28)
- http://docs.jboss.org/hibernate/validator/4.1/reference/en-US/html/ch08.html#d0e2816(2010?)
- Java 6 注释处理配置与 Ant (2010-09-05)
- http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html#processing
- http://ant.apache.org/manual/Tasks/apt.html
- 从 Gradle 构建脚本生成 JPA2 元模型(2011-06-22)
- http://download.oracle.com/javase/1.5.0/docs/guide/apt/GettingStarted.html
- http://www.scala-lang.org/node/4773 (2010-01-06)
- http://www.scala-lang.org/sid/5 (2010-01-27)
- http://code.google.com/p/androidannotations/wiki/Configuring (2011-07-28)
- http://docs.jboss.org/hibernate/validator/4.1/reference/en-US/html/ch08.html#d0e2816 (2010?)
- Java 6 annotation processing configuration with Ant (2010-09-05)
- http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html#processing
- http://ant.apache.org/manual/Tasks/apt.html
- Generating JPA2 Metamodel from a Gradle build script (2011-06-22)
- http://download.oracle.com/javase/1.5.0/docs/guide/apt/GettingStarted.html
推荐答案
在我寻求解决此问题的过程中,我在原始问题帖子中添加了一些研究链接.AndroidAnnotations 注释处理器生成源代码(Java 文件).注释处理器通常似乎在源代码级别(而不是类文件)运行.我期待 AndroidAnnotations 从 Scala 源文件生成 Java 代码.Scala 似乎不支持 Java 注释处理工具.所以我对这个问题的回答是:不可能在 Scala 源代码中使用 AndroidAnnotations.但是,在 Scala 混合源项目的 Java 源代码中仍可能使用 AndroidAnnotations.
During my quest to solve this problem, I added some research links to my original question post. The AndroidAnnotations annotation processor generates source code (Java files). Annotation processors in general seem to operate at the source code level (and not class files). I am expecting AndroidAnnotations to generate Java code from Scala source files. Scala doesn't seem to support the Java annotation processing tool. So my answer to this question would be: it is not possible to use AndroidAnnotations with Scala source code. However, AndroidAnnotations may still be used in the Java source code in a Scala mixed-source project.
这篇关于在 Scala 和 Gradle 中使用 AndroidAnnotations的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!