Skip to content

Instantly share code, notes, and snippets.

@loganj
Created January 31, 2012 06:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loganj/1709186 to your computer and use it in GitHub Desktop.
Save loganj/1709186 to your computer and use it in GitHub Desktop.
Sample config for android-plugin/library pull request
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.gist.apklibsample">
<application
android:icon="@drawable/android:star_big_on"
android:label="@string/app_name"
android:debuggable="true">
<activity android:label="@string/app_name" android:name=".MainActivity" android:theme="@style/Theme.Sherlock">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.github.gist.apklibsample.tests">
<application>
<activity android:name=".MainActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<uses-library android:name="android.test.runner"/>
</application>
<instrumentation android:label="Tests"
android:targetPackage="com.github.gist.apklibsample"
android:name="android.test.InstrumentationTestRunner"/>
<uses-sdk android:minSdkVersion="15"/>
</manifest>
import sbt._
import Keys._
import AndroidKeys._
object General {
val settings = Defaults.defaultSettings ++ Seq (
name := "Apklib Sample",
version := "0.1",
versionCode := 0,
scalaVersion := "2.9.1",
platformName in Android := "android-15",
resolvers += "ActionBarSherlock snapshots" at "http://r.jakewharton.com/maven/snapshot/"
)
val proguardSettings = Seq (
useProguard in Android := true
)
lazy val fullAndroidSettings =
General.settings ++
AndroidProject.androidSettings ++
TypedResources.settings ++
proguardSettings ++
AndroidManifestGenerator.settings ++
AndroidMarketPublish.settings ++ Seq (
keyalias in Android := "change-me",
libraryDependencies += "org.scalatest" %% "scalatest" % "1.7.RC1" % "test"
)
}
object AndroidBuild extends Build {
lazy val main = Project (
"Apklib Sample",
file("."),
settings = General.fullAndroidSettings
)
lazy val tests = Project (
"tests",
file("tests"),
settings = General.settings ++
AndroidTest.settings ++
General.proguardSettings ++ Seq (
name := "Apklib SampleTests"
)
) dependsOn main
}
import sbt._
import Keys._
import AndroidKeys._
libraryDependencies ++= Seq(
"com.actionbarsherlock" % "library" % "4.0.0-SNAPSHOT" artifacts(Artifact("library", "apklib", "apklib")),
"android" % "compatibility-v4" % "r3-SNAPSHOT"
)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
package com.github.gist.apklibsample
import _root_.android.app.Activity
import _root_.android.os.Bundle
import com.actionbarsherlock.app.SherlockActivity
class MainActivity extends SherlockActivity with TypedActivity {
override def onCreate(bundle: Bundle) {
super.onCreate(bundle)
setContentView(R.layout.main)
findView(TR.textview).setText("hello, world!")
}
}
resolvers += "nexus snapshots" at "http://nexus.scala-tools.org/content/repositories/snapshots"
addSbtPlugin("org.scala-tools.sbt" % "sbt-android-plugin" % "0.6.1-SNAPSHOT")
resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"
addSbtPlugin("com.github.mpeltonen" %% "sbt-idea" % "1.0.0")
import com.github.gist.apklibsample
import org.scalatest.matchers.ShouldMatchers
import org.scalatest.FunSpec
class Specs extends FunSpec with ShouldMatchers {
describe("a spec") {
it("should do something") {
}
}
}
<resources>
<string name="app_name">Apklib Sample</string>
</resources>
<resources>
<string name="app_name">Apklib Sample</string>
</resources>
package com.github.gist.apklibsample.tests
import com.github.gist.apklibsample._
import junit.framework.Assert._
import _root_.android.test.AndroidTestCase
import _root_.android.test.ActivityInstrumentationTestCase2
class AndroidTests extends AndroidTestCase {
def testPackageIsCorrect() {
assertEquals("com.github.gist.apklibsample", getContext.getPackageName)
}
}
class ActivityTests extends ActivityInstrumentationTestCase2(classOf[MainActivity]) {
def testHelloWorldIsShown() {
val activity = getActivity
val textview = activity.findView(TR.textview)
assertEquals(textview.getText, "hello, world!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment