11import org.gradle.api.JavaVersion.*
22import org.graalvm.buildtools.gradle.dsl.GraalVMExtension
3+ import org.gradle.api.internal.plugins.DefaultTemplateBasedStartScriptGenerator
34import java.lang.System.getProperty
45
56plugins {
6- kotlin(" jvm" ) version(" 1.8.0 " )
7- id(" org.graalvm.buildtools.native" ) version(" 0.9.19 " )
7+ kotlin(" jvm" ) version(" 1.8.20 " )
8+ id(" org.graalvm.buildtools.native" ) version(" 0.9.21 " )
89}
910
10- val os = getProperty(" os.name" ).toLowerCase ()
11+ val os = getProperty(" os.name" ).lowercase ()
1112
12- val hexagonVersion = " 2.4.5 "
13- val hexagonExtraVersion = " 2.4 .0"
14- val vertxVersion = " 4.3.7 "
13+ val hexagonVersion = " 2.8.0 "
14+ val hexagonExtraVersion = " 2.8 .0"
15+ val vertxVersion = " 4.4.1 "
1516
16- val modules = " java.logging"
17- val options = " -Xmx32m"
18- val icon = " $projectDir /logo.png"
1917val gradleScripts = " https://raw.githubusercontent.com/hexagonkt/hexagon/$hexagonVersion /gradle"
2018
19+ ext.set(" modules" , " java.logging" )
20+ ext.set(" options" , " -Xmx32m" )
21+ ext.set(" icon" , " $projectDir /logo.png" )
22+ ext.set(" applicationClass" , " co.codecv.CvKt" )
23+
2124apply (from = " $gradleScripts /kotlin.gradle" )
2225apply (from = " $gradleScripts /application.gradle" )
2326apply (from = " $gradleScripts /native.gradle" )
2427
2528group = " com.hexagonkt.tools"
26- version = " 0.9.17 "
29+ version = " 0.9.18 "
2730description = " CVs for programmers"
2831
29- ext {
30- set(" modules" , modules)
31- set(" options" , options)
32- set(" icon" , icon)
33- }
34-
3532if (current() !in setOf (VERSION_16 , VERSION_17 , VERSION_18 , VERSION_19 ))
3633 error(" This build must be run with JDK 16+. Current: ${current()} " )
3734
38- extensions.configure<JavaApplication > {
39- mainClass.set(" co.codecv.CvKt" )
40- }
41-
4235dependencies {
43- " implementation" (" com.hexagonkt:http_server_jetty :$hexagonVersion " )
36+ " implementation" (" com.hexagonkt:http_server_netty :$hexagonVersion " )
4437 " implementation" (" com.hexagonkt:logging_slf4j_jul:$hexagonVersion " )
4538 " implementation" (" com.hexagonkt:serialization_jackson_json:$hexagonVersion " )
4639 " implementation" (" com.hexagonkt:serialization_jackson_yaml:$hexagonVersion " )
4740 " implementation" (" com.hexagonkt:serialization_jackson_toml:$hexagonVersion " )
4841 " implementation" (" com.hexagonkt:templates_pebble:$hexagonVersion " )
42+ " implementation" (" com.hexagonkt.extra:helpers:$hexagonExtraVersion " )
43+ " implementation" (" com.hexagonkt.extra:args:$hexagonExtraVersion " )
4944 " implementation" (" com.hexagonkt.extra:web:$hexagonExtraVersion " )
45+
5046 " implementation" (" io.vertx:vertx-json-schema:$vertxVersion " )
5147
5248 " testImplementation" (" com.hexagonkt:http_client_jetty:$hexagonVersion " )
@@ -55,6 +51,24 @@ dependencies {
5551tasks.named(" classes" ) { dependsOn(" addResources" ) }
5652tasks.named(" build" ) { dependsOn(" installDist" ) }
5753
54+ tasks.named<CreateStartScripts >(" startScripts" ) {
55+ dependsOn(" jacocoTestReport" )
56+
57+ listOf (unixStartScriptGenerator, windowsStartScriptGenerator).forEach {
58+ val generator = it as DefaultTemplateBasedStartScriptGenerator
59+ val currentTemplate = generator.template.asString()
60+ val newTemplate = when (it) {
61+ windowsStartScriptGenerator ->
62+ currentTemplate.replace(" set CLASSPATH=\$ classpath" , " set CLASSPATH=\$ classpath;." )
63+ unixStartScriptGenerator ->
64+ currentTemplate.replace(" CLASSPATH=\$ classpath" , " CLASSPATH=\$ classpath:." )
65+ else ->
66+ error(" Unexpected script" )
67+ }
68+ generator.template = resources.text.fromString(newTemplate)
69+ }
70+ }
71+
5872tasks.create<Copy >(" addResources" ) {
5973 from(projectDir)
6074 include(" templates/cv.html" )
@@ -93,17 +107,7 @@ extensions.configure<GraalVMExtension> {
93107 val monitoring =
94108 if (getProperty(" enableMonitoring" ) == " true" ) " --enable-monitoring" else null
95109
96- listOfNotNull(
97- static,
98- monitoring,
99- " --enable-preview" ,
100- " --enable-http" ,
101- " --enable-https" ,
102- " --enable-url-protocols=classpath" ,
103- " --initialize-at-build-time=com.hexagonkt.core.ClasspathHandler" ,
104- " -R:MaxHeapSize=32m" ,
105- )
106- .forEach(buildArgs::add)
110+ listOfNotNull(static, monitoring).forEach(buildArgs::add)
107111 }
108112 }
109113}
0 commit comments