How to integrate Android Development Tools and Maven

With the Maven Android Plugin it is possible to build and deploy/undeploy your android app and start/stop the emulator – if you’re used to maven you won’t be going without it ;) If you’re interested in signing your apk using maven – take a look at this article Project Setup Create an android project using the android tool We need some dependencies – so create a pom.xml in the project’s root directory – I took this from the plugin samples and modified it: <?xml version="1.0" encoding="UTF-8"?> <!-- Copyright (C) 2009 Jayway AB Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode.android.app</groupId> <artifactId>demo</artifactId> <packaging>apk</packaging> <name>hasCode.com - Sample Android App using the Maven Android Plugin</name> <version>0.1</version> <dependencies> <dependency> <groupId>android</groupId> <artifactId>android</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <!--<finalName>${artifactId}</finalName>--> <plugins> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>maven-android-plugin</artifactId> <configuration> <sdk> <path>${env.ANDROID_HOME}</path> <platform>3</platform> </sdk> <deleteConflictingFiles>true</deleteConflictingFiles> </configuration> <extensions>true</extensions> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> </project> ...

April 2, 2010 · 3 min · 453 words · Micha Kops

Eclipse Snippets

Favorites Spare my time when using static imports .. Window > Preferences > Java > Editor > Content Assist > Favorites: com.google.common.collect.Lists com.jayway.restassured.matcher.RestAssuredMatchers com.jayway.restassured.RestAssured io.restassured.matcher.RestAssuredMatchers io.restassured.RestAssured org.hamcrest.MatcherAssert org.hamcrest.Matchers org.mockito.Mockito javaslang.API javaslang.Predicates Template to insert a static logger instance Go Windows > Preferences > Java > Editor > Templates > New … Enter logger as name and as template: ${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)} private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class); Afterwards you’re able to type logger in your code and ctrl+space gives the option to insert the logger ...

March 1, 2010 · 1 min · 101 words · Micha Kops

IntelliJ Snippets

Live Templates JUnit 5 Test @org.junit.jupiter.api.Test @org.junit.jupiter.api.DisplayName("$NAME$") void $METHOD$() throws Exception { $END$ } Figure 1. IntelliJ Live Template Editor Edit Variables: NAME METHOD: default-value camelCase(NAME) Figure 2. Editing template variables SLF4J Logger Template private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger( $CLASS$.class ); Edit variables: CLASS: expression: className() Favorite Shortcuts Select whole block in Editor Cmd+Tab+Down Select similar blocks in editor Ctrl+G Copy the absolute Path of the current File into Clipboard Cmd+Shift+C ...

March 1, 2010 · 2 min · 341 words · Micha Kops