Skip to content

Green Annotations Wiki

TMTron edited this page Sep 25, 2016 · 9 revisions

Building the project

Prerequisites

Maven

Maven is used as the build-system and must be installed: see Apache Maven Installation

Android SDK

The project can also be built without Android SDK, but the Android SDK is required to run the tests.

Building with Maven

  • build and install with tests: mvn install
  • build and install without tests: mvn -Dmaven.test.skip=true install

IntelliJ IDE

Project configuration

IntelliJ has built in Maven support, so you can just import the Maven project (Hint: select the root directory, where the top-most pom.xml file is located).
The Maven import already does most of the setup, but there are some settings, that we need to adjust after the project import.

  • Project Structure
  • Project
    • set the default Project SDK to a Java 1.8 SDK
    • set the Project language level to: 7 - Diamonds, ARM, multi-catch etc.
  • Facets
    • Android (green-annotations-test)
      • Structure
        • Manifest file: correct the path to reference the AndroidManifest.xml file in src/main
        • Resources directory: correct the path to reference the res directory in src/main
      • Maven: deactivate the following check-boxes, so that our changes in the Structure tab-sheet will not get overwritten when we re-import the configuration from the maven pom.xml files
        • Manifest file path
        • Resources directory path

now Build - Make Project should already work

Running JUnit tests

  • open a test file: e.g. green-annotations-test/src/test/java/com/tmtron/greenannotations/test/GreenEventBusActivityTest.java
  • click Run - Run to execute the JUnit test
    • when you see a window with 2 options, select the one at the bottom (with the 2 red/green arrows)
    • when you see this error: !!! JUnit version 3.8 or later expected
      you have to move the JUnit dependency before the Android dependency:
      • open File - Project Structure - Project Settings - Modules
      • select green-annotations-test
      • go to the Dependencies tab-sheet
      • move the JUnit dependency (Maven: junit:junit:4.12) to the very top (even before Maven Android API 17 Platform)
      • see http://stackoverflow.com/a/2431427/6287240

Running Maven inside IntelliJ

  • Open the Maven projects view: View - Tool Windows - Maven Projects
  • Open the Lifecycle node of an of the maven projects and then just double click any of the lifecycle events

Gotchas

Android SDK manager

When you update the SDK tools, it may fail and leave you with an empty $ANDROID_HOME/tools directory:
see Stackoverflow: Updating Android SDK: “A folder failed to be moved.”

IntelliJ generate sources

This seems to depend on the order of the dependencies: when the Android SDK dependency comes after Maven: org.androidannotations:androidannotations:4.1.0 then androidannotations-annotation processor is not run and the generated sources are missing.