Skip to content

Commit c47aaba

Browse files
committed
Exclude org.slf4j from spring analyzer jar and add TODOs
1 parent 0c1a5a3 commit c47aaba

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

utbot-spring-analyzer/build.gradle.kts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,40 @@ java {
1818
targetCompatibility = JavaVersion.VERSION_1_8
1919
}
2020

21+
val shadowConfiguration by configurations.creating {}
22+
2123
dependencies {
24+
fun shadowAndImplementation(dependencyNotation: Any) {
25+
shadowConfiguration(dependencyNotation)
26+
implementation(dependencyNotation)
27+
}
28+
29+
// TODO: use regular `implementation` configuration for `spring-boot`
30+
// and maybe for `commons-io`, they will be taken from user's classpath
2231
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot
23-
implementation("org.springframework.boot:spring-boot:$springBootVersion")
24-
25-
implementation(project(":utbot-rd"))
26-
implementation(project(":utbot-core"))
27-
implementation(project(":utbot-framework-api"))
28-
implementation("com.jetbrains.rd:rd-framework:$rdVersion")
29-
implementation("com.jetbrains.rd:rd-core:$rdVersion")
30-
implementation("commons-logging:commons-logging:$commonsLoggingVersion")
32+
shadowAndImplementation("org.springframework.boot:spring-boot:$springBootVersion")
33+
3134
implementation("io.github.microutils:kotlin-logging:$kotlinLoggingVersion")
32-
implementation("commons-io:commons-io:$commonsIOVersion")
35+
36+
shadowAndImplementation(project(":utbot-rd"))
37+
shadowAndImplementation(project(":utbot-core"))
38+
shadowAndImplementation(project(":utbot-framework-api"))
39+
shadowAndImplementation("com.jetbrains.rd:rd-framework:$rdVersion")
40+
shadowAndImplementation("com.jetbrains.rd:rd-core:$rdVersion")
41+
shadowAndImplementation("commons-logging:commons-logging:$commonsLoggingVersion")
42+
shadowAndImplementation("commons-io:commons-io:$commonsIOVersion")
3343
}
3444

45+
shadowConfiguration.exclude(group = "org.slf4j", module = "slf4j-api")
46+
3547
application {
3648
mainClass.set("org.utbot.spring.process.SpringAnalyzerProcessMainKt")
3749
}
3850

3951
// see more details about this task -- https://github.com/spring-projects/spring-boot/issues/1828
4052
tasks.shadowJar {
53+
this@shadowJar.configurations = listOf(shadowConfiguration)
54+
4155
isZip64 = true
4256
// Required for Spring
4357
mergeServiceFiles()

utbot-spring-analyzer/src/main/kotlin/org/utbot/spring/postProcessors/UtBotBeanFactoryPostProcessor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ object UtBotBeanFactoryPostProcessor : BeanFactoryPostProcessor, PriorityOrdered
2424
override fun postProcessBeanFactory(beanFactory: ConfigurableListableBeanFactory) {
2525
logger.info { "Started post-processing bean factory in UtBot" }
2626

27-
val beanClassNames = findBeanClassNames(beanFactory)
28-
beanQualifiedNames = beanClassNames.distinct()
29-
println("Bean Qualified Names: " + beanQualifiedNames)
27+
beanQualifiedNames = findBeanClassNames(beanFactory)
28+
logger.info { "Detected Beans: $beanQualifiedNames" }
3029

3130
// After desired post-processing is completed we destroy bean definitions
3231
// to avoid further possible actions with beans that may be unsafe.
@@ -44,6 +43,7 @@ object UtBotBeanFactoryPostProcessor : BeanFactoryPostProcessor, PriorityOrdered
4443
null
4544
}
4645
}.filterNot { it.startsWith("org.utbot.spring") || it.contains("\$\$") }
46+
.distinct()
4747
}
4848

4949
private fun destroyBeanDefinitions(beanFactory: ConfigurableListableBeanFactory) {

utbot-spring-analyzer/src/main/kotlin/org/utbot/spring/process/SpringAnalyzerProcess.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class SpringAnalyzerProcess private constructor(
7474
suspend operator fun invoke(classpathItems: List<String>): SpringAnalyzerProcess = LifetimeDefinition().terminateOnException { lifetime ->
7575
val extendedClasspath = listOf(springAnalyzerJarFile.path) + classpathItems
7676
val rdProcess = startUtProcessWithRdServer(lifetime) { port ->
77+
// TODO put right version of the Spring Boot jar on the
78+
// classpath if user uses Spring without Spring Boot
7779
classpathArgs = listOf(
7880
"-cp",
7981
"\"${extendedClasspath.joinToString(File.pathSeparator)}\"",

0 commit comments

Comments
 (0)