Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using AndroidAnnotations with Scala and Gradle

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 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
like image 430
W1M0R Avatar asked Sep 17 '11 10:09

W1M0R


People also ask

Does gradle work with Scala?

Gradle supports version 1.6. 0 of Zinc and above. The Zinc compiler itself needs a compatible version of scala-library that may be different from the version required by your application. Gradle takes care of specifying a compatible version of scala-library for you.

How do I run Scala with gradle?

From inside the new project directory, run the init task using the following command in a terminal: gradle init . When prompted, select the 2: application project type and 5: Scala as implementation language. Next you can choose the DSL for writing buildscripts - 1 : Groovy or 2: Kotlin .


2 Answers

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.

like image 200
W1M0R Avatar answered Sep 28 '22 05:09

W1M0R


Regarding Gradle (without Scala), it seems that someone managed to use it with AndroidAnnotations, here: Adapt AndroidAnnotations Maven settings to Gradle

like image 31
Pierre-Yves Ricau Avatar answered Sep 28 '22 04:09

Pierre-Yves Ricau