import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.config.Services
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException
import org.onap.ccsdk.cds.controllerblueprints.core.checkFileExists
import org.onap.ccsdk.cds.controllerblueprints.core.logger
import java.io.File
import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
import kotlin.system.measureTimeMillis
-open class BluePrintCompileService {
+open class BlueprintCompileService {
- val log = logger(BluePrintCompileService::class)
+ val log = logger(BlueprintCompileService::class)
companion object {
/** Compile the [bluePrintSourceCode] and get the [kClassName] instance for the constructor [args] */
suspend fun <T> eval(
- bluePrintSourceCode: BluePrintSourceCode,
+ bluePrintSourceCode: BlueprintSourceCode,
kClassName: String,
args: ArrayList<Any?>?
): T {
}
}
- val classLoaderWithDependencies = BluePrintCompileCache.classLoader(bluePrintSourceCode.cacheKey)
+ val classLoaderWithDependencies = BlueprintCompileCache.classLoader(bluePrintSourceCode.cacheKey)
/** Create the instance from the class loader */
return instance(classLoaderWithDependencies, kClassName, args)
}
/** Compile [bluePrintSourceCode] and put into cache */
- suspend fun compile(bluePrintSourceCode: BluePrintSourceCode) {
+ suspend fun compile(bluePrintSourceCode: BlueprintSourceCode) {
// TODO("Include Multiple folders")
val sourcePath = bluePrintSourceCode.blueprintKotlinSources.first()
val compiledJarFile = bluePrintSourceCode.targetJarFile
checkFileExists(compiledJarFile) { "couldn't generate compiled jar(${compiledJarFile.absolutePath})" }
}
else -> {
- throw BluePrintException("$exitCode :${messageCollector.errors().joinToString("\n")}")
+ throw BlueprintException("$exitCode :${messageCollector.errors().joinToString("\n")}")
}
}
}
/** create class [kClassName] instance from [classLoader] */
fun <T> instance(classLoader: URLClassLoader, kClassName: String, args: ArrayList<Any?>? = arrayListOf()): T {
val kClazz = classLoader.loadClass(kClassName)
- ?: throw BluePrintException("failed to load class($kClassName) from current class loader.")
+ ?: throw BlueprintException("failed to load class($kClassName) from current class loader.")
val instance = if (args.isNullOrEmpty()) {
kClazz.newInstance()
} else {
kClazz.constructors
.single().newInstance(*args.toArray())
- } ?: throw BluePrintException("failed to create class($kClassName) instance for constructor argument($args).")
+ } ?: throw BlueprintException("failed to create class($kClassName) instance for constructor argument($args).")
return instance as T
}
}
/** Compile source code information */
-open class BluePrintSourceCode : SourceCode {
+open class BlueprintSourceCode : SourceCode {
lateinit var blueprintKotlinSources: MutableList<String>
lateinit var moduleName: String