Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/androidlib/java/1-hello-world/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ object app extends AndroidAppModule {
/** Usage

> ./mill show app.test
...compiling 1 Java source...
...compiling 2 Java sources to out/app/test/compile.dest/classes...

> cat out/app/test/testForked.dest/out.json
["",[{"fullyQualifiedName":"com.helloworld.ExampleUnitTest.textSize_isCorrect","selector":"com.helloworld.ExampleUnitTest.textSize_isCorrect","duration":...,"status":"Success"}]]
Expand Down
4 changes: 4 additions & 0 deletions libs/androidlib/src/mill/androidlib/AndroidAppModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ trait AndroidAppModule extends AndroidModule { outer =>
)
}

override def androidAaptNonFinalIds: T[Boolean] = Task {
false
}

/**
* Regex patterns of files to be excluded from packaging into the APK.
*/
Expand Down
47 changes: 36 additions & 11 deletions libs/androidlib/src/mill/androidlib/AndroidModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,44 @@ trait AndroidModule extends JavaModule { outer =>
def androidVersionCode: T[Int] = 1

/**
* Specifies AAPT options for Android resource compilation.
* Specifies AAPT options for Android resource linking.
*/
def androidAaptOptions: T[Seq[String]] = Task {
if (androidIsDebug()) {
Seq(
"--proguard-minimal-keep-rules",
"--debug-mode",
"--auto-add-overlay"
)
} else {
Seq("--auto-add-overlay")
val debugOptions = Seq(
"--proguard-minimal-keep-rules",
"--debug-mode"
)

val extraPackages = androidAaptLinkExtraPackages().flatMap(ns => Seq("--extra-packages", ns))

Seq(
"--auto-add-overlay",
"--no-version-vectors",
"--no-proguard-location-reference"
) ++ extraPackages
++ Option.when(androidAaptNonFinalIds())(Seq("--non-final-ids")).toSeq.flatten
++ Option.when(androidIsDebug())(debugOptions).toSeq.flatten
}

/**
* Collect the namespaces from the Android module dependencies to be
* passed to AAPT during resource linking.
*/
def androidAaptLinkExtraPackages: T[Seq[String]] = Task {
// TODO: cleanup once we properly pass resources from dependencies
recursiveModuleDeps.collect {
case p: AndroidModule => p.androidNamespace
}
}

/**
* Sets whether resource IDs generated by AAPT should be non-final.
* Default is true for non-app modules.
*/
def androidAaptNonFinalIds: T[Boolean] = Task {
true
}

def androidProviderProguardConfigRules: T[Seq[String]] = Task {
val androidNs = "http://schemas.android.com/apk/res/android"
val manifest = androidMergedManifest().path
Expand Down Expand Up @@ -487,7 +511,8 @@ trait AndroidModule extends JavaModule { outer =>
// * it will generate R.java for the library even library has no resources declared
// * R.java will have not only resource ID from this library, but from other libraries as well. They should be stripped.
val rClassDir = androidLinkedResources().path / "generatedSources/java"
val mainRClassPath = os.walk(rClassDir)
val rSources = os.walk(rClassDir).filter(p => os.isFile(p) && p.ext == "java")
val mainRClassPath = rSources
.find(_.last == "R.java")
.get

Expand All @@ -508,7 +533,7 @@ trait AndroidModule extends JavaModule { outer =>
)
} yield PathRef(libRClassPath)

libClasses :+ PathRef(mainRClassPath)
libClasses ++ rSources.map(PathRef(_))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import mill.{T, Task}
@mill.api.experimental
trait AndroidHiltSupport extends KspModule, AndroidKotlinModule {

// Dagger does not work with the bt api
override def kotlincUseBtApi: T[Boolean] = Task {
false
}

override def kspProcessorOptions: T[Map[String, String]] = Task {
super.kspProcessorOptions() ++ Map(
"dagger.fastInit" -> "enabled",
Expand Down