<commit_before>package android

import sbt._
import sbt.Keys._
import classpath.ClasspathUtilities

import scala.collection.JavaConverters._
import scala.collection.JavaConversions._
import scala.util.control.Exception._
import scala.xml._

import java.util.Properties
import java.io.{File,FileInputStream}

import com.android.SdkConstants
import com.android.builder.model.{PackagingOptions, AaptOptions}
import com.android.builder.signing.{KeystoreHelper, DefaultSigningConfig}
import com.android.builder.AndroidBuilder
import com.android.builder.DexOptions
import com.android.builder.VariantConfiguration
import com.android.builder.dependency.{LibraryDependency => AndroidLibrary}
import com.android.ddmlib.IShellOutputReceiver
import com.android.ddmlib.DdmPreferences
import com.android.ddmlib.testrunner.ITestRunListener
import com.android.ide.common.res2.FileStatus
import com.android.ide.common.res2.FileValidity
import com.android.ide.common.res2.MergedResourceWriter
import com.android.ide.common.res2.ResourceMerger
import com.android.ide.common.res2.ResourceSet
import com.android.sdklib.IAndroidTarget
import com.android.sdklib.BuildToolInfo.PathId
import com.android.utils.ILogger

import proguard.{Configuration => PgConfig, ProGuard, ConfigurationParser}

import Keys._
import Dependencies._
import com.android.builder.compiling.BuildConfigGenerator
import java.net.URLEncoder

object Tasks {
  val ANDROID_NS = "http://schemas.android.com/apk/res/android"
  val INSTRUMENTATION_TAG = "instrumentation"
  val USES_LIBRARY_TAG = "uses-library"
  val APPLICATION_TAG = "application"
  val ANDROID_PREFIX = "android"
  val TEST_RUNNER_LIB = "android.test.runner"

  // TODO come up with a better solution
  // wish this could be protected
  var _createDebug = true

  val reservedWords = Set(
    "def",
    "forSome",
    "implicit",
    "lazy",
    "match",
    "object",
    "override",
    "sealed",
    "trait",
    "type",
    "val",
    "var",
    "with",
    "yield"
  )

  def createDebug = _createDebug
  private def createDebug_=(d: Boolean) = _createDebug = d

  def resourceUrl =
    Plugin.getClass.getClassLoader.getResource _

  val buildConfigGeneratorTaskDef = ( platformTarget
                                    , genPath
                                    , libraryProjects
                                    , packageForR
                                    ) map {
    (t, g, l, p) =>
    val b = new BuildConfigGenerator(g.getAbsolutePath, p)
    b.addField("boolean", "DEBUG", createDebug.toString)
    b.generate()
    l collect {
      case a: ApkLibrary         => a
      case a: AutoLibraryProject => a
    } foreach { lib =>
      val b = new BuildConfigGenerator(g.getAbsolutePath, lib.pkg)
      b.addField("boolean", "DEBUG", createDebug.toString)
      b.generate()
    }
    g ** "BuildConfig.java" get
  }

  def moduleForFile(u: UpdateReport, f: File): ModuleID = {
    val map: Map[File,ModuleID] =
      u.configurations.flatMap(_.modules).distinct.flatMap { m =>
        m.artifacts map { case (_,file) => (file,m.module) }
      } toMap

    map(f)
  }
  def moduleString(m: ModuleID) =
    m.organization + ":" + m.name + ":" + m.revision

  // fails poorly if windows' exclusive locks are preventing a proper clean
  val aarsTaskDef = ( update in Compile
                    , localAars
                    , libraryDependencies in Compile<commit_msg>do not match revision when unpacking apklib/aar<commit_after>package android

import sbt._
import sbt.Keys._
import classpath.ClasspathUtilities

import scala.collection.JavaConverters._
import scala.collection.JavaConversions._
import scala.util.control.Exception._
import scala.xml._

import java.util.Properties
import java.io.{File,FileInputStream}

import com.android.SdkConstants
import com.android.builder.model.{PackagingOptions, AaptOptions}
import com.android.builder.signing.{KeystoreHelper, DefaultSigningConfig}
import com.android.builder.AndroidBuilder
import com.android.builder.DexOptions
import com.android.builder.VariantConfiguration
import com.android.builder.dependency.{LibraryDependency => AndroidLibrary}
import com.android.ddmlib.IShellOutputReceiver
import com.android.ddmlib.DdmPreferences
import com.android.ddmlib.testrunner.ITestRunListener
import com.android.ide.common.res2.FileStatus
import com.android.ide.common.res2.FileValidity
import com.android.ide.common.res2.MergedResourceWriter
import com.android.ide.common.res2.ResourceMerger
import com.android.ide.common.res2.ResourceSet
import com.android.sdklib.IAndroidTarget
import com.android.sdklib.BuildToolInfo.PathId
import com.android.utils.ILogger

import proguard.{Configuration => PgConfig, ProGuard, ConfigurationParser}

import Keys._
import Dependencies._
import com.android.builder.compiling.BuildConfigGenerator
import java.net.URLEncoder

object Tasks {
  val ANDROID_NS = "http://schemas.android.com/apk/res/android"
  val INSTRUMENTATION_TAG = "instrumentation"
  val USES_LIBRARY_TAG = "uses-library"
  val APPLICATION_TAG = "application"
  val ANDROID_PREFIX = "android"
  val TEST_RUNNER_LIB = "android.test.runner"

  // TODO come up with a better solution
  // wish this could be protected
  var _createDebug = true

  val reservedWords = Set(
    "def",
    "forSome",
    "implicit",
    "lazy",
    "match",
    "object",
    "override",
    "sealed",
    "trait",
    "type",
    "val",
    "var",
    "with",
    "yield"
  )

  def createDebug = _createDebug
  private def createDebug_=(d: Boolean) = _createDebug = d

  def resourceUrl =
    Plugin.getClass.getClassLoader.getResource _

  val buildConfigGeneratorTaskDef = ( platformTarget
                                    , genPath
                                    , libraryProjects
                                    , packageForR
                                    ) map {
    (t, g, l, p) =>
    val b = new BuildConfigGenerator(g.getAbsolutePath, p)
    b.addField("boolean", "DEBUG", createDebug.toString)
    b.generate()
    l collect {
      case a: ApkLibrary         => a
      case a: AutoLibraryProject => a
    } foreach { lib =>
      val b = new BuildConfigGenerator(g.getAbsolutePath, lib.pkg)
      b.addField("boolean", "DEBUG", createDebug.toString)
      b.generate()
    }
    g ** "BuildConfig.java" get
  }

  def moduleForFile(u: UpdateReport, f: File): ModuleID = {
    val map: Map[File,ModuleID] =
      u.configurations.flatMap(_.modules).distinct.flatMap { m =>
        m.artifacts map { case (_,file) => (file,m.module) }
      } toMap

    map(f)
  }
  def moduleString(m: ModuleID) = m.organization + ":" + m.name

  // fails poorly if windows' exclusive locks are preventing a proper clean
  val aarsTaskDef = ( update in Compile
                    , localAars
                    , libraryDependencies in Compile
{'fraction_non_alphanumeric': 0.09916507983008642, 'fraction_numerical': 0.0014647722279185586, 'mean_word_length': 3.1558125380401703, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4391287', 'n_tokens_mistral': 2078, 'n_tokens_neox': 2032, 'n_words': 452}