1+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+ plugins {
4+ id(" com.android.application" )
5+ id(" org.jetbrains.kotlin.android" )
6+ id(" org.jetbrains.kotlin.plugin.serialization" )
7+ id(" com.github.node-gradle.node" )
8+ }
9+
10+ android {
11+ namespace = " io.template.polywrap"
12+ compileSdk = 33
13+
14+ defaultConfig {
15+ applicationId = " io.template.polywrap"
16+ minSdk = 24
17+ targetSdk = 33
18+ versionCode = 1
19+ versionName = " 1.0"
20+
21+ testInstrumentationRunner = " androidx.test.runner.AndroidJUnitRunner"
22+ vectorDrawables {
23+ useSupportLibrary = true
24+ }
25+ }
26+
27+ buildTypes {
28+ release {
29+ isMinifyEnabled = false
30+ proguardFiles(
31+ getDefaultProguardFile(" proguard-android-optimize.txt" ),
32+ " proguard-rules.pro"
33+ )
34+ }
35+ }
36+ compileOptions {
37+ sourceCompatibility = JavaVersion .VERSION_17
38+ targetCompatibility = JavaVersion .VERSION_17
39+ }
40+ kotlinOptions {
41+ jvmTarget = " 17"
42+ }
43+ buildFeatures {
44+ compose = true
45+ }
46+ composeOptions {
47+ kotlinCompilerExtensionVersion = " 1.4.8"
48+ }
49+ packaging {
50+ resources {
51+ excludes + = " /META-INF/{AL2.0,LGPL2.1}"
52+ }
53+ }
54+ }
55+
56+ dependencies {
57+ // polywrap client
58+ implementation(" io.polywrap:polywrap-client:0.10.4" )
59+ implementation(" org.jetbrains.kotlinx:kotlinx-serialization-core:1.5.1" )
60+ // polywrap logger plugin
61+ implementation(" io.polywrap.plugins:logger:0.10.4" )
62+ implementation(" com.github.tony19:logback-android:3.0.0" )
63+
64+ // ui
65+ implementation(" androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1" )
66+
67+ // defaults
68+ implementation(" androidx.core:core-ktx:1.10.1" )
69+ implementation(" androidx.lifecycle:lifecycle-runtime-ktx:2.6.1" )
70+ implementation(" androidx.activity:activity-compose:1.7.2" )
71+ implementation(platform(" androidx.compose:compose-bom:2023.03.00" ))
72+ implementation(" androidx.compose.ui:ui" )
73+ implementation(" androidx.compose.ui:ui-graphics" )
74+ implementation(" androidx.compose.ui:ui-tooling-preview" )
75+ implementation(" androidx.compose.material3:material3" )
76+ testImplementation(" junit:junit:4.13.2" )
77+ androidTestImplementation(" androidx.test.ext:junit:1.1.5" )
78+ androidTestImplementation(" androidx.test.espresso:espresso-core:3.5.1" )
79+ androidTestImplementation(platform(" androidx.compose:compose-bom:2023.03.00" ))
80+ androidTestImplementation(" androidx.compose.ui:ui-test-junit4" )
81+ debugImplementation(" androidx.compose.ui:ui-tooling" )
82+ debugImplementation(" androidx.compose.ui:ui-test-manifest" )
83+ }
84+
85+ // set up NodeJS to run the Polywrap CLI
86+ // NodeJS installation will be stored in gradle cache
87+ node {
88+ val nullString: String? = null
89+ distBaseUrl.set(nullString)
90+ // Whether to download and install a specific Node.js version or not
91+ // If false, it will use the globally installed Node.js
92+ // If true, it will download node using above parameters
93+ // Note that npm is bundled with Node.js
94+ download.set(true )
95+ }
96+
97+ // run polwyrap codegen
98+ tasks.register< com.github.gradle.node.npm.task.NpxTask > (" codegen" ) {
99+ group = " polywrap"
100+ dependsOn(tasks.npmInstall)
101+ command.set(" polywrap" )
102+ args.set(listOf (" codegen" ,
103+ " -m" , " $rootDir /polywrap.yaml" ,
104+ " -g" , " $projectDir /src/main/java/wrap"
105+ ))
106+ }
107+
108+ // set polywrap codegen to run before each build
109+ tasks.withType<KotlinCompile > { dependsOn(" codegen" ) }
0 commit comments