Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to modify Compose -- Use JB Compose #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
115 changes: 108 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,86 @@
buildscript {
Properties properties = new Properties()
def propertiesFile = project.rootProject.file('local.properties')
if (propertiesFile.exists()) {
properties.load(propertiesFile.newDataInputStream())
ext {
Properties properties = new Properties()
def propertiesFile = project.rootProject.file('local.properties')
if (propertiesFile.exists()) {
properties.load(propertiesFile.newDataInputStream())
}
aosp_location = properties.getProperty('aosp.location')
android_build_tool_version = '4.0.1'
kotlin_version = "1.4-M3"
//FIXME if use 1.4.31 kotlinx.serialization must over 1.0
// kotlin_version = "1.4.31"
// - Android Compose
android_compose_appcompat_version = '1.3.0-beta01'
android_compose_activity_version = '1.3.0-alpha02'
// - Jetpack Compose - shared UI
jb_compose_version = '0.3.2'

//collections-immutable
coroutines_core_version = '1.3.7-1.4-M3'
collections_immutable_version = '0.3'
ktor_version = '1.3.2-1.4-M3'
// 1.5.0-M2
kotlin_serialization_version = '1.4-M3'
// kotlin_serialization_version = '1.4.31'
//Ref : https://blog.csdn.net/vitaviva/article/details/104779479
//Ref : https://blog.csdn.net/weixin_44761758/article/details/89536909?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&dist_request_id=1329187.9314.16178509973458491&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control
serialization_runtime= '0.20.0-1.4-M3'
// serialization_runtime= '1.0-M1-1.4.0-rc-218'
// 1.0.0-alpha13
compose_version = '1.0.0-beta01'
}

repositories {
google()
mavenCentral()
jcenter()
gradlePluginPortal()
maven {
url = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
}
//JB_Kotlin_Multiplatform
maven {
url "https://plugins.gradle.org/m2/"
}

maven {
url = "https://dl.bintray.com/kotlin/kotlin-eap"
}
maven {
url = "https://dl.bintray.com/kotlin/kotlin-dev"
}
//JB_Compose
maven {
url = "https://maven.pkg.jetbrains.space/public/p/compose/dev"
}
// // kotlin-DSL
// maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
dependencies {
classpath "com.android.tools.build:gradle:${android_build_tool_version}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//JB_Kotlin_Multiplatform
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0-M2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_serialization_version"

//Test
classpath "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"

//JB_Compose
classpath "org.jetbrains.compose:compose-gradle-plugin:$jb_compose_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
ext.aosp_location = properties.getProperty('aosp.location')
}

plugins {

id 'org.jetbrains.kotlin.jvm' version '1.4-M3'
// id 'org.jetbrains.kotlin.jvm' version '1.4.31'
}

group 'me.shika'
Expand All @@ -19,14 +91,43 @@ allprojects {
google()
mavenCentral()
jcenter()
gradlePluginPortal()
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
//JB_Kotlin_Multiplatform
maven {
url "https://plugins.gradle.org/m2/"
}

maven {
url = "https://dl.bintray.com/kotlin/kotlin-eap"
}
maven {
url "https://dl.bintray.com/kotlin/kotlin-eap/"
url = "https://dl.bintray.com/kotlin/kotlin-dev"
}
//JB_Compose
maven {
url = "https://maven.pkg.jetbrains.space/public/p/compose/dev"
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile) {
// tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile) {
// kotlinOptions {
// freeCompilerArgs += ["-Xskip-prerelease-check"]
// }
// }

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
freeCompilerArgs += ["-Xskip-prerelease-check"]

// freeCompilerArgs = [
// "-Xjsr305=strict",
// "-progressive",
//// "-Xopt-in=kotlin.RequiresOptIn"
// ]
jvmTarget = "1.8"
useIR = true
allWarningsAsErrors = false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'org.jetbrains.kotlin.multiplatform'
}
Expand All @@ -15,10 +13,6 @@ dependencies {
kotlinCompilerPluginClasspath "androidx.compose:compose-compiler:0.1.0-dev15"
}

project.tasks.withType(KotlinCompile.class).configureEach { compile ->
compile.kotlinOptions.useIR = true
}

kotlin {
jvm()

Expand All @@ -28,7 +22,7 @@ kotlin {
kotlin.srcDirs += file("$aosp_location/frameworks/support/compose/compose-dispatch/src/commonMain/kotlin")
dependencies {
implementation kotlin('stdlib-common')
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7-1.4-M3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_core_version"
implementation "org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3"
}
}
Expand All @@ -37,7 +31,7 @@ kotlin {
kotlin.srcDirs += file("$aosp_location/frameworks/support/compose/compose-dispatch/src/jvmMain/kotlin")
dependencies {
implementation kotlin('stdlib-jdk8')
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7-1.4-M3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_core_version"
}
}
}
Expand Down
25 changes: 10 additions & 15 deletions integration/build.gradle → common/integration/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'org.jetbrains.kotlin.multiplatform'
}
Expand All @@ -13,12 +11,6 @@ configurations.kotlinCompilerClasspath { configuration ->
.force(dep)
}

tasks.withType(KotlinCompile) {
kotlinOptions {
useIR = true
}
}

kotlin {
js('client') {
browser()
Expand All @@ -34,26 +26,29 @@ kotlin {
}

dependencies {
kotlinCompilerPluginClasspath "androidx.compose:compose-compiler:0.1.0-dev15"
// kotlinCompilerPluginClasspath "androidx.compose:compose-compiler:0.1.0-dev15"
// kotlinCompilerPluginClasspath "androidx.compose:compose-compiler:1.0.0-beta03"
add("kotlinCompilerPluginClasspath", "androidx.compose.compiler:compiler:$compose_version")
}

sourceSets {
clientMain {
dependencies {
implementation kotlin('stdlib-js')
implementation project(':client')
implementation project(':web:client')
}
}
serverMain {
dependencies {
implementation kotlin('stdlib-jdk8')
implementation project(':server')
implementation project(':web:server')
implementation fileTree("../compose-wrapper/built/")

implementation "org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3"
implementation "io.ktor:ktor-server-core:1.3.2-1.4-M3"
implementation "io.ktor:ktor-server-netty:1.3.2-1.4-M3"
implementation "io.ktor:ktor-websockets:1.3.2-1.4-M3"
implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-server-netty:$ktor_version"
implementation "io.ktor:ktor-websockets:$ktor_version"
//Log
implementation "ch.qos.logback:logback-classic:1.2.3"
}
}
Expand All @@ -64,7 +59,7 @@ kotlin {
task copyServerLibs(type: Copy) {
into "$buildDir/server"
from(configurations.serverRuntimeClasspath)
from(project(':compose-wrapper').configurations.jvmRuntimeClasspath)
from(project(':common:compose-wrapper').configurations.jvmRuntimeClasspath)
}

task stage(dependsOn: ['assemble', 'clean', 'copyServerLibs'])
Expand Down
8 changes: 4 additions & 4 deletions protocol/build.gradle → common/protocol/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'org.jetbrains.kotlin.multiplatform'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.4-M3'
id 'org.jetbrains.kotlin.plugin.serialization'
}

kotlin {
Expand All @@ -11,21 +11,21 @@ kotlin {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0-1.4-M3"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_runtime"
}
}

jsMain {
dependencies {
implementation kotlin('stdlib-js')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.20.0-1.4-M3"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serialization_runtime"
}
}

jvmMain {
dependencies {
implementation kotlin('stdlib-jdk8')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0-1.4-M3"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_runtime"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Sun May 03 03:53:49 BST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
28 changes: 23 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
pluginManagement {
repositories {
google()
mavenCentral()
jcenter()
gradlePluginPortal()
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
//JB_Kotlin_Multiplatform
maven {
url "https://plugins.gradle.org/m2/"
}

maven {
url = "https://dl.bintray.com/kotlin/kotlin-eap"
}
maven {
url = "https://dl.bintray.com/kotlin/kotlin-dev"
}
//JB_Compose
maven {
url = "https://maven.pkg.jetbrains.space/public/p/compose/dev"
}
}
}

rootProject.name = 'compose-html-server'

include ':server'
include ':client'
include ':compose-wrapper'
include ':protocol'
include ':integration'
include ':web:server'
include ':web:client'
include ':common:compose-wrapper'
include ':common:protocol'
include ':common:integration'
8 changes: 5 additions & 3 deletions client/build.gradle → web/client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'org.jetbrains.kotlin.multiplatform'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.4-M3'
id 'org.jetbrains.kotlin.plugin.serialization'
}

kotlin {
Expand All @@ -9,8 +9,10 @@ kotlin {
jsMain {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-js"
implementation project(':protocol')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.20.0-1.4-M3"

implementation project(':common:protocol')

implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serialization_runtime"
}
}
}
Expand Down
25 changes: 11 additions & 14 deletions server/build.gradle → web/server/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'org.jetbrains.kotlin.jvm'
id 'application'
Expand All @@ -15,19 +13,18 @@ configurations.kotlinCompilerClasspath { configuration ->
}

dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
implementation fileTree("../compose-wrapper/built/")
implementation project(':protocol')
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7-1.4-M3"
implementation "io.ktor:ktor-server-core:1.3.2-1.4-M3"
implementation "io.ktor:ktor-websockets:1.3.2-1.4-M3"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0-1.4-M3"
implementation fileTree("../../common/compose-wrapper/built/")
implementation project(':common:protocol')

kotlinCompilerPluginClasspath "androidx.compose:compose-compiler:0.1.0-dev15"
}

tasks.withType(KotlinCompile) {
kotlinOptions {
useIR = true
}
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_core_version"

implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-websockets:$ktor_version"

implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_runtime"
}