Skip to content

Instantly share code, notes, and snippets.

@pfn
Created September 18, 2013 14:38
Show Gist options
  • Save pfn/6610144 to your computer and use it in GitHub Desktop.
Save pfn/6610144 to your computer and use it in GitHub Desktop.
import android.Keys._
TaskKey[Unit]("check-for-properties") <<= (apkFile) map { a =>
val found = findInArchive(a) (_.getName == "com/example/lib/file.properties")
if (!found) error("Properties not found in APK")
}
def findInArchive(archive: File)(predicate: String => Boolean): Boolean = {
import java.io._
import java.util.zip._
val in = new ZipInputStream(new FileInputStream(archive))
val found = Stream.continually(in.getNextEntry) takeWhile (
_ != null) exists predicate
in.close()
found
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment