forked from korlibs/korge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
102 lines (90 loc) · 3.72 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
import korlibs.root.*
import org.jetbrains.kotlin.backend.common.serialization.*
import org.jetbrains.kotlin.gradle.tasks.*
plugins {
//id "com.dorongold.task-tree" version "2.1.1"
// ./gradlew :kds:compileKotlinJs taskTree
}
korlibs.root.RootKorlibsPlugin.doInit(rootProject)
// Used to verify we are publishing with iOS references even if we do the publishing from another machine like windows or linux
tasks {
val checkModulePublication by creating {
doLast {
val publishedKorgeModule = File("${System.getProperty("user.home")}/.m2/repository/com/soywiz/korge/korge/999.0.0.999/korge-999.0.0.999.module")
val publishedKorgeModuleText = publishedKorgeModule.readText()
for (ref in listOf("jvmApiElements", "jsApiElements", "android", "iosArm64")) {
check (ref in publishedKorgeModuleText) {
System.err.println(publishedKorgeModuleText)
"Can't find '$ref' on the published '$publishedKorgeModule'"
}
}
}
}
}
afterEvaluate {
allprojects {
val publishing = extensions.findByType(PublishingExtension::class.java)
if (publishing == null) {
val copyArtifactsToDirectory by tasks.registering(Task::class) {
}
} else {
val copyArtifactsToDirectory by tasks.registering(Task::class) {
dependsOn("publishToMavenLocal")
doLast {
val base = rootProject.layout.buildDirectory.dir("artifacts")
for (pub in publishing.publications.filterIsInstance<MavenPublication>()) {
//println(pub.artifacts.toList())
val basePath = pub.groupId.replace(".", "/") + "/" + pub.artifactId + "/" + pub.version
val baseDir = File(base.get().asFile, basePath)
val m2Dir = File(File(System.getProperty("user.home"), ".m2/repository"), basePath)
//println("m2Dir=$m2Dir")
// .module
copy {
from(m2Dir)
into(baseDir)
}
}
}
}
}
}
}
val mversion = project.getForcedVersion()
tasks {
val generateArtifactsZip by registering(Zip::class) {
subprojects {
dependsOn("${this.path}:copyArtifactsToDirectory")
}
from(rootProject.layout.buildDirectory.dir("artifacts"))
archiveFileName = "korge-$mversion.zip"
destinationDirectory = rootProject.layout.buildDirectory
}
val generateArtifactsTar by registering(Tar::class) {
subprojects {
dependsOn("${this.path}:copyArtifactsToDirectory")
}
from(rootProject.layout.buildDirectory.dir("artifacts"))
//compression = Compression.GZIP
//into(rootProject.layout.buildDirectory)
archiveFileName = "korge-$mversion.tar"
destinationDirectory = rootProject.layout.buildDirectory
}
// winget install zstd
val generateArtifactsTarZstd by registering(Exec::class) {
val rootFile = rootProject.layout.buildDirectory.asFile.get()
dependsOn(generateArtifactsTar)
commandLine(
"zstd", "-z",
//"--ultra", "-22",
"-17",
"-f", File(rootFile, "korge-$mversion.tar").absolutePath,
"-o", File(rootFile, "korge-$mversion.tar.zstd").absolutePath
)
}
}
afterEvaluate {
println("-----------")
println(tasks.findByPath(":korge:jvmMainClasses")!!::class)
println(tasks.findByPath(":korge:compileKotlinJvm")!!::class)
//org.jetbrains.kotlin.gradle.tasks.KotlinCompile
}