diff --git a/.gitignore b/.gitignore index a1c2a238a9..9c5ac3d9ed 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +templates/mpp-template/.idea/** +templates/desktop-template/.idea/** \ No newline at end of file diff --git a/README.md b/README.md index 2439ffa88b..e4088f7758 100644 --- a/README.md +++ b/README.md @@ -13,5 +13,5 @@ at https://android.googlesource.com/platform/frameworks/support. * `imageviewer` - Image Viewer application for Android and Desktop * `issues` - GitHub issue tracker with an adaptive UI and ktor-client * `gradle-plugin` - plugin for simpler usage of Compose with Gradle build - * `templates` - new application templates (see `app-template/build_and_run_from_cli_example.sh` for using without Gradle) + * `templates` - new application templates (see `desktop-template/build_and_run_from_cli_example.sh` for using without Gradle) * `tutorials` - tutorials on using Compose for Desktop diff --git a/gradle-plugin/.idea/vcs.xml b/gradle-plugin/.idea/vcs.xml index 35eb1ddfbb..62bd7a01e9 100644 --- a/gradle-plugin/.idea/vcs.xml +++ b/gradle-plugin/.idea/vcs.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/templates/app-template/.gitignore b/templates/app-template/.gitignore deleted file mode 100644 index f8b92c3aa0..0000000000 --- a/templates/app-template/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.gradle -build diff --git a/templates/app-template/.idea/.gitignore b/templates/app-template/.idea/.gitignore deleted file mode 100644 index 73f69e0958..0000000000 --- a/templates/app-template/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/templates/app-template/.idea/codeStyles/Project.xml b/templates/app-template/.idea/codeStyles/Project.xml deleted file mode 100644 index 31d977a0b2..0000000000 --- a/templates/app-template/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/templates/app-template/.idea/codeStyles/codeStyleConfig.xml b/templates/app-template/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index 79ee123c2b..0000000000 --- a/templates/app-template/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/templates/app-template/.idea/compiler.xml b/templates/app-template/.idea/compiler.xml deleted file mode 100644 index ac216bc822..0000000000 --- a/templates/app-template/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/templates/app-template/.idea/gradle.xml b/templates/app-template/.idea/gradle.xml deleted file mode 100644 index 611e7c8ad7..0000000000 --- a/templates/app-template/.idea/gradle.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/templates/app-template/.idea/jarRepositories.xml b/templates/app-template/.idea/jarRepositories.xml deleted file mode 100644 index 37805f73ec..0000000000 --- a/templates/app-template/.idea/jarRepositories.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/templates/app-template/.idea/misc.xml b/templates/app-template/.idea/misc.xml deleted file mode 100644 index c7ce6bd3ca..0000000000 --- a/templates/app-template/.idea/misc.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/templates/app-template/.idea/vcs.xml b/templates/app-template/.idea/vcs.xml deleted file mode 100644 index 94a25f7f4c..0000000000 --- a/templates/app-template/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/templates/app-template/gradle.properties b/templates/app-template/gradle.properties deleted file mode 100644 index 29e08e8ca8..0000000000 --- a/templates/app-template/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -kotlin.code.style=official \ No newline at end of file diff --git a/templates/app-template/src/main/kotlin/main.kt b/templates/app-template/src/main/kotlin/main.kt deleted file mode 100644 index 396ab388fe..0000000000 --- a/templates/app-template/src/main/kotlin/main.kt +++ /dev/null @@ -1,23 +0,0 @@ -import androidx.compose.desktop.Window -import androidx.compose.foundation.Text -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp - -fun main() { - Window { - Column(Modifier.fillMaxSize(), Arrangement.SpaceEvenly) { - Text( - text = "Привет! 你好! Desktop Compose", - color = Color.Black, - modifier = Modifier - .background(Color.Blue) - .preferredHeight(56.dp) - .wrapContentSize(Alignment.Center) - ) - } - } -} \ No newline at end of file diff --git a/templates/desktop-template/.gitignore b/templates/desktop-template/.gitignore new file mode 100644 index 0000000000..81b4fd153d --- /dev/null +++ b/templates/desktop-template/.gitignore @@ -0,0 +1,88 @@ +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof \ No newline at end of file diff --git a/templates/desktop-template/.run/desktop.run.xml b/templates/desktop-template/.run/desktop.run.xml new file mode 100644 index 0000000000..4f43224711 --- /dev/null +++ b/templates/desktop-template/.run/desktop.run.xml @@ -0,0 +1,21 @@ + + + + + + + true + + + \ No newline at end of file diff --git a/templates/app-template/REAMDE.md b/templates/desktop-template/README.md similarity index 100% rename from templates/app-template/REAMDE.md rename to templates/desktop-template/README.md diff --git a/templates/app-template/build.gradle.kts b/templates/desktop-template/build.gradle.kts similarity index 83% rename from templates/app-template/build.gradle.kts rename to templates/desktop-template/build.gradle.kts index 1474d194b9..78fbb79382 100644 --- a/templates/app-template/build.gradle.kts +++ b/templates/desktop-template/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.compose.compose plugins { kotlin("jvm") version "1.4.0" - id("org.jetbrains.compose") version "0.1.0-demo3" + id("org.jetbrains.compose") version "0.1.0-build60" application } diff --git a/templates/app-template/build_and_run_from_cli_example.sh b/templates/desktop-template/build_and_run_from_cli_example.sh old mode 100755 new mode 100644 similarity index 100% rename from templates/app-template/build_and_run_from_cli_example.sh rename to templates/desktop-template/build_and_run_from_cli_example.sh diff --git a/templates/desktop-template/gradle.properties b/templates/desktop-template/gradle.properties new file mode 100644 index 0000000000..f1a9d3306a --- /dev/null +++ b/templates/desktop-template/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +kotlin.code.style=official \ No newline at end of file diff --git a/templates/app-template/gradle/wrapper/gradle-wrapper.properties b/templates/desktop-template/gradle/wrapper/gradle-wrapper.properties similarity index 92% rename from templates/app-template/gradle/wrapper/gradle-wrapper.properties rename to templates/desktop-template/gradle/wrapper/gradle-wrapper.properties index a4b4429748..ac33e9944a 100644 --- a/templates/app-template/gradle/wrapper/gradle-wrapper.properties +++ b/templates/desktop-template/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/templates/app-template/gradlew b/templates/desktop-template/gradlew old mode 100755 new mode 100644 similarity index 99% rename from templates/app-template/gradlew rename to templates/desktop-template/gradlew index fbd7c51583..2fe81a7d95 --- a/templates/app-template/gradlew +++ b/templates/desktop-template/gradlew @@ -82,7 +82,6 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -130,7 +129,6 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/templates/app-template/gradlew.bat b/templates/desktop-template/gradlew.bat similarity index 96% rename from templates/app-template/gradlew.bat rename to templates/desktop-template/gradlew.bat index 5093609d51..9618d8d960 100644 --- a/templates/app-template/gradlew.bat +++ b/templates/desktop-template/gradlew.bat @@ -29,9 +29,6 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -84,7 +81,6 @@ set CMD_LINE_ARGS=%* set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% diff --git a/templates/app-template/settings.gradle.kts b/templates/desktop-template/settings.gradle.kts similarity index 100% rename from templates/app-template/settings.gradle.kts rename to templates/desktop-template/settings.gradle.kts diff --git a/templates/desktop-template/src/main/kotlin/main.kt b/templates/desktop-template/src/main/kotlin/main.kt new file mode 100644 index 0000000000..15a5c0576a --- /dev/null +++ b/templates/desktop-template/src/main/kotlin/main.kt @@ -0,0 +1,6 @@ +import androidx.compose.desktop.Window +import androidx.compose.foundation.Text + +fun main() = Window { + Text("Hello, World!") +} \ No newline at end of file diff --git a/templates/mpp-template/.gitignore b/templates/mpp-template/.gitignore new file mode 100644 index 0000000000..81b4fd153d --- /dev/null +++ b/templates/mpp-template/.gitignore @@ -0,0 +1,88 @@ +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof \ No newline at end of file diff --git a/templates/mpp-template/.run/android.run.xml b/templates/mpp-template/.run/android.run.xml new file mode 100644 index 0000000000..a9dd595f84 --- /dev/null +++ b/templates/mpp-template/.run/android.run.xml @@ -0,0 +1,59 @@ + + + + + \ No newline at end of file diff --git a/templates/mpp-template/.run/desktop.run.xml b/templates/mpp-template/.run/desktop.run.xml new file mode 100644 index 0000000000..d9335c1be5 --- /dev/null +++ b/templates/mpp-template/.run/desktop.run.xml @@ -0,0 +1,21 @@ + + + + + + + true + + + \ No newline at end of file diff --git a/templates/mpp-template/README.md b/templates/mpp-template/README.md new file mode 100644 index 0000000000..988ed80ad2 --- /dev/null +++ b/templates/mpp-template/README.md @@ -0,0 +1,6 @@ +Compose MPP Application + +- `./gradlew run` - run application +- `./gradlew install` - build application into `build/install` +- `./gradlew build` - build and create dist ready for distribution in `build/distributions/xxx.zip` +- `./gradlew installDebug` - install android application \ No newline at end of file diff --git a/templates/mpp-template/android/build.gradle.kts b/templates/mpp-template/android/build.gradle.kts new file mode 100644 index 0000000000..f0a7bb5417 --- /dev/null +++ b/templates/mpp-template/android/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + id("com.android.application") + kotlin("android") + id("org.jetbrains.compose") +} + +android { + compileSdkVersion(30) + + defaultConfig { + minSdkVersion(21) + targetSdkVersion(30) + versionCode = 1 + versionName = "1.0" + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation(project(":common")) +} \ No newline at end of file diff --git a/templates/mpp-template/android/src/main/AndroidManifest.xml b/templates/mpp-template/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..6020c11eb2 --- /dev/null +++ b/templates/mpp-template/android/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/mpp-template/android/src/main/java/com/myapplication/MainActivity.kt b/templates/mpp-template/android/src/main/java/com/myapplication/MainActivity.kt new file mode 100644 index 0000000000..d6219c1108 --- /dev/null +++ b/templates/mpp-template/android/src/main/java/com/myapplication/MainActivity.kt @@ -0,0 +1,16 @@ +package com.myapplication + +import App +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.compose.ui.platform.setContent + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContent { + App() + } + } +} \ No newline at end of file diff --git a/templates/mpp-template/android/src/main/res/drawable-v24/ic_launcher_foreground.xml b/templates/mpp-template/android/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000000..2b068d1146 --- /dev/null +++ b/templates/mpp-template/android/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/templates/mpp-template/android/src/main/res/drawable/ic_launcher_background.xml b/templates/mpp-template/android/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000000..07d5da9cbf --- /dev/null +++ b/templates/mpp-template/android/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/mpp-template/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/templates/mpp-template/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000000..eca70cfe52 --- /dev/null +++ b/templates/mpp-template/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/templates/mpp-template/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/templates/mpp-template/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000000..eca70cfe52 --- /dev/null +++ b/templates/mpp-template/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/templates/mpp-template/android/src/main/res/mipmap-hdpi/ic_launcher.png b/templates/mpp-template/android/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..a571e60098 Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/templates/mpp-template/android/src/main/res/mipmap-hdpi/ic_launcher_round.png b/templates/mpp-template/android/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000000..61da551c55 Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/templates/mpp-template/android/src/main/res/mipmap-mdpi/ic_launcher.png b/templates/mpp-template/android/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..c41dd28531 Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/templates/mpp-template/android/src/main/res/mipmap-mdpi/ic_launcher_round.png b/templates/mpp-template/android/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000000..db5080a752 Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/templates/mpp-template/android/src/main/res/mipmap-xhdpi/ic_launcher.png b/templates/mpp-template/android/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..6dba46dab1 Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/templates/mpp-template/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/templates/mpp-template/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..da31a871c8 Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/templates/mpp-template/android/src/main/res/mipmap-xxhdpi/ic_launcher.png b/templates/mpp-template/android/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..15ac681720 Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/templates/mpp-template/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/templates/mpp-template/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..b216f2d313 Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/templates/mpp-template/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/templates/mpp-template/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..f25a419744 Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/templates/mpp-template/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/templates/mpp-template/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..e96783ccce Binary files /dev/null and b/templates/mpp-template/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/templates/mpp-template/android/src/main/res/values/strings.xml b/templates/mpp-template/android/src/main/res/values/strings.xml new file mode 100644 index 0000000000..592270bf53 --- /dev/null +++ b/templates/mpp-template/android/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + My application + \ No newline at end of file diff --git a/templates/mpp-template/build.gradle.kts b/templates/mpp-template/build.gradle.kts new file mode 100644 index 0000000000..caeaa20b92 --- /dev/null +++ b/templates/mpp-template/build.gradle.kts @@ -0,0 +1,7 @@ +allprojects { + repositories { + google() + jcenter() + maven("https://packages.jetbrains.team/maven/p/ui/dev") + } +} \ No newline at end of file diff --git a/templates/mpp-template/common/build.gradle.kts b/templates/mpp-template/common/build.gradle.kts new file mode 100644 index 0000000000..7653e66c45 --- /dev/null +++ b/templates/mpp-template/common/build.gradle.kts @@ -0,0 +1,51 @@ +import org.jetbrains.compose.compose + +plugins { + id("com.android.library") + kotlin("multiplatform") + id("org.jetbrains.compose") +} + +kotlin { + android() + jvm("desktop") + + sourceSets { + named("commonMain") { + dependencies { + api(compose.runtime) + api(compose.foundation) + api(compose.material) + } + } + named("androidMain") { + dependencies { + api("androidx.appcompat:appcompat:1.1.0") + api("androidx.core:core-ktx:1.3.1") + } + } + } +} + +android { + compileSdkVersion(30) + + defaultConfig { + minSdkVersion(21) + targetSdkVersion(30) + versionCode = 1 + versionName = "1.0" + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + sourceSets { + named("main") { + manifest.srcFile("src/androidMain/AndroidManifest.xml") + res.srcDirs("src/androidMain/res") + } + } +} diff --git a/templates/mpp-template/common/src/androidMain/AndroidManifest.xml b/templates/mpp-template/common/src/androidMain/AndroidManifest.xml new file mode 100644 index 0000000000..abeb3cd382 --- /dev/null +++ b/templates/mpp-template/common/src/androidMain/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/templates/mpp-template/common/src/commonMain/kotlin/App.kt b/templates/mpp-template/common/src/commonMain/kotlin/App.kt new file mode 100644 index 0000000000..4b1cd6ae3f --- /dev/null +++ b/templates/mpp-template/common/src/commonMain/kotlin/App.kt @@ -0,0 +1,7 @@ +import androidx.compose.foundation.Text +import androidx.compose.runtime.Composable + +@Composable +fun App() { + Text("Hello, World!") +} \ No newline at end of file diff --git a/templates/mpp-template/desktop/build.gradle.kts b/templates/mpp-template/desktop/build.gradle.kts new file mode 100644 index 0000000000..89af4eb8d8 --- /dev/null +++ b/templates/mpp-template/desktop/build.gradle.kts @@ -0,0 +1,17 @@ +import org.jetbrains.compose.compose + +plugins { + kotlin("jvm") + id("org.jetbrains.compose") + java + application +} + +dependencies { + implementation(compose.desktop.all) + implementation(project(":common")) +} + +application { + mainClassName = "MainKt" +} \ No newline at end of file diff --git a/templates/mpp-template/desktop/src/main/kotlin/main.kt b/templates/mpp-template/desktop/src/main/kotlin/main.kt new file mode 100644 index 0000000000..c810ea3d8b --- /dev/null +++ b/templates/mpp-template/desktop/src/main/kotlin/main.kt @@ -0,0 +1,5 @@ +import androidx.compose.desktop.Window + +fun main() = Window { + App() +} \ No newline at end of file diff --git a/templates/mpp-template/gradle.properties b/templates/mpp-template/gradle.properties new file mode 100644 index 0000000000..a9d5d0bc15 --- /dev/null +++ b/templates/mpp-template/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +android.useAndroidX=true +android.enableJetifier=true +kotlin.code.style=official \ No newline at end of file diff --git a/templates/mpp-template/gradle/wrapper/gradle-wrapper.properties b/templates/mpp-template/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..ac33e9944a --- /dev/null +++ b/templates/mpp-template/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/templates/mpp-template/gradlew b/templates/mpp-template/gradlew new file mode 100644 index 0000000000..2fe81a7d95 --- /dev/null +++ b/templates/mpp-template/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/templates/mpp-template/gradlew.bat b/templates/mpp-template/gradlew.bat new file mode 100644 index 0000000000..9618d8d960 --- /dev/null +++ b/templates/mpp-template/gradlew.bat @@ -0,0 +1,100 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/templates/mpp-template/settings.gradle.kts b/templates/mpp-template/settings.gradle.kts new file mode 100644 index 0000000000..c15602925c --- /dev/null +++ b/templates/mpp-template/settings.gradle.kts @@ -0,0 +1,15 @@ +buildscript { + repositories { + google() + jcenter() + maven("https://packages.jetbrains.team/maven/p/ui/dev") + } + + dependencies { + classpath("org.jetbrains.compose:compose-gradle-plugin:0.1.0-build60") + classpath("com.android.tools.build:gradle:4.0.1") + classpath(kotlin("gradle-plugin", version = "1.4.0")) + } +} + +include(":common", ":android", ":desktop") \ No newline at end of file