Skip to content

Commit fd40141

Browse files
committed
Convert to Gradle's provider infrastructure
1 parent 148ec25 commit fd40141

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

jabgui/build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,24 @@ tasks.named<JavaExec>("run") {
152152
enableAssertions = true
153153
}
154154

155+
// region: Generate JabRef-post-image.wsf based on template
156+
val processedText: Provider<String> =
157+
providers.fileContents(layout.projectDirectory.file("${projectDir}/buildres/windows/JabRef-post-image.wsf"))
158+
.asText
159+
.map { it.replace("@jabRefRoot@", "$projectDir").replace('\\', '/') }
160+
161+
abstract class WriteTinyFile : DefaultTask() {
162+
@get:Input abstract val content: Property<String>
163+
@get:OutputFile abstract val outputFile: RegularFileProperty
164+
@TaskAction fun run() = outputFile.get().asFile.writeText(content.get())
165+
}
166+
167+
val genPostImageWsf = tasks.register<WriteTinyFile>("genPostImageWsf") {
168+
content.set(processedText)
169+
outputFile.set(layout.buildDirectory.file("generated/JabRef-post-image.wsf"))
170+
}
171+
// endregion
172+
155173
// Below should eventually replace the 'jlink {}' and doLast-copy configurations above
156174
javaModulePackaging {
157175
applicationName = "JabRef"
@@ -174,6 +192,7 @@ javaModulePackaging {
174192
include("JabRefHost.bat")
175193
include("JabRefHost.ps1")
176194
})
195+
targetResources.from(genPostImageWsf.flatMap { it.outputFile })
177196
}
178197
targetsWithOs("linux") {
179198
options.addAll(

0 commit comments

Comments
 (0)