I'm configuring a TeamCity 2018.1 instance using Kotlin portable DSL. When I exported the DSL from the TeamCity web UI, my project structure looked like this:
<Root>
|- Project A
|- Project B
This gave me a file system structure that looked something like this:
.teamcity
|- _Self
|- project.kts
|- Project A
|- project.kts
|- Project B
|- project.kts
|- settings.kts
Currently, there are static references when loading subprojects, similar to this
import Project_A.*
// …
subProject(Project_A.Project)
subProject(Project_B.Project)
I want to modify the Root settings.kts file so that I could load projects dynamically. I'm trying this:
version = "2018.1"
project {
subProject {
id("Root")
name = "Root"
for(project in arrayListOf("Project_A.Project", "Project_B.Project")) {
val subProj = Class.forName("$project").getConstructor().newInstance() as Project
subProject(subProj)
}
}
}
However, this fails with:
_Root: java.net.URLClassLoader [381]:
java.lang.ClassNotFoundException: Project_A
Why does it fail?