[Gradle, JS] Fix newFileProperty for gradle <5.0
This commit is contained in:
+3
-1
@@ -1 +1,3 @@
|
||||
kotlin.tests.individualTaskReports=true
|
||||
kotlin.tests.individualTaskReports=true
|
||||
#because of dependency (kotlinx-html) which is not klib yet
|
||||
kotlin.js.mode=legacy
|
||||
+11
-8
@@ -40,15 +40,18 @@ internal fun <T> Project.optionalProvider(initialize: () -> T?): ReadOnlyPropert
|
||||
|
||||
// Before 5.0 fileProperty is created via ProjectLayout
|
||||
// https://docs.gradle.org/current/javadoc/org/gradle/api/model/ObjectFactory.html#fileProperty--
|
||||
internal fun Project.newFileProperty(initialize: (() -> File)? = null): RegularFileProperty =
|
||||
if (isGradleVersionAtLeast(5, 0)) {
|
||||
project.objects.fileProperty().apply {
|
||||
if (initialize != null) {
|
||||
set(provider { RegularFile(initialize) })
|
||||
}
|
||||
}
|
||||
internal fun Project.newFileProperty(initialize: (() -> File)? = null): RegularFileProperty {
|
||||
val regularFileProperty = if (isGradleVersionAtLeast(5, 0)) {
|
||||
project.objects.fileProperty()
|
||||
} else {
|
||||
val projectLayoutClass = Class.forName("org.gradle.api.file.ProjectLayout")
|
||||
val filePropertyMethod = projectLayoutClass.getMethod("fileProperty")
|
||||
filePropertyMethod(project.layout) as RegularFileProperty
|
||||
}
|
||||
}
|
||||
|
||||
return regularFileProperty.apply {
|
||||
if (initialize != null) {
|
||||
set(provider { RegularFile(initialize) })
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user