1
+ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2
+
1
3
plugins {
2
4
id ' java-library'
3
5
id ' jacoco'
6
+ id ' com.gradleup.shadow' version ' 8.3.0'
4
7
}
5
8
6
9
java {
@@ -54,12 +57,17 @@ task e2eTest(type: Test) {
54
57
}
55
58
56
59
dependencies {
57
- testImplementation project(" :procedural:timeline" )
60
+ annotationProcessor project(' :procedural:processor' )
61
+
62
+ implementation project(" :procedural:scheduling" )
63
+ implementation project(" :procedural:timeline" )
64
+ implementation project(' :merlin-sdk' )
65
+ implementation project(' :type-utils' )
66
+ implementation project(' :contrib' )
67
+
58
68
testImplementation project(" :procedural:remote" )
59
69
testImplementation " com.zaxxer:HikariCP:5.1.0"
60
70
testImplementation(" org.postgresql:postgresql:42.6.0" )
61
- testImplementation project(' :merlin-driver' )
62
- testImplementation project(' :type-utils' )
63
71
64
72
testImplementation ' com.microsoft.playwright:playwright:1.37.0'
65
73
@@ -69,3 +77,65 @@ dependencies {
69
77
testImplementation ' org.junit.jupiter:junit-jupiter-engine:5.10.0'
70
78
testImplementation ' org.junit.jupiter:junit-jupiter-params:5.10.0'
71
79
}
80
+
81
+ tasks. register(' buildAllSchedulingProcedureJars' ) {
82
+ group = ' SchedulingProcedureJars'
83
+
84
+ dependsOn " generateSchedulingProcedureJarTasks"
85
+ dependsOn {
86
+ tasks. findAll { task -> task. name. startsWith(' buildSchedulingProcedureJar_' ) }
87
+ }
88
+ }
89
+
90
+ tasks. create(" generateSchedulingProcedureJarTasks" ) {
91
+ group = ' SchedulingProcedureJars'
92
+
93
+ final proceduresDir = findFirstMatchingBuildDir(" generated/procedures" )
94
+
95
+ if (proceduresDir == null ) {
96
+ println " No procedures folder found"
97
+ return
98
+ }
99
+ println " Generating jar tasks for the following procedures directory: ${ proceduresDir} "
100
+
101
+ final files = file(proceduresDir). listFiles()
102
+ if (files. length == 0 ) {
103
+ println " No procedures available within folder ${ proceduresDir} "
104
+ return
105
+ }
106
+
107
+ files. toList(). each { file ->
108
+ final nameWithoutExtension = file. name. replace(" .java" , " " )
109
+ final taskName = " buildSchedulingProcedureJar_${ nameWithoutExtension} "
110
+
111
+ println " Generating ${ taskName} task, which will build ${ nameWithoutExtension} .jar"
112
+
113
+ tasks. create(taskName, ShadowJar ) {
114
+ group = ' SchedulingProcedureJars'
115
+ configurations = [project. configurations. compileClasspath]
116
+ from sourceSets. main. output
117
+ archiveBaseName = " " // clear
118
+ archiveClassifier. set(nameWithoutExtension) // set output jar name
119
+ manifest {
120
+ attributes ' Main-Class' : getMainClassFromGeneratedFile(file)
121
+ }
122
+ minimize()
123
+ }
124
+ }
125
+ }
126
+
127
+ private String findFirstMatchingBuildDir (String pattern ) {
128
+ String found = null
129
+ final generatedDir = file(" build/generated/sources" )
130
+ generatedDir. mkdirs()
131
+ generatedDir. eachDirRecurse { dir -> if (dir. path. contains(pattern)) found = dir. path }
132
+ return found
133
+ }
134
+
135
+ private static String getMainClassFromGeneratedFile (File file ) {
136
+ final fileString = file. toString()
137
+ final prefix = " build/generated/sources/annotationProcessor/java/main/"
138
+ final index = fileString. indexOf(prefix) + prefix. length()
139
+ final trimmed = fileString. substring(index). replace(" .java" , " " )
140
+ return trimmed. replace(" /" , " ." )
141
+ }
0 commit comments