-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
201 lines (156 loc) · 5.04 KB
/
build.gradle.kts
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.javafxports.jfxmobile.plugin.DownConfiguration
import org.javafxports.jfxmobile.plugin.JFXMobileExtension
import org.javafxports.jfxmobile.plugin.android.AndroidExtension
import org.javafxports.jfxmobile.plugin.ios.IosExtension
import org.jetbrains.kotlin.gradle.dsl.Coroutines
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.nio.file.Paths
buildscript {
repositories {
google()
}
}
plugins {
kotlin("jvm") version "1.2.71"
application
id("com.github.johnrengelman.shadow") version "4.0.1"
id("org.javafxports.jfxmobile") version "1.3.16"
id("com.github.ben-manes.versions") version "0.20.0"
}
group = "xerus.music"
application {
mainClassName = "xerus.music.Launcher"
}
// region dependencies
kotlin.experimental.coroutines = Coroutines.ENABLE
repositories {
jcenter()
maven("https://jitpack.io")
maven("https://dl.bintray.com/ijabz/maven")
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
compile("com.github.Xerus2000.util", "javafx", "cd7376ec6e33543d81ee07884ec5a3b5827ee008")
// Music
compile("com.github.ngmusic", "moodplay", "3a1c3aa2b24136d2c1cd900afe840d21d0131939")
compile("net.jthink", "jaudiotagger", "2.2.4")
// Logging
compile("org.slf4j", "slf4j-api", "1.7.25")
compile("io.github.microutils", "kotlin-logging", "1.5.4")
implementation("ch.qos.logback", "logback-classic", "1.2.3")
// Platform-specifics
val CHARM_DOWN_VERSION = "2.0.1"
compile("com.gluonhq", "charm-down-common", CHARM_DOWN_VERSION)
desktopRuntime("com.gluonhq", "charm-down-desktop", CHARM_DOWN_VERSION)
desktopRuntime("org.xerial", "sqlite-jdbc", "3.25.2")
androidRuntime("com.gluonhq", "charm-down-android", CHARM_DOWN_VERSION)
androidRuntime("org.sqldroid", "sqldroid", "1.0.3")
desktopCompile("com.github.ngmusic.mpris-java", "mpris-extensions", "74f51fb6ef2535a55f41b01a0cf160c1ef4e698d")
iosRuntime("com.gluonhq", "charm-down-ios", CHARM_DOWN_VERSION)
}
jfxmobile {
// Work around https://github.com/gradle/kotlin-dsl/issues/457
fun JFXMobileExtension.android(action: AndroidExtension.() -> Unit) = (this as ExtensionAware).extensions.configure(AndroidExtension::class.java, action)
fun JFXMobileExtension.ios(action: IosExtension.() -> Unit) = (this as ExtensionAware).extensions.configure(IosExtension::class.java, action)
downConfig = DownConfiguration(project).apply {
plugins("storage", "settings")
}
android {
manifest = "src/android/AndroidManifest.xml"
compileSdkVersion = "26"
minSdkVersion = "21"
}
}
//endregion
// ANDROID TASKS
val ANDROID = "Android"
val androidApk = tasks.getByName("android").apply { mustRunAfter("clean") }
tasks {
"androidInstall" {
group = ANDROID
}
create("apk") {
group = ANDROID
dependsOn("clean", androidApk)
}
create<Exec>("pushApk") {
group = ANDROID
commandLine("adb", "push", "build/javafxports/android/MusicPlayer.apk", "storage/AE58-1072/Programmieren")
}
create("push") {
doLast {
Runtime.getRuntime().exec("adb shell ls /storage")
exec { commandLine("adb", "push", "src/layouts/CSS", "storage/AE58-1072/Programmieren/") }
exec { commandLine("adb", "push", "src/layouts/FXML", "storage/AE58-1072/Programmieren/") }
exec { commandLine("adb", "push", "build/javafxports/android/MusicPlayer.apk", "storage/AE58-1072/Programmieren/") }
}
}
create("androidRun") {
group = ANDROID
doLast {
exec {
commandLine("adb", "logcat", "-c")
}
exec {
commandLine("adb",
"shell", "monkey",
"-p", "xerus.music", "1")
}
exec {
commandLine("adb", "logcat", "-s", "System.out")
}
}
mustRunAfter("androidInstall")
}
tasks.replace("android").dependsOn("androidInstall", "androidRun").group = ANDROID
create<Exec>("androidUninstall") {
group = ANDROID
commandLine("adb", "shell", "pm", "uninstall", "xerus.music")
}
create("androidReinstall") {
doLast {
exec { commandLine("adb", "push", "shell", "pm", "uninstall") }
exec { commandLine("gradle", "android") }
}
}
}
// TASKS
val MAIN = "_main"
tasks {
"run"(JavaExec::class) {
group = MAIN
// gradle run -Dargs="FINE save"
args = System.getProperty("exec.args", "").split(" ")
}
tasks.replace("jar", ShadowJar::class.java).run {
group = MAIN
classifier = ""
description = "Assemble a fat Jar"
/*for (set in arrayOf(sourceSets.getByName("main"), sourceSets.getByName("desktop"))) {
from(set.output)
}*/
from(tasks["compileDesktopJava"].outputs)
configurations.add(project.configurations["desktopRuntime"])
}
create<Sync>("release") {
group = MAIN
dependsOn("apk", "jar")
val releases = Paths.get(properties["releaseFolder"].toString() + "/MusicPlayer")
doLast {
sync {
from("src/main/resources/layouts")
into(releases.resolve("/layouts"))
}
copy {
from("build/libs", "build/javafxports/android")
into("releases")
include("MusicPlayer.jar", "MusicPlayer.apk")
}
}
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}
println("Java version: ${JavaVersion.current()}")