Rename non-Framework project modules
Prior to this commit, the Spring Framework build would mix proper framework modules (spring-* modules published to maven central) and internal modules such as: * "spring-framework-bom" (which publishes the Framework BOM with all modules) * "spring-core-coroutines" which is an internal modules for Kotlin compilation only This commit renames these modules so that they don't start with "spring-*"; we're also moving the "kotlin-coroutines" module under "spring-core", since it's merged in the resulting JAR. See gh-23282
This commit is contained in:
29
spring-core/kotlin-coroutines/kotlin-coroutines.gradle
Normal file
29
spring-core/kotlin-coroutines/kotlin-coroutines.gradle
Normal file
@@ -0,0 +1,29 @@
|
||||
description = "Spring Core Coroutines support"
|
||||
|
||||
apply plugin: "kotlin"
|
||||
|
||||
dependencies {
|
||||
compile("org.jetbrains.kotlin:kotlin-reflect")
|
||||
compile("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
compile("io.projectreactor:reactor-core")
|
||||
compile("org.jetbrains.kotlinx:kotlinx-coroutines-core")
|
||||
compile("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
|
||||
}
|
||||
|
||||
// Avoid publishing coroutines JAR to the artifact repository
|
||||
if (pluginManager.hasPlugin("artifactoryPublish")) {
|
||||
artifactoryPublish.skip = true
|
||||
}
|
||||
|
||||
eclipse {
|
||||
project {
|
||||
buildCommand "org.jetbrains.kotlin.ui.kotlinBuilder"
|
||||
buildCommand "org.eclipse.jdt.core.javabuilder"
|
||||
natures "org.jetbrains.kotlin.core.kotlinNature"
|
||||
natures "org.eclipse.jdt.core.javanature"
|
||||
linkedResource name: "kotlin_bin", type: "2", locationUri: "org.jetbrains.kotlin.core.filesystem:/" + project.name + "/kotlin_bin"
|
||||
}
|
||||
classpath {
|
||||
containers "org.jetbrains.kotlin.core.KOTLIN_CONTAINER"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:JvmName("CoroutinesUtils")
|
||||
package org.springframework.core
|
||||
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.reactive.awaitFirstOrNull
|
||||
import kotlinx.coroutines.reactor.asFlux
|
||||
|
||||
import kotlinx.coroutines.reactor.mono
|
||||
import reactor.core.publisher.Mono
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.lang.reflect.Method
|
||||
import kotlin.reflect.full.callSuspend
|
||||
import kotlin.reflect.jvm.kotlinFunction
|
||||
|
||||
/**
|
||||
* Convert a [Deferred] instance to a [Mono] one.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
internal fun <T: Any> deferredToMono(source: Deferred<T>) =
|
||||
mono(Dispatchers.Unconfined) { source.await() }
|
||||
|
||||
/**
|
||||
* Convert a [Mono] instance to a [Deferred] one.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
internal fun <T: Any> monoToDeferred(source: Mono<T>) =
|
||||
GlobalScope.async(Dispatchers.Unconfined) { source.awaitFirstOrNull() }
|
||||
|
||||
/**
|
||||
* Invoke an handler method converting suspending method to [Mono] or
|
||||
* [reactor.core.publisher.Flux] if necessary.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@ExperimentalCoroutinesApi
|
||||
internal fun invokeHandlerMethod(method: Method, bean: Any, vararg args: Any?): Any? {
|
||||
val function = method.kotlinFunction!!
|
||||
return if (function.isSuspend) {
|
||||
val mono = mono(Dispatchers.Unconfined) {
|
||||
function.callSuspend(bean, *args.sliceArray(0..(args.size-2)))
|
||||
.let { if (it == Unit) null else it }
|
||||
}.onErrorMap(InvocationTargetException::class.java) { it.targetException }
|
||||
if (function.returnType.classifier == Flow::class) {
|
||||
mono.flatMapMany { (it as Flow<Any>).asFlux() }
|
||||
}
|
||||
else {
|
||||
mono
|
||||
}
|
||||
}
|
||||
else {
|
||||
function.call(bean, *args)
|
||||
}
|
||||
}
|
||||
@@ -70,12 +70,12 @@ dependencies {
|
||||
cglib("cglib:cglib:${cglibVersion}@jar")
|
||||
objenesis("org.objenesis:objenesis:${objenesisVersion}@jar")
|
||||
jarjar("org.pantsbuild:jarjar:1.7.2")
|
||||
coroutines(project(":spring-core-coroutines"))
|
||||
coroutines(project(":kotlin-coroutines"))
|
||||
|
||||
compile(files(cglibRepackJar))
|
||||
compile(files(objenesisRepackJar))
|
||||
compile(project(":spring-jcl"))
|
||||
compileOnly(project(":spring-core-coroutines"))
|
||||
compileOnly(project(":kotlin-coroutines"))
|
||||
optional("net.sf.jopt-simple:jopt-simple:5.0.4")
|
||||
optional("org.aspectj:aspectjweaver:${aspectjVersion}")
|
||||
optional("org.jetbrains.kotlin:kotlin-reflect")
|
||||
@@ -94,7 +94,7 @@ dependencies {
|
||||
testCompile("com.fasterxml.woodstox:woodstox-core:5.2.0") {
|
||||
exclude group: "stax", module: "stax-api"
|
||||
}
|
||||
testCompile(project(":spring-core-coroutines"))
|
||||
testCompile(project(":kotlin-coroutines"))
|
||||
}
|
||||
|
||||
jar {
|
||||
|
||||
Reference in New Issue
Block a user