-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.gradle.kts
118 lines (99 loc) · 3.14 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
import org.apache.tools.ant.taskdefs.condition.Os
import java.io.FileInputStream
import java.io.InputStreamReader
import java.util.*
plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "2.0.10"
id("org.jetbrains.intellij") version "1.17.3"
}
group = "me.rerere"
version = "1.7.5"
repositories {
mavenCentral()
}
dependencies {
implementation("com.github.weisj:jsvg:1.3.0")
}
// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
version = "2024.2"
type = "IU" // Target IDE Platform
plugins = listOf("JavaScript")
}
fun properties(key: String) = project.findProperty(key).toString()
// include the generated source directory
sourceSets["main"].java.srcDirs("src/main/gen")
tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "17"
dependsOn("processJavaScript")
}
patchPluginXml {
sinceBuild = "241"
untilBuild = "243.*"
}
signPlugin {
certificateChain = file("sign/chain.crt").readText()
privateKey = System.getenv(file("sign/private.pem").readText())
password = System.getenv("PRIVATE_KEY_PASSWORD")
}
publishPlugin {
token = System.getenv("PUBLISH_TOKEN")
}
task("processJavaScript") {
inputs.dir("src/main/javascript/src")
inputs.file("src/main/javascript/package.json")
inputs.file("src/main/javascript/babel.config.json")
inputs.file("src/main/javascript/tsconfig.json")
inputs.file("src/main/javascript/rollup.config.js")
outputs.dir("${project.projectDir}/unojs")
outputs.cacheIf { true }
doFirst {
file("${project.projectDir}/unojs")
.takeIf { it.exists() }
?.let {
it.listFiles()?.forEach { file ->
println("del $file")
file.delete()
}
}
exec {
workingDir("${project.projectDir}/src/main/javascript")
val npm = if (Os.isFamily(Os.FAMILY_WINDOWS)) "npm.cmd" else "npm"
commandLine(npm, "run", "build")
}
}
}
prepareSandbox {
inputs.dir("unojs")
doLast {
copy {
from("${project.projectDir}/unojs")
into("${destinationDir.path}/${project.name}/unojs")
}
}
}
runIde {
val idePath = getLocalProperty("IDE_PATH") as String?
idePath?.let {
ideDir = file(idePath)
}
}
}
fun getLocalProperty(key: String, file: String = "local.properties"): Any? {
val properties = Properties()
val localProperties = File(file)
if (localProperties.isFile) {
InputStreamReader(FileInputStream(localProperties), Charsets.UTF_8).use { reader ->
properties.load(reader)
}
} else return null
return properties.getProperty(key)
}