Fix dependency loading

This commit is contained in:
Alexander Nozik 2021-05-21 10:05:46 +03:00
parent e0d331d4d4
commit e44bf118dc

View File

@ -49,7 +49,7 @@ class KScienceExtension(val project: Project) {
fun useCoroutines( fun useCoroutines(
version: String = KScienceVersions.coroutinesVersion, version: String = KScienceVersions.coroutinesVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN, sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API configuration: DependencyConfiguration = DependencyConfiguration.API,
): Unit = project.useCommonDependency( ): Unit = project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-coroutines-core:$version", "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version",
dependencySourceSet = sourceSet, dependencySourceSet = sourceSet,
@ -62,7 +62,7 @@ class KScienceExtension(val project: Project) {
fun useAtomic( fun useAtomic(
version: String = KScienceVersions.atomicVersion, version: String = KScienceVersions.atomicVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN, sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION,
): Unit = project.run { ): Unit = project.run {
plugins.apply("kotlinx-atomicfu") plugins.apply("kotlinx-atomicfu")
useCommonDependency( useCommonDependency(
@ -79,7 +79,7 @@ class KScienceExtension(val project: Project) {
version: String = KScienceVersions.serializationVersion, version: String = KScienceVersions.serializationVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN, sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API, configuration: DependencyConfiguration = DependencyConfiguration.API,
block: SerializationTargets.() -> Unit = {} block: SerializationTargets.() -> Unit = {},
): Unit = project.run { ): Unit = project.run {
plugins.apply("org.jetbrains.kotlin.plugin.serialization") plugins.apply("org.jetbrains.kotlin.plugin.serialization")
val artifactName = if (version.startsWith("0")) { val artifactName = if (version.startsWith("0")) {
@ -95,17 +95,23 @@ class KScienceExtension(val project: Project) {
SerializationTargets(sourceSet, configuration).apply(block) SerializationTargets(sourceSet, configuration).apply(block)
} }
/**
* Add platform-specific JavaFX dependencies with given list of [FXModule]s
*/
fun useFx( fun useFx(
vararg modules: FXModule, vararg modules: FXModule,
configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY, configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY,
version: String = "11", version: String = "11",
platform: FXPlatform = defaultPlatform platform: FXPlatform = defaultPlatform,
) = project.useFx(modules.toList(), configuration, version, platform) ) = project.useFx(modules.toList(), configuration, version, platform)
/**
* Add dependency on kotlinx-html library
*/
fun useHtml( fun useHtml(
version: String = KScienceVersions.htmlVersion, version: String = KScienceVersions.htmlVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN, sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION configuration: DependencyConfiguration = DependencyConfiguration.API,
): Unit = project.useCommonDependency( ): Unit = project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-html:$version", "org.jetbrains.kotlinx:kotlinx-html:$version",
dependencySourceSet = sourceSet, dependencySourceSet = sourceSet,
@ -115,8 +121,16 @@ class KScienceExtension(val project: Project) {
/** /**
* Use kotlinx-datetime library with default version or [version] * Use kotlinx-datetime library with default version or [version]
*/ */
fun useDateTime(version: String = KScienceVersions.dateTimeVersion){ fun useDateTime(
project.useCommonDependency("org.jetbrains.kotlinx:kotlinx-datetime:$version") version: String = KScienceVersions.dateTimeVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API,
) {
project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-datetime:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
} }
/** /**