[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
|
// Before 5.0 fileProperty is created via ProjectLayout
|
||||||
// https://docs.gradle.org/current/javadoc/org/gradle/api/model/ObjectFactory.html#fileProperty--
|
// https://docs.gradle.org/current/javadoc/org/gradle/api/model/ObjectFactory.html#fileProperty--
|
||||||
internal fun Project.newFileProperty(initialize: (() -> File)? = null): RegularFileProperty =
|
internal fun Project.newFileProperty(initialize: (() -> File)? = null): RegularFileProperty {
|
||||||
if (isGradleVersionAtLeast(5, 0)) {
|
val regularFileProperty = if (isGradleVersionAtLeast(5, 0)) {
|
||||||
project.objects.fileProperty().apply {
|
project.objects.fileProperty()
|
||||||
if (initialize != null) {
|
|
||||||
set(provider { RegularFile(initialize) })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
val projectLayoutClass = Class.forName("org.gradle.api.file.ProjectLayout")
|
val projectLayoutClass = Class.forName("org.gradle.api.file.ProjectLayout")
|
||||||
val filePropertyMethod = projectLayoutClass.getMethod("fileProperty")
|
val filePropertyMethod = projectLayoutClass.getMethod("fileProperty")
|
||||||
filePropertyMethod(project.layout) as RegularFileProperty
|
filePropertyMethod(project.layout) as RegularFileProperty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return regularFileProperty.apply {
|
||||||
|
if (initialize != null) {
|
||||||
|
set(provider { RegularFile(initialize) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user