From c58edaf1df0f66680b072db558bcdb2d67dedf43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Fonseca?= Date: Fri, 6 Jun 2014 10:41:34 +0100 Subject: [PATCH] Bumped version to 0.6. Fixed Migrations trait Added seed file to migrations. --- README.md | 2 +- build.sbt | 2 +- .../db/migrations/Seed.scala | 23 +++++++++++++++++++ .../PACKAGE_NAME_AS_DIR/db/Migration.scala | 4 ++-- src/main/scala/Android.scala | 2 +- src/main/scala/Create.scala | 2 +- src/main/scala/Permissions.scala | 11 ++++++++- 7 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/create/src/main/scala/PACKAGE_NAME_AS_DIR/db/migrations/Seed.scala diff --git a/README.md b/README.md index ffca320..7823fb9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ In most cases, a global installation will make the most sense. This is strongly If you don't already have one, create an `~/.sbt/0.13/plugins` directory. And inside of it, create an `agile-scala-android.sbt` (it doesn't matter what you call it) file containing the line: - addSbtPlugin("pt.pimentelfonseca" % "agile-scala-android" % "0.5") + addSbtPlugin("pt.pimentelfonseca" % "agile-scala-android" % "0.6") Next, you can add the settings `agileAndroidNewProjectTask` globally, which will add just a single task: `npa`. To do this, create a file under `~/.sbt/0.13` called `npa.sbt` (it doesn't matter what you call this either) containing the line: diff --git a/build.sbt b/build.sbt index 2b58409..1704fb3 100644 --- a/build.sbt +++ b/build.sbt @@ -14,7 +14,7 @@ organization := "pt.pimentelfonseca" profileName := "pt.pimentelfonseca" -version := "0.5" +version := "0.6" //scalaVersion := "2.11.0" //libraryDependencies ++= Seq( diff --git a/src/main/resources/create/src/main/scala/PACKAGE_NAME_AS_DIR/db/migrations/Seed.scala b/src/main/resources/create/src/main/scala/PACKAGE_NAME_AS_DIR/db/migrations/Seed.scala new file mode 100644 index 0000000..ce96fd9 --- /dev/null +++ b/src/main/resources/create/src/main/scala/PACKAGE_NAME_AS_DIR/db/migrations/Seed.scala @@ -0,0 +1,23 @@ +package PACKAGE_DB.migrations + +import PACKAGE_DB._ +import PACKAGE_DB.tables._ +import PACKAGE_NAME._ + +import java.util.Date + +import scala.slick.driver.MySQLDriver.simple._ + +class Seed extends Migration { + + override def version = "00:00:00 01/01/2001" + + override def up = + { + App.DB withSession { + implicit session => + } + } + + override def down = ??? +} \ No newline at end of file diff --git a/src/main/resources/database/scala/PACKAGE_NAME_AS_DIR/db/Migration.scala b/src/main/resources/database/scala/PACKAGE_NAME_AS_DIR/db/Migration.scala index 3cf4ae6..06272e8 100644 --- a/src/main/resources/database/scala/PACKAGE_NAME_AS_DIR/db/Migration.scala +++ b/src/main/resources/database/scala/PACKAGE_NAME_AS_DIR/db/Migration.scala @@ -10,7 +10,7 @@ trait Migration { def version: Long = ??? - def up() = ??? + def up() - def down() = ??? + def down() } diff --git a/src/main/scala/Android.scala b/src/main/scala/Android.scala index bbed571..5f261cb 100644 --- a/src/main/scala/Android.scala +++ b/src/main/scala/Android.scala @@ -48,7 +48,7 @@ protected object Android { val manifestFile = findManifestPath(sourceDirectory) - val pemissionsXML = XML.loadFile(manifestFile).child.filter(_.label == "permission") + val pemissionsXML = XML.loadFile(manifestFile).child.filter(_.label == "uses-permission") pemissionsXML.map(_.attribute("http://schemas.android.com/apk/res/android", "name").getOrElse(new Text("")).head.text) } diff --git a/src/main/scala/Create.scala b/src/main/scala/Create.scala index f7afc65..10e7e07 100644 --- a/src/main/scala/Create.scala +++ b/src/main/scala/Create.scala @@ -10,7 +10,7 @@ object Create def templateKeys(sbtVersion: String, pluginVersion: String, packageName: String, minSdkVersion: Int) = { ListMap[String, String]( "SBT_VERSION" -> sbtVersion, - "PLUGIN_VERSION" -> "0.5", + "PLUGIN_VERSION" -> "0.6", "PACKAGE_NAME_AS_DIR" -> packageName.replace('.', '/'), "PACKAGE_NAME" -> packageName, "PACKAGE_MODELS" -> (packageName + ".models"), diff --git a/src/main/scala/Permissions.scala b/src/main/scala/Permissions.scala index d8b6446..5a00a90 100644 --- a/src/main/scala/Permissions.scala +++ b/src/main/scala/Permissions.scala @@ -122,7 +122,7 @@ object Permissions val intentPermissions = mappedIntentPermissions(16) - sourceFilesNoComments.foldLeft(Array[String]()) + val intentPermissionsFound = sourceFilesNoComments.foldLeft(Array[String]()) { (neededPermissions, fileContent) => { @@ -146,6 +146,15 @@ object Permissions } } } + + if (sourceFilesNoComments.exists(_.contains("http://"))) // could also yield false-positives + { + intentPermissionsFound :+ "android.permission.INTERNET" + } + else + { + intentPermissionsFound + } } def analyseNeededPermissions(sourceFiles: Seq[File], temporaryDirectory: File, jarPath: String): Array[String] =