From b3f351d0f124ff6b3a0f12d002d25fbeaa3d8206 Mon Sep 17 00:00:00 2001 From: Felipe Lima Date: Mon, 23 Mar 2020 20:15:15 -0700 Subject: [PATCH] Update kotlin MPP and AGP versions (#30) * Update kotlin and AGP versions * add github action * Bump moar * Upgrade to new javascript gradle pluign * Fix CI working dir --- .github/workflows/android.yml | 28 +++++ .gitignore | 3 +- .travis.yml | 42 ------- android/build.gradle | 11 +- build.gradle | 6 +- gradle/wrapper/gradle-wrapper.properties | 2 +- lib/build.gradle | 31 +++-- web/build.gradle | 108 +++++------------- .../kotlin/com/felipecsl/knes/Audio.kt | 0 .../kotlin/com/felipecsl/knes/FrameTimer.kt | 0 .../com/felipecsl/knes/KeyboardController.kt | 0 .../kotlin/com/felipecsl/knes/Main.kt | 0 .../knes/components/RootComponent.kt | 0 .../img/apple-touch-icon-114x114.png | Bin .../img/apple-touch-icon-144x144.png | Bin .../resources}/img/apple-touch-icon-72x72.png | Bin .../resources}/img/apple-touch-icon.png | Bin .../web => main/resources}/img/favicon.ico | Bin .../resources}/img/kotlin-logo.jpeg | Bin .../{jsMain/web => main/resources}/index.css | 0 .../{jsMain/web => main/resources}/index.html | 2 +- web/yarn.lock | 4 + 22 files changed, 85 insertions(+), 152 deletions(-) create mode 100644 .github/workflows/android.yml delete mode 100644 .travis.yml rename web/src/{jsMain => main}/kotlin/com/felipecsl/knes/Audio.kt (100%) rename web/src/{jsMain => main}/kotlin/com/felipecsl/knes/FrameTimer.kt (100%) rename web/src/{jsMain => main}/kotlin/com/felipecsl/knes/KeyboardController.kt (100%) rename web/src/{jsMain => main}/kotlin/com/felipecsl/knes/Main.kt (100%) rename web/src/{jsMain => main}/kotlin/com/felipecsl/knes/components/RootComponent.kt (100%) rename web/src/{jsMain/web => main/resources}/img/apple-touch-icon-114x114.png (100%) rename web/src/{jsMain/web => main/resources}/img/apple-touch-icon-144x144.png (100%) rename web/src/{jsMain/web => main/resources}/img/apple-touch-icon-72x72.png (100%) rename web/src/{jsMain/web => main/resources}/img/apple-touch-icon.png (100%) rename web/src/{jsMain/web => main/resources}/img/favicon.ico (100%) rename web/src/{jsMain/web => main/resources}/img/kotlin-logo.jpeg (100%) rename web/src/{jsMain/web => main/resources}/index.css (100%) rename web/src/{jsMain/web => main/resources}/index.html (97%) create mode 100644 web/yarn.lock diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..429cf81 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,28 @@ +name: Android CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Gradle + run: ./gradlew check + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: | + ${{ runner.os }}-gradle- diff --git a/.gitignore b/.gitignore index 4b068a4..0e61b80 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ local.properties *.so *.nes .externalNativeBuild -.cxx \ No newline at end of file +.cxx +node_modules \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 93b6fd2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -language: android - -android: - components: - - tools - - platform-tools - - build-tools-28.0.2 - - extra-google-m2repository - - extra-android-m2repository - - android-28 - licenses: - - 'android-sdk-license-.+' - -jdk: - - oraclejdk8 - -install: - - echo y | sdkmanager "ndk-bundle" - - echo y | sdkmanager "cmake;3.6.4111459" - - echo y | sdkmanager "lldb;3.1" -before_script: - - export ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle - -branches: - except: - - gh-pages - -notifications: - email: false - -sudo: false - -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ - -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ - - $HOME/.m2 - - $HOME/.android/build-cache \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 0a29548..a8ae3c8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,14 +1,17 @@ +plugins { + id 'org.jetbrains.kotlin.multiplatform' version '1.3.71' +} + apply plugin: 'com.android.application' -apply plugin: 'kotlin-multiplatform' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { applicationId "com.felipecsl.knes" minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 29 versionCode 1 versionName "1.0" ndk { @@ -52,7 +55,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" testImplementation 'junit:junit:4.12' - testImplementation 'com.google.truth:truth:0.42' + testImplementation 'com.google.truth:truth:1.0.1' testImplementation 'org.mockito:mockito-core:1.10.19' testImplementation "org.robolectric:robolectric:3.8" } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 20ceb4e..9a908cd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { - ext.kotlin_version = '1.3.50' - ext.android_gradle_plugin_version = '3.5.2' + ext.kotlin_version = '1.3.71' + ext.android_gradle_plugin_version = '4.0.0-beta01' repositories { mavenLocal() @@ -16,8 +16,6 @@ buildscript { } dependencies { classpath "com.android.tools.build:gradle:$android_gradle_plugin_version" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.45" } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0f63390..e4a89ba 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/lib/build.gradle b/lib/build.gradle index c27a1ec..bdf5deb 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -1,12 +1,15 @@ -apply plugin: 'kotlin-multiplatform' +plugins { + id 'org.jetbrains.kotlin.multiplatform' version '1.3.71' +} + apply plugin: 'com.android.library' android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 29 } } @@ -15,19 +18,11 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } -afterEvaluate { - compileKotlinJs { - kotlinOptions.metaInfo = true - kotlinOptions.outputFile = "${project.buildDir.path}/js/${project.name}.js" - kotlinOptions.sourceMap = true - kotlinOptions.moduleKind = 'commonjs' - kotlinOptions.main = "call" - } -} - kotlin { jvm() - js() + js { + browser {} + } android() androidNativeArm32() androidNativeArm64() @@ -59,22 +54,22 @@ kotlin { implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version" } } - jvm().compilations.main.defaultSourceSet { + jvmMain { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } } - js().compilations.main.defaultSourceSet { + jsMain { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" } } - jvm().compilations.test.defaultSourceSet { + jvmTest { dependencies { implementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'com.google.truth:truth:0.42' + implementation 'com.google.truth:truth:1.0.1' implementation 'org.mockito:mockito-core:1.10.19' implementation "org.robolectric:robolectric:3.8" } diff --git a/web/build.gradle b/web/build.gradle index e363083..aedfa42 100644 --- a/web/build.gradle +++ b/web/build.gradle @@ -1,88 +1,34 @@ -apply plugin: 'kotlin-multiplatform' -apply plugin: 'org.jetbrains.kotlin.frontend' - -kotlinFrontend { - downloadNodeJsVersion = "latest" - - webpackBundle { - bundleName = "main" - contentPath = file('src/jsMain/web') - webpackConfigFile = file('webpack.config.js').absolutePath - sourceMapEnabled = true - mode = "development" - } - - npm { - dependency "react" - dependency "core-js" - dependency "react-dom" - dependency "react-router-dom" - dependency "kotlin" - // This looks like an unofficial package but I couldn't find the actual Jetbrains one, only kotlinx-html - dependency "kotlinx-html-js" - dependency "@jetbrains/kotlin-react" - dependency "@jetbrains/kotlin-react-dom" - dependency "@jetbrains/kotlin-extensions" - dependency "@jetbrains/kotlin-react-router-dom" - } +plugins { + id 'org.jetbrains.kotlin.js' version '1.3.71' } kotlin { - sourceSets { - jsMain { - dependencies { - implementation project(':lib') - implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" - // https://bintray.com/kotlin/kotlin-js-wrappers/kotlin-react - implementation "org.jetbrains:kotlin-react:16.9.0-pre.83-kotlin-$kotlin_version" - // https://bintray.com/kotlin/kotlin-js-wrappers/kotlin-react-dom - implementation "org.jetbrains:kotlin-react-dom:16.9.0-pre.83-kotlin-$kotlin_version" - // https://bintray.com/kotlin/kotlin-js-wrappers/kotlin-react-router-dom - implementation "org.jetbrains:kotlin-react-router-dom:4.3.1-pre.83-kotlin-$kotlin_version" - // https://github.com/Kotlin/kotlinx.html/releases - implementation "org.jetbrains.kotlinx:kotlinx-html-js:0.6.12" - } + target { + browser { } } - - targets { - fromPreset(presets.js, 'js') { - configure([compilations.main, compilations.test]) { - tasks.getByName(compileKotlinTaskName).kotlinOptions { - metaInfo = true - outputFile = file("build/js/${project.name}.js") - sourceMap = true - moduleKind = 'commonjs' - } - } - - configure(compilations.main) { - tasks.getByName(compileKotlinTaskName).kotlinOptions { - main = "call" - } - } - } - } -} - -afterEvaluate { - tasks.getByName('karma-run-single') { - enabled false - } -} - -task copyLibs(type: Copy) { - destinationDir buildDir - - into("js") { - from project(':lib').file("build/js") + sourceSets["main"].dependencies { + implementation npm("react", "16.13.1") + implementation npm("core-js", "3.6.4") + implementation npm("react-dom", "16.13.1") + implementation npm("react-router-dom", "5.1.2") + // This looks like an unofficial package but I couldn't find the actual Jetbrains one, only kotlinx-html + implementation npm("kotlinx-html-js", "0.6.4") + implementation npm("@jetbrains/kotlin-react", "16.9.0-pre.91") + implementation npm("@jetbrains/kotlin-react-dom", "16.9.0-pre.91") + implementation npm("@jetbrains/kotlin-extensions", "1.0.1-pre.91") + implementation npm("@jetbrains/kotlin-react-router-dom", "4.3.1-pre.91") + + implementation project(':lib') + + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + // https://bintray.com/kotlin/kotlin-js-wrappers/kotlin-react + implementation "org.jetbrains:kotlin-react:16.13.0-pre.94-kotlin-1.3.70" + // https://bintray.com/kotlin/kotlin-js-wrappers/kotlin-react-dom + implementation "org.jetbrains:kotlin-react-dom:16.13.0-pre.94-kotlin-1.3.70" + // https://bintray.com/kotlin/kotlin-js-wrappers/kotlin-react-router-dom + implementation "org.jetbrains:kotlin-react-router-dom:4.3.1-pre.94-kotlin-1.3.70" + // https://github.com/Kotlin/kotlinx.html/releases + implementation "org.jetbrains.kotlinx:kotlinx-html-js:0.7.1" } -} - -bundle { - dependsOn copyLibs -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" } \ No newline at end of file diff --git a/web/src/jsMain/kotlin/com/felipecsl/knes/Audio.kt b/web/src/main/kotlin/com/felipecsl/knes/Audio.kt similarity index 100% rename from web/src/jsMain/kotlin/com/felipecsl/knes/Audio.kt rename to web/src/main/kotlin/com/felipecsl/knes/Audio.kt diff --git a/web/src/jsMain/kotlin/com/felipecsl/knes/FrameTimer.kt b/web/src/main/kotlin/com/felipecsl/knes/FrameTimer.kt similarity index 100% rename from web/src/jsMain/kotlin/com/felipecsl/knes/FrameTimer.kt rename to web/src/main/kotlin/com/felipecsl/knes/FrameTimer.kt diff --git a/web/src/jsMain/kotlin/com/felipecsl/knes/KeyboardController.kt b/web/src/main/kotlin/com/felipecsl/knes/KeyboardController.kt similarity index 100% rename from web/src/jsMain/kotlin/com/felipecsl/knes/KeyboardController.kt rename to web/src/main/kotlin/com/felipecsl/knes/KeyboardController.kt diff --git a/web/src/jsMain/kotlin/com/felipecsl/knes/Main.kt b/web/src/main/kotlin/com/felipecsl/knes/Main.kt similarity index 100% rename from web/src/jsMain/kotlin/com/felipecsl/knes/Main.kt rename to web/src/main/kotlin/com/felipecsl/knes/Main.kt diff --git a/web/src/jsMain/kotlin/com/felipecsl/knes/components/RootComponent.kt b/web/src/main/kotlin/com/felipecsl/knes/components/RootComponent.kt similarity index 100% rename from web/src/jsMain/kotlin/com/felipecsl/knes/components/RootComponent.kt rename to web/src/main/kotlin/com/felipecsl/knes/components/RootComponent.kt diff --git a/web/src/jsMain/web/img/apple-touch-icon-114x114.png b/web/src/main/resources/img/apple-touch-icon-114x114.png similarity index 100% rename from web/src/jsMain/web/img/apple-touch-icon-114x114.png rename to web/src/main/resources/img/apple-touch-icon-114x114.png diff --git a/web/src/jsMain/web/img/apple-touch-icon-144x144.png b/web/src/main/resources/img/apple-touch-icon-144x144.png similarity index 100% rename from web/src/jsMain/web/img/apple-touch-icon-144x144.png rename to web/src/main/resources/img/apple-touch-icon-144x144.png diff --git a/web/src/jsMain/web/img/apple-touch-icon-72x72.png b/web/src/main/resources/img/apple-touch-icon-72x72.png similarity index 100% rename from web/src/jsMain/web/img/apple-touch-icon-72x72.png rename to web/src/main/resources/img/apple-touch-icon-72x72.png diff --git a/web/src/jsMain/web/img/apple-touch-icon.png b/web/src/main/resources/img/apple-touch-icon.png similarity index 100% rename from web/src/jsMain/web/img/apple-touch-icon.png rename to web/src/main/resources/img/apple-touch-icon.png diff --git a/web/src/jsMain/web/img/favicon.ico b/web/src/main/resources/img/favicon.ico similarity index 100% rename from web/src/jsMain/web/img/favicon.ico rename to web/src/main/resources/img/favicon.ico diff --git a/web/src/jsMain/web/img/kotlin-logo.jpeg b/web/src/main/resources/img/kotlin-logo.jpeg similarity index 100% rename from web/src/jsMain/web/img/kotlin-logo.jpeg rename to web/src/main/resources/img/kotlin-logo.jpeg diff --git a/web/src/jsMain/web/index.css b/web/src/main/resources/index.css similarity index 100% rename from web/src/jsMain/web/index.css rename to web/src/main/resources/index.css diff --git a/web/src/jsMain/web/index.html b/web/src/main/resources/index.html similarity index 97% rename from web/src/jsMain/web/index.html rename to web/src/main/resources/index.html index 97ac70c..a99a31f 100644 --- a/web/src/jsMain/web/index.html +++ b/web/src/main/resources/index.html @@ -45,7 +45,7 @@ fill="currentColor" class="octo-body"> - + diff --git a/web/yarn.lock b/web/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/web/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +