File tree 16 files changed +84
-128
lines changed
16 files changed +84
-128
lines changed Original file line number Diff line number Diff line change @@ -252,7 +252,14 @@ configure(subprojects.findAll { it.name != coreModule && it.name != rootModule }
252
252
}
253
253
254
254
// Redefine source sets because we are not using 'kotlin/main/fqn' folder convention
255
- configure(subprojects. findAll { ! sourceless. contains(it. name) && it. name != " benchmarks" && it. name != ' example-frontend-js' && it. name != coreModule }) {
255
+ configure(subprojects. findAll {
256
+ ! sourceless. contains(it. name) &&
257
+ it. name != " benchmarks" &&
258
+ it. name != coreModule &&
259
+ it. name != " example-frontend-js"
260
+ }) {
261
+ // Pure JS and pure MPP doesn't have this notion and are configured separately
262
+ // TODO detect it via platformOf and migrate benchmarks to the same scheme
256
263
sourceSets {
257
264
main. kotlin. srcDirs = [' src' ]
258
265
test. kotlin. srcDirs = [' test' ]
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ kotlinDslPluginOptions {
14
14
experimentalWarning.set(false )
15
15
}
16
16
17
- val props = Properties ().apply {
17
+ private val props = Properties ().apply {
18
18
file(" ../gradle.properties" ).inputStream().use { load(it) }
19
19
}
20
20
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ import org.jetbrains.dokka.gradle.DokkaTask
10
10
import java.io.File
11
11
import java.net.URL
12
12
13
+ /* *
14
+ * Package-list by external URL for documentation generation.
15
+ */
13
16
fun Project.externalDocumentationLink (
14
17
url : String ,
15
18
packageList : File = projectDir.resolve("package.list")
Original file line number Diff line number Diff line change 7
7
import org.gradle.api.Project
8
8
import org.gradle.api.publish.maven.MavenPom
9
9
10
- // --------------- pom configuration ---------------
10
+ // Pom configuration
11
11
12
12
fun MavenPom.configureMavenCentralMetadata (project : Project ) {
13
13
name by project.name
Original file line number Diff line number Diff line change 1
1
import org.gradle.api.Project
2
2
3
+ // Use from Groovy for now
3
4
fun platformOf (project : Project ): String =
4
5
when (project.name.substringAfterLast(" -" )) {
5
6
" js" -> " js"
Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ import org.gradle.kotlin.dsl.get
7
7
import org.gradle.kotlin.dsl.named
8
8
import java.io.File
9
9
10
+ /*
11
+ * Task used by our ui/android tests to test minification results
12
+ * and keep track of size of the binary.
13
+ * TODO move back to kotlinx-coroutines-android when it's migrated to the kts
14
+ */
10
15
open class RunR8 : JavaExec () {
11
16
12
17
@OutputDirectory
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import java.nio.file.Files
9
9
import java.util.zip.ZipEntry
10
10
import java.util.zip.ZipFile
11
11
12
+ // TODO move back to kotlinx-coroutines-play-services when it's migrated to the kts
12
13
@Suppress(" UnstableApiUsage" )
13
14
abstract class UnpackAar : TransformAction <TransformParameters .None > {
14
15
@get:InputArtifact
Original file line number Diff line number Diff line change 6
6
7
7
apply plugin : ' org.jetbrains.kotlin.js'
8
8
9
- kotlin. sourceSets {
10
- main. kotlin. srcDirs = [' src' ]
11
- test. kotlin. srcDirs = [' test' ]
12
- main. resources. srcDirs = [' resources' ]
13
- test. resources. srcDirs = [' test-resources' ]
9
+ dependencies {
10
+ implementation " org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version "
11
+ testImplementation " org.jetbrains.kotlin:kotlin-test-js:$kotlin_version "
14
12
}
15
13
16
- dependencies {
17
- compile " org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version "
18
- testCompile " org.jetbrains.kotlin:kotlin-test-js:$kotlin_version "
14
+ kotlin {
15
+ js(LEGACY ) {
16
+ moduleName = project. name - " -js"
17
+ }
18
+
19
+ sourceSets {
20
+ main. kotlin. srcDirs = [' src' ]
21
+ test. kotlin. srcDirs = [' test' ]
22
+ main. resources. srcDirs = [' resources' ]
23
+ test. resources. srcDirs = [' test-resources' ]
24
+ }
19
25
}
20
26
21
27
tasks. withType(compileKotlinJs. getClass()) {
@@ -25,11 +31,3 @@ tasks.withType(compileKotlinJs.getClass()) {
25
31
metaInfo = true
26
32
}
27
33
}
28
-
29
- compileKotlinJs {
30
- kotlinOptions {
31
- // drop -js suffix from outputFile
32
- def baseName = project. name - " -js"
33
- outputFile = new File (outputFile. parent, baseName + " .js" )
34
- }
35
- }
Original file line number Diff line number Diff line change 3
3
Build application with
4
4
5
5
```
6
- gradlew :example-frontend-js:bundle
6
+ gradlew :example-frontend-js:build
7
7
```
8
8
9
9
The resulting application can be found in ` build/dist ` subdirectory.
10
10
11
11
You can start application with webpack-dev-server using:
12
12
13
13
```
14
- gradlew :example-frontend-js:start
14
+ gradlew :example-frontend-js:run
15
15
```
16
16
17
17
Built and deployed application is available at the library documentation site
Original file line number Diff line number Diff line change 2
2
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
3
*/
4
4
5
- apply plugin : ' kotlin-dce-js'
6
- apply from : rootProject. file(' gradle/node-js.gradle' )
7
-
8
- dependencies {
9
- compile " org.jetbrains.kotlinx:kotlinx-html-js:$html_version "
10
- }
11
-
12
- compileKotlinJs {
13
- kotlinOptions {
14
- main = " call"
5
+ project. kotlin {
6
+ js(LEGACY ) {
7
+ binaries. executable()
8
+ browser {
9
+ distribution {
10
+ directory = new File (directory. parentFile, " dist" )
11
+ }
12
+ webpackTask {
13
+ cssSupport. enabled = true
14
+ }
15
+ runTask {
16
+ cssSupport. enabled = true
17
+ }
18
+ testTask {
19
+ useKarma {
20
+ useChromeHeadless()
21
+ webpackConfig. cssSupport. enabled = true
22
+ }
23
+ }
24
+ }
15
25
}
16
- }
17
26
18
- task bundle (type : NpmTask , dependsOn : [npmInstall, build]) {
19
- inputs. files(fileTree(" $buildDir /kotlin-js-min/main" ))
20
- inputs. files(fileTree(" $buildDir /kotlin-js-min/legacy/main" ))
21
- inputs. files(fileTree(file(" src/main/web" )))
22
- inputs. file(" npm/webpack.config.js" )
23
- outputs. dir(" $buildDir /dist" )
24
- args = [" run" , " bundle" ]
25
- }
26
-
27
- task start (type : NpmTask , dependsOn : bundle) {
28
- args = [" run" , " start" ]
27
+ sourceSets {
28
+ main. dependencies {
29
+ implementation " org.jetbrains.kotlinx:kotlinx-html-js:$html_version "
30
+ implementation(npm(" html-webpack-plugin" , " 3.2.0" ))
31
+ }
32
+ }
29
33
}
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -13,7 +13,10 @@ import kotlin.coroutines.*
13
13
import kotlin.math.*
14
14
import kotlin.random.Random
15
15
16
+ external fun require (resource : String )
17
+
16
18
fun main () {
19
+ require(" style.css" )
17
20
println (" Starting example application..." )
18
21
document.addEventListener(" DOMContentLoaded" , {
19
22
Application ().start()
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
+ */
4
+
5
+ ; ( function ( config ) {
6
+ const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
7
+
8
+ config . output . filename = "[name].bundle.js"
9
+
10
+ config . plugins . push (
11
+ new HtmlWebpackPlugin ( {
12
+ title : 'Kotlin Coroutines JS Example'
13
+ } )
14
+ )
15
+
16
+ // path from <root-build>/js/packages/example-frontend-js to src/main/web
17
+ config . resolve . modules . push ( "../../../../js/example-frontend-js/src/main/web" ) ;
18
+ } ) ( config ) ;
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ val copyExampleFrontendJs by tasks.registering(Copy::class) {
26
26
from(" $srcBuildDir /dist" )
27
27
into(" $buildDocsDir /example-frontend-js" )
28
28
29
- dependsOn(" :example-frontend-js:bundle " )
29
+ dependsOn(" :example-frontend-js:browserDistribution " )
30
30
}
31
31
32
32
tasks.register<Exec >(" site" ) {
You can’t perform that action at this time.
0 commit comments