summaryrefslogtreecommitdiff
path: root/build.gradle
blob: 8e43c79bae2f9eaddaeb72165617b9062ba93e94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
buildscript {
    ext.kotlin_version = '1.1.51'

    repositories {
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
        maven { url "https://plugins.gradle.org/m2/" }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.20"
        classpath "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0.RC4-2"
    }
}

group = 'pl.treksoft'
version = '0.0.1-SNAPSHOT'

apply plugin: 'kotlin2js'
apply plugin: 'org.jetbrains.kotlin.frontend'
apply plugin: "io.gitlab.arturbosch.detekt"

repositories {
    jcenter()
    maven { url = 'https://dl.bintray.com/gbaldeck/kotlin' }
    maven { url = 'https://dl.bintray.com/rjaros/kotlin' }
    maven { url = "./libs" }
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
    compile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" // for now only compile configuration is supported
    compile "com.github.snabbdom:snabbdom-kotlin:0.1.1"
    compile "pl.treksoft:navigo-kotlin:0.0.1"
    compile "pl.treksoft:jquery-kotlin:0.0.2"
    compile "obs:kotlin-observable:0.0.1"
}

kotlinFrontend {
    npm {
        dependency "jquery"
        dependency "bootstrap"
        dependency "css-loader"
        dependency "style-loader"
        dependency "less"
        dependency "less-loader"
        dependency "imports-loader"
        dependency "bootstrap-webpack"
        dependency "font-awesome"
        dependency("font-awesome-webpack", "0.0.5-beta.2")
        dependency "file-loader"
        dependency "url-loader"
        dependency("awesome-bootstrap-checkbox", "0.3.7")
        dependency "bootstrap-select"
        dependency "ajax-bootstrap-select"
        dependency("snabbdom", "0.6.9")
        dependency "snabbdom-virtualize"
        dependency "navigo"
        dependency "jquery-resizable-dom"
        devDependency("karma")
    }

    webpackBundle {
        bundleName = "main"
        contentPath = file('src/main/web')
    }

    define "PRODUCTION", false

}

detekt {
    version = "1.0.0.RC4-2"
    profile("main") {
        input = "$projectDir/src/main/kotlin"
        config = "$projectDir/detekt.yml"
        filters = ".*test.*,.*/resources/.*,.*/tmp/.*"
    }
}

compileKotlin2Js {
    kotlinOptions.metaInfo = true
    kotlinOptions.outputFile = "$project.buildDir.path/js/${project.name}.js"
    kotlinOptions.sourceMap = true
    kotlinOptions.moduleKind = 'commonjs'
}

compileTestKotlin2Js {
    kotlinOptions.metaInfo = true
    kotlinOptions.outputFile = "$project.buildDir.path/js-tests/${project.name}-tests.js"
    kotlinOptions.sourceMap = true
    kotlinOptions.moduleKind = 'commonjs'
}

task copyResources(type: Copy) {
    from "src/main/assets"
    into file(buildDir.path + "/js")
}

afterEvaluate {
    tasks.getByName("webpack-bundle") { dependsOn(copyResources) }
    tasks.getByName("webpack-run") { dependsOn(copyResources) }
}