Skip to content
Draft
23 changes: 12 additions & 11 deletions example/androidlib/java/1-hello-world/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ object app extends AndroidAppModule {
def androidApplicationId = "com.helloworld.app"
def androidApplicationNamespace = "com.helloworld.app"

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }

override def androidVirtualDeviceIdentifier: String = "java-test"

object test extends AndroidAppTests, TestModule.Junit4 {
Expand All @@ -57,6 +46,18 @@ object app extends AndroidAppModule {
)
}

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
object release extends AndroidReleaseModule {
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
}
}

//// SNIPPET:END
Expand Down
16 changes: 9 additions & 7 deletions example/androidlib/java/2-app-bundle/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ object bundle extends AndroidAppBundle {
def androidSdkModule = mill.api.ModuleRef(androidSdkModule0)
def androidCompileSdk = 35

def androidApplicationId = "com.helloworld.app"
def androidApplicationNamespace = "com.helloworld.app"

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
def androidApplicationId = "com.helloworld.app"
def androidApplicationNamespace = "com.helloworld.app"

def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
object release extends AndroidReleaseModule {
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
}
}

//// SNIPPET:END
Expand Down
10 changes: 0 additions & 10 deletions example/androidlib/java/4-sum-lib-java/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ object lib extends AndroidLibModule, PublishModule {
developers = Seq(Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi"))
)

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }

object test extends AndroidLibTests, TestModule.Junit4 {
def mvnDeps = Seq(mvn"junit:junit:4.13.2")
}
Expand Down
28 changes: 12 additions & 16 deletions example/androidlib/java/5-R8/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,7 @@ object app extends AndroidR8AppModule { // <2>
def androidApplicationId = "com.helloworld.app"
def androidApplicationNamespace = "com.helloworld.app"

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }

override def androidVirtualDeviceIdentifier: String = "java-test"
override def androidIsDebug: T[Boolean] = Task { false }

def androidProjectProguardFiles = Task.Sources(
"proguard-rules.pro"
Expand All @@ -58,10 +46,6 @@ object app extends AndroidR8AppModule { // <2>
object it extends AndroidAppInstrumentedTests, AndroidR8AppModule {
def androidSdkModule = mill.api.ModuleRef(androidSdkModule0)

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

override def androidReleaseSettings: T[AndroidBuildTypeSettings] = Task {
AndroidBuildTypeSettings(isMinifyEnabled = false)
}
Expand All @@ -78,6 +62,18 @@ object app extends AndroidR8AppModule { // <2>
)
}

object release extends AndroidReleaseModule, AndroidR8ReleaseModule

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
}

// <1> Create and configure an Android SDK module to manage Android SDK paths and tools.
Expand Down
22 changes: 12 additions & 10 deletions example/androidlib/java/6-native-libs/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ object app extends AndroidNativeAppModule { // <1>
def androidApplicationId = "com.helloworld.app"
def androidApplicationNamespace = "com.helloworld.app"

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }

override def androidVirtualDeviceIdentifier: String = "java-test"

def androidExternalNativeLibs = Task { // <2>
Expand All @@ -58,6 +48,18 @@ object app extends AndroidNativeAppModule { // <1>
)
}

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
object release extends AndroidReleaseModule, AndroidNativeAppVariantModule {
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
}
}

// <1> You need to extend AndroidNativeLibs trait to use native libraries in the app.
Expand Down
71 changes: 51 additions & 20 deletions example/androidlib/kotlin/1-hello-kotlin/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,10 @@ object app extends AndroidAppKotlinModule {
def androidApplicationId = "com.helloworld.app"
def androidApplicationNamespace = "com.helloworld.app"

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
override def androidVirtualDeviceIdentifier: String = "kotlin-test"
override def androidEmulatorPort: String = "5556"

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

object test extends AndroidAppKotlinTests, TestModule.Junit4 {
def junit4Version = "4.13.2"
Expand All @@ -55,7 +45,7 @@ object app extends AndroidAppKotlinModule {
// configuration but the apk signature will not match
// the app apk
override def androidIsDebug: T[Boolean] = Task {
false
true
}

def mvnDeps = Seq(
Expand All @@ -65,6 +55,20 @@ object app extends AndroidAppKotlinModule {
mvn"junit:junit:4.13.2"
)
}

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
object release extends AndroidKotlinReleaseModule {
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
override def androidEmulatorPort = "5654"
}
}

//// SNIPPET:END
Expand Down Expand Up @@ -117,7 +121,13 @@ object app extends AndroidAppKotlinModule {

*/

// This command runs unit tests on your local environment.
// The android tests (existing typically in androidTest directory, aka instrumented tests)
// typically run on an android device.
// The createAndroidVirtualDevice command creates an AVD (Android Virtual Device)
// and the startAndroidEmulator command starts the AVD. The it task runs the integration tests
// against the available AVD. The stopAndroidEmulator command stops the AVD and the
// destroyAndroidVirtualDevice command destroys the AVD.
// The provided commands can be used in a CI/CD pipeline assuming the right setup is in place.

/** Usage

Expand Down Expand Up @@ -162,10 +172,31 @@ object app extends AndroidAppKotlinModule {

*/

// The android tests (existing typically in androidTest directory, aka instrumented tests)
// typically run on an android device.
// The createAndroidVirtualDevice command creates an AVD (Android Virtual Device)
// and the startAndroidEmulator command starts the AVD. The it task runs the integration tests
// against the available AVD. The stopAndroidEmulator command stops the AVD and the
// destroyAndroidVirtualDevice command destroys the AVD.
// The provided commands can be used in a CI/CD pipeline assuming the right setup is in place.
// To create a release apk and run it, you can use the configured release submodule.
// Every AndroidAppModule can be configured with its own emulator, so you can easily
// avoid signature mismatches between debug and release as follows.

/** Usage

> ./mill app.release.createAndroidVirtualDevice

> ./mill show app.release.startAndroidEmulator

> ./mill app.release.androidInstall

> ./mill show app.release.androidRun --activity com.helloworld.app.MainActivity
[
"Starting: Intent { cmp=com.helloworld.app/.MainActivity }",
"Status: ok",
"LaunchState: COLD",
"Activity: com.helloworld.app/.MainActivity",
"TotalTime: ...",
"WaitTime: ...",
"Complete"
]

> ./mill show app.release.stopAndroidEmulator

> ./mill show app.release.deleteAndroidVirtualDevice

*/
Binary file not shown.
12 changes: 12 additions & 0 deletions example/androidlib/kotlin/2-compose/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ object app extends AndroidAppKotlinModule {
mvn"androidx.tracing:tracing:1.2.0"
)

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
object release extends AndroidKotlinReleaseModule {
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
}
}

//// SNIPPET:END
Expand Down
24 changes: 13 additions & 11 deletions example/androidlib/kotlin/4-sum-lib-kotlin/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ object lib extends AndroidLibKotlinModule, PublishModule {
developers = Seq(Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi"))
)

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }

object test extends AndroidLibKotlinTests, TestModule.Junit4 {
def junit4Version = "4.13.2"
}
Expand Down Expand Up @@ -78,6 +67,19 @@ object app extends AndroidAppKotlinModule {
object test extends AndroidAppKotlinTests, TestModule.Junit4 {
def junit4Version = "4.13.2"
}

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
object release extends AndroidKotlinReleaseModule {
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
}
}

//// SNIPPET:END
Expand Down
26 changes: 10 additions & 16 deletions example/thirdparty/android-endless-tunnel/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,23 @@ object `endless-tunnel` extends mill.api.Module {

override def androidNativeLibName: T[String] = "libgame"

override def androidVirtualDeviceIdentifier: String = "cpp-test"

override def androidCMakeExtraArgs: T[Seq[String]] =
super.androidCMakeExtraArgs() ++ Seq("-DANDROID_STL=c++_static")

/**
* Configuration for ReleaseKey
* WARNING: Replace these default values with secure and private credentials before using in production.
* Never use these defaults in a production environment as they are not secure.
* This is just for testing purposes.
*/
def androidReleaseKeyAlias: T[Option[String]] = Task {
Some("releaseKey")
}

def androidReleaseKeyPass: T[Option[String]] = Task {
Some("MillBuildTool")
object release extends AndroidReleaseModule, AndroidNativeAppVariantModule {
def androidReleaseKeyName: Option[String] = Some("releaseKey.jks")
def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") }
def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") }
def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") }
}

def androidReleaseKeyStorePass: T[Option[String]] = Task {
Some("MillBuildTool")
}

override def androidVirtualDeviceIdentifier: String = "cpp-test"

override def androidCMakeExtraArgs: T[Seq[String]] =
super.androidCMakeExtraArgs() ++ Seq("-DANDROID_STL=c++_static")

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,11 @@ trait AndroidAppKotlinModule extends AndroidKotlinModule, AndroidAppModule { out

}

trait AndroidAppKotlinVariantModule extends AndroidKotlinVariantModule, AndroidAppKotlinModule {
override def sources: T[Seq[PathRef]] = outer.sources
override def resolutionParams: Task[ResolutionParams] = Task.Anon(outer.resolutionParams())
}

trait AndroidKotlinReleaseModule extends AndroidReleaseModule, AndroidAppKotlinVariantModule

}
Loading