Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 12 commits
  • 9 files changed
  • 0 commit comments
  • 3 contributors
Commits on Dec 28, 2011
@ezh ezh add ability to predex external libraries 8d34425
Commits on Dec 31, 2011
@ezh ezh fix updated source verification cae90bd
Commits on Jan 14, 2012
@ezh ezh add ability to filter predex libraries
for example dxOpts in Android := ("-JXmx512m", Some(Seq(".*/digilib.*")))
dced1e9
Commits on Apr 24, 2012
@jberkel jberkel Adding travis.yml 5623dbd
Commits on May 01, 2012
@jberkel jberkel Add support for bundle packaging type 9a8b1e5
Commits on May 07, 2012
@jberkel jberkel use sbt 0.11.3 da94226
Commits on May 18, 2012
@rst rst Tell ProGuard to preserve serialization hooks.
Without specific notice, ProGuard will lop off readObject, readResolve, etc.,
which can lead to baffling failures, even when just serializing library
classes.  For example, if you're serializing Scala Option[T] objects, losing
readResolve can get you duplicates of None, which is ordinarily a singleton;
that, in turn, can lead to spurious, and very strange-looking MatchExceptions.
a58c221
Commits on May 20, 2012
@jberkel jberkel Merge pull request #131 from rst/serialization-fix
Tell ProGuard to preserve serialization hooks.  (re: issue 122)
99639f8
@jberkel jberkel Adding travis ci link e145b97
Commits on May 23, 2012
@ezh ezh Merge branch 'master' of https://github.com/jberkel/android-plugin.git 2b9185a
Commits on May 24, 2012
@jberkel jberkel Merge pull request #107 from ezh/master
add ability to predex external libraries
164565f
@jberkel jberkel notes 89a7487
View
1 .travis.yml
@@ -0,0 +1 @@
+language: scala
View
2 README.md
@@ -45,6 +45,8 @@ This code is based on work by Walter Chang
A lot of people have contributed to the plugin; see [contributors][] for a full
list.
+[![Build Status](https://secure.travis-ci.org/jberkel/android-plugin.png?branch=master)](http://travis-ci.org/jberkel/android-plugin)
+
[sbt]: https://github.com/harrah/xsbt/wiki
[scala-on-android]: http://groups.google.com/group/scala-on-android
[simple-build-tool]: http://groups.google.com/group/simple-build-tool
View
2 build.sbt
@@ -4,7 +4,7 @@ organization := "org.scala-sbt"
version := "0.6.2-SNAPSHOT"
-scalacOptions += "-deprecation"
+scalacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-Xfatal-warnings")
publishMavenStyle := false
View
4 notes/0.6.2.markdown
@@ -8,8 +8,12 @@
* Parse output from Android instrumentation tests ([Jan Berkel][jberkel])
+* Add ability to predex external libraries ([PR-107][], [ezh][ezh])
+
[jberkel]: https://github.com/jberkel
[appamatto]: https://github.com/appamatto
+[ezh]: https://github.com/ezh
[PR-123]: https://github.com/jberkel/android-plugin/pull/123
[PR-124]: https://github.com/jberkel/android-plugin/pull/124
[GH-125]: https://github.com/jberkel/android-plugin/issues/125
+[PR-107]: https://github.com/jberkel/android-plugin/pull/107
View
2 project/build.properties
@@ -1 +1 @@
-sbt.version=0.11.2
+sbt.version=0.11.3
View
8 src/main/scala/AndroidBase.scala
@@ -198,8 +198,8 @@ object AndroidBase {
(libPath, classDirectory, resourceDirectory) =>
libPath :+ classDirectory :+ resourceDirectory
},
- proguardInJars <<= (fullClasspath, proguardExclude, preinstalledModules) map {
- (fullClasspath, proguardExclude, preinstalledModules) =>
+ proguardInJars <<= (fullClasspath, proguardExclude, preinstalledModules, classpathTypes in Compile) map {
+ (fullClasspath, proguardExclude, preinstalledModules, classpathTypes) =>
// remove preinstalled jars
fullClasspath.filterNot( cp =>
cp.get(moduleID.key).map( module => preinstalledModules.exists( m =>
@@ -208,14 +208,14 @@ object AndroidBase {
).getOrElse(false)
// only include jar files
).filter( cp =>
- cp.get(artifact.key).map(artifact => artifact.`type` == "jar").getOrElse(true)
+ cp.get(artifact.key).map(artifact => (classpathTypes - "so").contains(artifact.`type`)).getOrElse(true)
).map(_.data) --- proguardExclude get
},
makeManagedJavaPath <<= directory(managedJavaPath),
copyNativeLibraries <<= copyNativeLibrariesTask,
- classpathTypes in Compile := Set("jar", "so"),
+ classpathTypes in Compile := Set("jar", "bundle", "so"),
apklibSources <<= apklibSourcesTask,
aaptGenerate <<= aaptGenerateTask,
View
4 src/main/scala/AndroidDefault.scala
@@ -15,7 +15,7 @@ object AndroidDefaults {
val DefaultClassesMinJarName = "classes.min.jar"
val DefaultClassesDexName = "classes.dex"
val DefaultResourcesApkName = "resources.apk"
- val DefaultDxJavaOpts = "-JXmx512m"
+ val DefaultDxOpts = ("-JXmx512m", None)
val DefaultManifestSchema = "http://schemas.android.com/apk/res/android"
val DefaultEnvs = List("ANDROID_SDK_HOME", "ANDROID_SDK_ROOT", "ANDROID_HOME")
@@ -31,7 +31,7 @@ object AndroidDefaults {
classesMinJarName := DefaultClassesMinJarName,
classesDexName := DefaultClassesDexName,
resourcesApkName := DefaultResourcesApkName,
- dxJavaOpts := DefaultDxJavaOpts,
+ dxOpts := DefaultDxOpts,
manifestSchema := DefaultManifestSchema,
envs := DefaultEnvs,
// a list of modules which are already included in Android
View
91 src/main/scala/AndroidInstall.scala
@@ -40,24 +40,70 @@ object AndroidInstall {
}
private def dxTask: Project.Initialize[Task[File]] =
- (dxPath, dxInputs, dxJavaOpts, proguardOptimizations, classDirectory, classesDexPath, streams) map {
- (dxPath, dxInputs, dxJavaOpts, proguardOptimizations, classDirectory, classesDexPath, streams) =>
-
- val uptodate = classesDexPath.exists &&
- !(dxInputs +++ (classDirectory ** "*.class") get).exists (_.lastModified > classesDexPath.lastModified)
-
- if (!uptodate) {
- val noLocals = if (proguardOptimizations.isEmpty) "" else "--no-locals"
- val dxCmd = (Seq(dxPath.absolutePath,
- dxMemoryParameter(dxJavaOpts),
- "--dex", noLocals,
- "--num-threads="+java.lang.Runtime.getRuntime.availableProcessors,
- "--output="+classesDexPath.absolutePath) ++
- dxInputs.get.map(_.absolutePath)).filter(_.length > 0)
- streams.log.debug(dxCmd.mkString(" "))
- streams.log.info("Dexing "+classesDexPath)
- streams.log.debug(dxCmd !!)
- } else streams.log.debug("dex file uptodate, skipping")
+ (dxPath, dxInputs, dxOpts, proguardOptimizations, classDirectory, classesDexPath, scalaInstance, streams) map {
+ (dxPath, dxInputs, dxOpts, proguardOptimizations, classDirectory, classesDexPath, scalaInstance, streams) =>
+
+ def dexing(inputs: Seq[JFile], output: JFile) {
+ val uptodate = output.exists && inputs.forall(input =>
+ input.isDirectory match {
+ case true =>
+ (input ** "*").get.forall(_.lastModified <= output.lastModified)
+ case false =>
+ input.lastModified <= output.lastModified
+ }
+ )
+
+ if (!uptodate) {
+ val noLocals = if (proguardOptimizations.isEmpty) "" else "--no-locals"
+ val dxCmd = (Seq(dxPath.absolutePath,
+ dxMemoryParameter(dxOpts._1),
+ "--dex", noLocals,
+ "--num-threads="+java.lang.Runtime.getRuntime.availableProcessors,
+ "--output="+output.getAbsolutePath) ++
+ inputs.map(_.absolutePath)).filter(_.length > 0)
+ streams.log.debug(dxCmd.mkString(" "))
+ streams.log.info("Dexing "+output.getAbsolutePath)
+ streams.log.debug(dxCmd !!)
+ } else streams.log.debug("dex file " + output.getAbsolutePath + " uptodate, skipping")
+ }
+
+ // Option[Seq[String]]
+ // - None standard dexing for prodaction stage
+ // - Some(Seq(predex_library_regexp)) predex only changed libraries for development stage
+ dxOpts._2 match {
+ case None =>
+ dexing(dxInputs.get, classesDexPath)
+ case Some(predex) =>
+ val (dexFiles, predexFiles) = predex match {
+ case exceptSeq: Seq[_] if exceptSeq.nonEmpty =>
+ val (filtered, orig) = dxInputs.get.partition(file =>
+ exceptSeq.exists(filter => {
+ streams.log.debug("apply filter \"" + filter + "\" to \"" + file.getAbsolutePath + "\"")
+ file.getAbsolutePath.matches(filter)
+ }))
+ // dex only classes directory ++ filtered, predex all other
+ ((classDirectory --- scalaInstance.libraryJar).get ++ filtered, orig)
+ case _ =>
+ // dex only classes directory, predex all other
+ ((classDirectory --- scalaInstance.libraryJar).get, (dxInputs --- classDirectory).get)
+ }
+ dexFiles.foreach(s => streams.log.debug("pack in dex \"" + s.getName + "\""))
+ predexFiles.foreach(s => streams.log.debug("pack in predex \"" + s.getName + "\""))
+ // dex
+ dexing(dexFiles, classesDexPath)
+ // predex
+ predexFiles.get.foreach(f => {
+ val predexPath = new JFile(classesDexPath.getParent, "predex")
+ if (!predexPath.exists)
+ predexPath.mkdir
+ val output = new File(predexPath, f.getName)
+ val outputPermissionDescriptor = new File(predexPath, f.getName.replaceFirst(".jar$", ".xml"))
+ dexing(Seq(f), output)
+ val permission = <permissions><library name={ f.getName.replaceFirst(".jar$", "") } file={ "/data/" + f.getName } /></permissions>
+ val p = new java.io.PrintWriter(outputPermissionDescriptor)
+ try { p.println(permission) } finally { p.close() }
+ })
+ }
classesDexPath
}
@@ -94,6 +140,15 @@ object AndroidInstall {
"-keep public class * extends android.app.Application" ::
"-keep public class "+manifestPackage+".** { public protected *; }" ::
"-keep public class * implements junit.framework.Test { public void test*(); }" ::
+ """
+ -keepclassmembers class * implements java.io.Serializable {
+ private static final java.io.ObjectStreamField[] serialPersistentFields;
+ private void writeObject(java.io.ObjectOutputStream);
+ private void readObject(java.io.ObjectInputStream);
+ java.lang.Object writeReplace();
+ java.lang.Object readResolve();
+ }
+ """ ::
proguardOption :: Nil )
val config = new ProGuardConfiguration
new ConfigurationParser(args.toArray[String]).parse(config)
View
2 src/main/scala/AndroidKeys.scala
@@ -32,7 +32,7 @@ object AndroidKeys {
val classesMinJarName = SettingKey[String]("classes-min-jar-name")
val classesDexName = SettingKey[String]("classes-dex-name")
val resourcesApkName = SettingKey[String]("resources-apk-name")
- val dxJavaOpts = SettingKey[String]("dx-java-opts")
+ val dxOpts = SettingKey[Tuple2[String, Option[Seq[String]]]]("dx-opts")
val manifestSchema = SettingKey[String]("manifest-schema")
val envs = SettingKey[Seq[String]]("envs")
val preinstalledModules = SettingKey[Seq[ModuleID]]("preinstalled-modules")

No commit comments for this range

Something went wrong with that request. Please try again.