Skip to content

Commit 7960957

Browse files
committed
Convert to Gradle's provider infrastructure
1 parent 29fbfdb commit 7960957

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

jabgui/build.gradle.kts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import org.apache.tools.ant.filters.ReplaceTokens
2-
3-
41
plugins {
52
id("org.jabref.gradle.module")
63
id("application")
@@ -152,6 +149,24 @@ tasks.named<JavaExec>("run") {
152149
enableAssertions = true
153150
}
154151

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

0 commit comments

Comments
 (0)