mirror of
https://github.com/processing/processing4.git
synced 2026-03-13 16:07:38 +01:00
Write and load version.properties for plugin (#1423)
Add a writeVersion Gradle task that writes project.version to build/resources/main/version.properties, so the plugin can access the project version at runtime. This way the version number of the plugin and the used version of processing.core will be the same.
This commit is contained in:
@@ -38,4 +38,16 @@ publishing{
|
||||
url = uri(project(":app").layout.buildDirectory.dir("resources-bundled/common/repository").get().asFile.absolutePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("writeVersion") {
|
||||
// make the version available to the plugin at runtime by writing it to a properties file in the resources directory
|
||||
doLast {
|
||||
val file = layout.buildDirectory.file("resources/main/version.properties").get().asFile
|
||||
file.parentFile.mkdirs()
|
||||
file.writeText("version=${project.version}")
|
||||
}
|
||||
}
|
||||
tasks.named("processResources") {
|
||||
dependsOn("writeVersion")
|
||||
}
|
||||
@@ -20,7 +20,10 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
|
||||
val sketchName = project.layout.projectDirectory.asFile.name.replace(Regex("[^a-zA-Z0-9_]"), "_")
|
||||
|
||||
val isProcessing = project.findProperty("processing.version") != null
|
||||
val processingVersion = project.findProperty("processing.version") as String? ?: "4.3.4"
|
||||
val processingVersion = project.findProperty("processing.version") as String?
|
||||
?: javaClass.classLoader.getResourceAsStream("version.properties")?.use { stream ->
|
||||
java.util.Properties().apply { load(stream) }.getProperty("version")
|
||||
} ?: "4.3.4"
|
||||
val processingGroup = project.findProperty("processing.group") as String? ?: "org.processing"
|
||||
val workingDir = project.findProperty("processing.workingDir") as String?
|
||||
val debugPort = project.findProperty("processing.debugPort") as String?
|
||||
|
||||
Reference in New Issue
Block a user