141 lines
4.2 KiB
Plaintext
141 lines
4.2 KiB
Plaintext
plugins {
|
|
id("java")
|
|
id("org.jetbrains.kotlin.jvm") version "1.9.23"
|
|
id("org.jetbrains.intellij") version "1.17.2"
|
|
id("org.jetbrains.grammarkit") version "2022.3.2.2"
|
|
id("de.undercouch.download") version "5.6.0"
|
|
}
|
|
val slintVersion: String by project
|
|
//github url
|
|
val slintGithubUrl = "https://github.com/slint-ui/slint/releases/download/v$slintVersion"
|
|
//download dir
|
|
val slintViewerDownloadDir = "${layout.buildDirectory.get()}/slint-viewer"
|
|
//decompression path
|
|
val slintViewerBinaryDir = "${layout.buildDirectory.get()}/slint-viewer/$slintVersion"
|
|
|
|
val grammarGeneratedRoot = "${layout.buildDirectory.get()}/generated/sources/grammar/"
|
|
//github filename-> decompression name
|
|
val slintViewerFilenames = arrayOf(
|
|
"slint-viewer-linux.tar.gz" to "slint-viewer-linux",
|
|
"slint-viewer-macos.tar.gz" to "slint-viewer-macos",
|
|
"slint-viewer-windows.zip" to "slint-viewer-windows.exe",
|
|
)
|
|
|
|
sourceSets {
|
|
main {
|
|
java {
|
|
srcDirs(file("${grammarGeneratedRoot}/main/java"))
|
|
}
|
|
}
|
|
}
|
|
group = "me.zhouxi"
|
|
version = "1.0-SNAPSHOT"
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
intellij {
|
|
version.set("IC-2023.2.5")
|
|
sandboxDir.set("idea-sandbox")
|
|
plugins.set(listOf("java"))
|
|
}
|
|
dependencies {
|
|
compileOnly("org.projectlombok:lombok:1.18.32")
|
|
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
|
testCompileOnly("org.projectlombok:lombok:1.18.32")
|
|
testAnnotationProcessor("org.projectlombok:lombok:1.18.32")
|
|
implementation("org.jetbrains:grammar-kit:2022.3.2")
|
|
}
|
|
tasks {
|
|
buildPlugin {
|
|
//copy slint-viewer to plugin dir
|
|
from(slintViewerBinaryDir) {
|
|
into("/slint-viewer")
|
|
}
|
|
}
|
|
withType<JavaExec>().configureEach {
|
|
if (name.endsWith("main()")) {
|
|
notCompatibleWithConfigurationCache("JavaExec created by IntelliJ")
|
|
}
|
|
}
|
|
|
|
runIde {
|
|
//copy slint-viewer
|
|
doFirst {
|
|
copy {
|
|
from(slintViewerBinaryDir)
|
|
into("idea-sandbox/plugins/intellij-slint/slint-viewer")
|
|
}
|
|
}
|
|
}
|
|
|
|
withType<JavaCompile> {
|
|
sourceCompatibility = "17"
|
|
targetCompatibility = "17"
|
|
}
|
|
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
|
kotlinOptions.jvmTarget = "17"
|
|
}
|
|
|
|
patchPluginXml {
|
|
sinceBuild.set("232")
|
|
untilBuild.set("242.*")
|
|
}
|
|
|
|
generateParser {
|
|
purgeOldFiles.set(true)
|
|
sourceFile.set(file("src/main/grammar/main.bnf"))
|
|
pathToParser.set("SlintParser")
|
|
targetRootOutputDir.set(file("${grammarGeneratedRoot}/main/java"))
|
|
pathToPsiRoot.set("psi")
|
|
}
|
|
generateLexer {
|
|
sourceFile.set(file("src/main/grammar/main.flex"))
|
|
targetOutputDir.set(file("${grammarGeneratedRoot}/main/java/me/zhouxi/slint/lang/lexer"))
|
|
purgeOldFiles.set(true)
|
|
}
|
|
|
|
withType<Test> {
|
|
jvmArgs("-Djava.awt.headless=true")
|
|
}
|
|
|
|
register("downloadSlintViewer") {
|
|
doFirst {
|
|
slintViewerFilenames.forEach { fileDesc ->
|
|
val (filename, renamed) = fileDesc
|
|
val src = "$slintGithubUrl/$filename"
|
|
val fileTarget = "$slintViewerDownloadDir/$filename"
|
|
download.run {
|
|
src(src)
|
|
dest(fileTarget)
|
|
}
|
|
copy {
|
|
val fileTree = if (filename.endsWith("zip")) {
|
|
zipTree(fileTarget)
|
|
} else {
|
|
tarTree(fileTarget)
|
|
}
|
|
from(fileTree)
|
|
//include executable file path
|
|
include("slint-viewer/slint-viewer*")
|
|
eachFile {
|
|
//rename to platform name
|
|
this.relativePath = RelativePath(true, renamed)
|
|
}
|
|
into(slintViewerBinaryDir)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
signPlugin {
|
|
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
|
|
privateKey.set(System.getenv("PRIVATE_KEY"))
|
|
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
|
|
}
|
|
|
|
publishPlugin {
|
|
token.set(System.getenv("PUBLISH_TOKEN"))
|
|
}
|
|
}
|