On Thursday, November 5, 2020 at 8:36:49 AM UTC+1, Joker Joker wrote:
I want to share solution for gradle based project.This solution allows to get any build's properties on client/server.1) Add to build.gradle...task createProperties(dependsOn: processResources) {
doLast {
new File("$buildDir/resources/main/yourmodule/shared/ IVersion.properties"). withWriter { w ->
Properties p = new Properties()
p['version'] = project.version.toString()
p.store w, null
}
}
}classes {
dependsOn createProperties
}...
I'd rather generate the file earlier and add it to the main sourceSet; also, make your task run only when needed by declaring its inputs and outputs:
(using the Kotlin DSL here)
val createProperties by tasks.registering {
val outputDir = file("$buildDir/generated/resources/createProperties/")
inputs.property("version", project::getVersion)
outputs.dir(outputDir)
doFirst {
val props = Properties()
props.setProperty("version", project.version.toString())
file("$outputDir/yourmodule/shared/IVersion.properties").apply {
project.mkdir(parentFile)
writer().use { props.store(it) }
}
}
}
sourceSets {
main {
resources {
srcDir(createProperties)
}
}
}
either that or have an existing resource file with placeholders, and do replacements in the processResources task:
tasks {
processResources {
filesMatching("yourmodule/shared/IVersion.properties") {
filter<ReplaceToken> {
"tokens" to mapOf(
"version" to project.version
)
}
}
}
}
This would be the equivalent of Maven filtering, in Gradle.
That being said, I'd rather go with -setProperty for GWT, and generate a file that way for server-side use only if needed.
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/9dda78bc-23da-48c0-91af-be176d46984eo%40googlegroups.com.
No comments:
Post a Comment