InstallingEnvironment - PerfectCarl/androidannotations GitHub Wiki

Introduction

Developing an AnnotationProcessor is not something very common, but hopefully we went through many different bugs and solved them. We now have a quite stable and clean dev environment, so you should be able to contribute to AndroidAnnotations by following these simple steps.

Installing the environment

  • Install Git
  • Install Maven
  • Install Eclipse Juno
  • Install the latest version of the Android SDK and the Android Eclipse Plugin (ADT)
  • Install the latest version of the m2e-android and m2e plugins:
    • Start Eclipse, then select Help > Install New Software.
    • Click Add, in the top-right corner.
    • In the Add Repository dialog that appears, enter "m2e-android" for the Name and the following URL for the Location: http://rgladwell.github.com/m2e-android/updates/
    • In the Available Software dialog, select the checkbox next to Android Connector for M2E and click Next.
    • In the next window, you'll see a list of the tools to be downloaded. Click Next.
    • Read and accept the license agreements, then click Finish. If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
    • When the installation completes, restart Eclipse.

Getting the sources

  • Fork the repository
  • Clone the repository to your computer:
git clone [email protected]:YOUR_USERNAME/androidannotations.git

Importing in Eclipse

  • Go to File > Import > General > Existing Projects into Workspace, click Browse, select the eclipse-dependencies folder and click Open. Click Finish.

  • Go to File > Import > Maven > Existing Maven Projects, click Browse, select the AndroidAnnotations folder and click Open then uncheck the last two to keep only /pom.xml and androidannotations/pom.xml checked. Click Finish.

  • In the androidannotations project, right click on src/main/eclipse and select Build Path > Use as source folder.

  • Right click on the androidannotations project, select Build Path > Add Libraries.... Select Plug-in Dependencies, select org.eclipse.core.runtime_XXX.jar and click Finish.

Running the dev Eclipse instance

  • Go to Run > Run Configurations... and double click on Eclipse Application. Go to the Arguments tab and add -XX:MaxPermSize=256m in VM arguments. Then click Run.

Note: I encountered a problem with running Eclipse on a 32bits JVM with a 64bits Mac, which was simply solved by adding -D32 to the VM arguments of the run configuration.

  • This new eclipse is launched on a new workspace.

Note: you can use get a free jrebel license (free for OSS projects) and use it for automatic class reloading. You just need to add ${jrebel_args} to the VM arguments, and enable jrebel.

You may also start this new Eclipse instance in Debug, put breakpoints in AndroidAnnotations code and benefit from hot code swapping.

Importing the test projects

  • Go to File > Import > Maven > Existing Maven Projects, click Browse, select the AndroidAnnotations/functional-test-1-5 folder and click Open and then Finish.

  • If you get weird errors about some Android or JDK classes not being found and see unable to get system library for the project on eclipse ide when looking at the build path, check this out.

  • Go to File > Import > Maven > Existing Maven Projects, click Browse, select the AndroidAnnotations/functional-test-1-5-tests folder and click Open and then Finish.

  • The generated classes may not be there yet, so do a Project > Clean... to let AndroidAnnotations generate them.

  • A bit of dark magic: if you still have compilation errors on a project, claiming that the generated classes are missing, open the project Properties > Java compiler > Annotation Processing and change the name of the Generated source directory. Click Apply, then change it back to .apt_generated and apply again. You should be good to go, if not, then let us know ;-) .

Running the functional tests

  • Right click on functional-test-1-5-tests and select Run As > JUnit Test. Check Use configuration specific settings, select Eclipse JUnit Launcher and click OK.

  • If the tests are failing, the probable cause is that the runner doesn't have access to the classpath containing the tested classes. Select Run > Run Configurations..., open JUnit > functional-test-1-5-tests, open the Classpath tab, click on User entries, click on Add Projects... on the right, select functional-test-1-5 and click OK and the Run.

  • The test may take a bit of time to run, because Robolectric has to load tons of classes.

  • Select the functional-test-1-5 then click on Run > Run Configurations... and double click on JUnit. Change the test runner to JUnit4. In the bottom part, select the Eclipse JUnit Runner.

  • Go to Classpath and click Advanced on the right. Select Add Folders, and select functional-test-1-5 > target > android-classes. Also add the folder functional-test-1-5 > bin > classes

Notes:

To start the tests, just run the previously created Run Configuration

To see your changes in the code, you have to restart the 2nd eclipse. We didn't find any better solution, but tell us if you do!