-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
107 lines (83 loc) · 2.41 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
java
kotlin("jvm") version "1.8.0"
}
val userHome = System.getProperty("user.home")
val vpPluginsDir = "${userHome}\\AppData\\Roaming\\VisualParadigm\\plugins"
val vpPluginName = project.name
val vpPluginDir = "$vpPluginsDir/$vpPluginName"
group = "com.vygovskiy.vpplugins"
version = "1.0"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
compileOnly(files("lib/openapi.jar"))
//implementation(fileTree(mapOf("dir" to "lib", "include" to listOf("*.jar"))))
testImplementation("junit", "junit", "4.12")
implementation("com.miglayout:miglayout:3.7.4")
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.register("lvTest") {
val uh = System.getProperty("user.home")
println("")
}
tasks.register("vpCopyPlugin") {
group = "Visual Paradigm"
dependsOn(
"build",
"vpDeletePluginDir",
"vpCopyClasses",
"vpCopyDependenciesJars"
)
}
tasks.register<Delete>("vpDeletePluginDir") {
group = "Visual Paradigm"
delete(vpPluginDir)
}
tasks.register<Copy>("vpCopyClasses") {
group = "Visual Paradigm"
dependsOn("build")
from(
"$buildDir/classes/kotlin/main",
"$buildDir/resources/main"
)
into(vpPluginDir)
doLast {
copyPluginXml()
}
}
tasks.register<Copy>("vpCopyDependenciesJars") {
group = "Visual Paradigm"
from(
getJarDependencies()
.map { it.absoluteFile }
.toTypedArray()
)
into("$vpPluginDir/lib")
}
/**
* Return collection of JAR dependencies
*/
fun getJarDependencies(): FileCollection {
return configurations.runtimeClasspath.get()
.filter { !it.name.startsWith("openapi") }
.filter { it.name.endsWith("jar")}
}
fun copyPluginXml() {
val runtimeSection = getJarDependencies().joinToString(
separator = "\n",
prefix = "\n <runtime>\n",
postfix = "\n </runtime>\n"
) {" <library path='lib/${it.name}' relativePath='true'/>"}
val pluginXmlFile = File("$buildDir/resources/main/plugin.xml").readText()
val content = pluginXmlFile.replace("<runtime/>", runtimeSection, false)
File("$vpPluginDir/plugin.xml").writeText(content)
}