Permalink
Browse files

Fixed Maven build

  • Loading branch information...
1 parent 7c06501 commit d41b1e54e278e568ecca973f30308dc7093b6a0d David Varvel and Phil Goodwin committed Feb 28, 2013
Showing with 19 additions and 40 deletions.
  1. +8 −1 README.md
  2. +1 −5 build.xml
  3. +0 −3 pom.xml
  4. +10 −8 script/helpers.rb
  5. +0 −23 test/java/com/example/android/sampleapp/StarterActivityWithFestTest.java
View
9 README.md
@@ -239,13 +239,20 @@ git repo, and gives the project a name of [YourProject].
- `script/set_package` -- Change the Java package from the default to the provided package name.
- `script/init_git_repo` -- create a new local git repository. Existing `.git` directory safely moved to `.git.bak`.
-## ant
+## ant (DEPRECATED)
In addition to the built-in Android `ant` tasks you will likely use the following additions often.
You can chain them, such as `ant clean test`. Feel free to edit `build.xml` to fit your needs.
- `ant clean` -- deletes all output dirs
- `ant test` -- executes the project tests
+## Maven
+There are a couple of useful maven tasks:
+
+- `mvn clean` -- deletes all output dirs
+- `mvn test` -- executes the project tests
+- `mvn install` -- writes the target (your apk by default) to the local maven repo
+
## Open Source Robolectric
Robolectric is open source and it continuously improves. We recommend that your project fork robolectric.
By forking you have the freedom to choose when (if ever) to update to later versions of robolectric,
View
6 build.xml
@@ -105,7 +105,7 @@
<target name="-pre-compile">
<!-- android uses this property for its generated testing framework. We'll set it manually.-->
<property name="tested.project.absolute.dir" location="."/>
- <property name="tested.project.test.absolute.dir" location="${tested.project.absolute.dir}/test/java"/>
+ <property name="tested.project.test.absolute.dir" location="${tested.project.absolute.dir}/src/test/java"/>
<property name="out.test.classes.absolute.dir" location="${out.dir}/testClasses"/>
</target>
@@ -135,10 +135,6 @@
verbose="${verbose}"
classpathref="project.javac.classpath"
includeantruntime="false">
- <src path="${source.absolute.dir}"/>
- <src path="${gen.absolute.dir}"/>
-
- <!-- test src -->
<src path="${tested.project.test.absolute.dir}"/>
<classpath>
<pathelement path="${out.classes.absolute.dir}"/>
View
3 pom.xml
@@ -204,9 +204,6 @@
<excludes>
<exclude>**/Test*.java</exclude>
</excludes>
- <includes>
- <include>com/example/android/sampleapp/StarterActivityTest.java</include>
- </includes>
</configuration>
</plugin>
</plugins>
View
18 script/helpers.rb
@@ -4,6 +4,8 @@
SAMPLE_PACKAGE_DIR = SAMPLE_PACKAGE.gsub('.', "/")
STARTER_PROJECT_DIR = Dir.getwd
ANDROID_HOME = `which android | sed 's|/tools/android$||'`.chomp
+SRC_DIR = "src/main/java"
+TEST_SRC_DIR = "src/test/java"
def bail_with(project)
puts ">>> #{project} failed! <<<"
@@ -100,18 +102,18 @@ def rename_package
return unless validate_package(package)
package_path = package.gsub('.', '/')
- FileUtils.mkdir_p "src/#{package_path}/"
- FileUtils.mkdir_p "test/java/#{package_path}"
+ FileUtils.mkdir_p "#{SRC_DIR}/#{package_path}/"
+ FileUtils.mkdir_p "#{TEST_SRC_DIR}/#{package_path}"
- replace_package(Dir.glob("src/#{SAMPLE_PACKAGE_DIR}/**/*.java"), package, SAMPLE_PACKAGE)
+ replace_package(Dir.glob("#{SRC_DIR}/#{SAMPLE_PACKAGE_DIR}/**/*.java"), package, SAMPLE_PACKAGE)
replace_package(config_files, package, SAMPLE_PACKAGE)
- replace_package(Dir.glob("test/java/#{SAMPLE_PACKAGE_DIR}/**/*.java"), package, SAMPLE_PACKAGE)
+ replace_package(Dir.glob("#{TEST_SRC_DIR}/#{SAMPLE_PACKAGE_DIR}/**/*.java"), package, SAMPLE_PACKAGE)
- move_source_files("src/#{SAMPLE_PACKAGE_DIR}/*", "src/#{package_path}")
- move_source_files("test/java/#{SAMPLE_PACKAGE_DIR}/*", "test/java/#{package_path}")
+ move_source_files("#{SRC_DIR}/#{SAMPLE_PACKAGE_DIR}/*", "#{SRC_DIR}/#{package_path}")
+ move_source_files("#{TEST_SRC_DIR}/#{SAMPLE_PACKAGE_DIR}/*", "#{TEST_SRC_DIR}/#{package_path}")
- FileUtils.rm_rf "src/com/example" unless package.start_with? "com.example"
- FileUtils.rm_rf "test/java/com/example" unless package.start_with? "com.example"
+ FileUtils.rm_rf "#{SRC_DIR}/com/example" unless package.start_with? "com.example"
+ FileUtils.rm_rf "#{TEST_SRC_DIR}/com/example" unless package.start_with? "com.example"
end
def copy_starter_files_to_project_directory(project_directory)
View
23 test/java/com/example/android/sampleapp/StarterActivityWithFestTest.java
@@ -1,23 +0,0 @@
-package com.example.android.sampleapp;
-
-import android.widget.TextView;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-
-import java.io.FileNotFoundException;
-
-import static org.fest.assertions.api.ANDROID.assertThat;
-
-@RunWith(RobolectricTestRunner.class)
-public class StarterActivityWithFestTest {
- @Test
- public void shouldHaveATitle() throws FileNotFoundException {
- final StarterActivity activity = new StarterActivity();
- activity.onCreate(null);
- TextView title = (TextView) activity.findViewById(R.id.title);
- assertThat(title).isNotNull()
- .hasText("Hello World")
- .isVisible();
- }
-}

0 comments on commit d41b1e5

Please sign in to comment.