1
+ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
1
2
import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer
2
3
import com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer
3
4
@@ -18,38 +19,62 @@ java {
18
19
targetCompatibility = JavaVersion .VERSION_1_8
19
20
}
20
21
21
- val shadowConfiguration by configurations.creating {}
22
+ val withoutSpringConfiguration by configurations.creating {}
23
+ val withSpringConfiguration by configurations.creating {
24
+ extendsFrom(withoutSpringConfiguration)
25
+ }
26
+ configurations.implementation.get().extendsFrom(withSpringConfiguration)
22
27
23
28
dependencies {
24
- fun shadowAndImplementation (dependencyNotation : Any ) {
25
- shadowConfiguration(dependencyNotation)
26
- implementation(dependencyNotation)
27
- }
28
-
29
29
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot
30
- implementation (" org.springframework.boot:spring-boot:$springBootVersion " )
30
+ withSpringConfiguration (" org.springframework.boot:spring-boot:$springBootVersion " )
31
31
32
32
implementation(" io.github.microutils:kotlin-logging:$kotlinLoggingVersion " )
33
33
34
- shadowAndImplementation(project(" :utbot-rd" ))
35
- shadowAndImplementation(project(" :utbot-core" ))
36
- shadowAndImplementation(project(" :utbot-framework-api" ))
37
- shadowAndImplementation(" com.jetbrains.rd:rd-framework:$rdVersion " )
38
- shadowAndImplementation(" com.jetbrains.rd:rd-core:$rdVersion " )
39
- shadowAndImplementation(" commons-logging:commons-logging:$commonsLoggingVersion " )
40
- shadowAndImplementation(" commons-io:commons-io:$commonsIOVersion " )
41
- }
34
+ fun ModuleDependency.excludeSlf4jApi () = exclude(group = " org.slf4j" , module = " slf4j-api" )
42
35
43
- shadowConfiguration.exclude(group = " org.slf4j" , module = " slf4j-api" )
36
+ withoutSpringConfiguration(project(" :utbot-rd" )) { excludeSlf4jApi() }
37
+ withoutSpringConfiguration(project(" :utbot-core" )) { excludeSlf4jApi() }
38
+ withoutSpringConfiguration(project(" :utbot-framework-api" )) { excludeSlf4jApi() }
39
+ withoutSpringConfiguration(" com.jetbrains.rd:rd-framework:$rdVersion " ) { excludeSlf4jApi() }
40
+ withoutSpringConfiguration(" com.jetbrains.rd:rd-core:$rdVersion " ) { excludeSlf4jApi() }
41
+ withoutSpringConfiguration(" commons-logging:commons-logging:$commonsLoggingVersion " ) { excludeSlf4jApi() }
42
+ withoutSpringConfiguration(" commons-io:commons-io:$commonsIOVersion " ) { excludeSlf4jApi() }
43
+ }
44
44
45
45
application {
46
46
mainClass.set(" org.utbot.spring.process.SpringAnalyzerProcessMainKt" )
47
47
}
48
48
49
- // see more details about this task -- https://github.com/spring-projects/spring-boot/issues/1828
50
- tasks.shadowJar {
51
- this @shadowJar.configurations = listOf (shadowConfiguration)
49
+ val shadowWithoutSpring by tasks.register<ShadowJar >(" shadowJarWithoutSpring" ) {
50
+ configureShadowJar(withoutSpringConfiguration)
51
+ archiveFileName.set(" utbot-spring-analyzer-shadow.jar" )
52
+ }
53
+
54
+ val shadowWithSpring by tasks.register<ShadowJar >(" shadowJarWithSpring" ) {
55
+ configureShadowJar(withSpringConfiguration)
56
+ archiveFileName.set(" utbot-spring-analyzer-with-spring-shadow.jar" )
57
+ }
52
58
59
+ val springAnalyzerJar: Configuration by configurations.creating {
60
+ isCanBeResolved = false
61
+ isCanBeConsumed = true
62
+ }
63
+
64
+ artifacts {
65
+ add(springAnalyzerJar.name, shadowWithoutSpring)
66
+ add(springAnalyzerJar.name, shadowWithSpring)
67
+ }
68
+
69
+ fun ShadowJar.configureShadowJar (configuration : Configuration ) {
70
+ // see more details -- https://github.com/johnrengelman/shadow/blob/master/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.groovy
71
+ group = " shadow"
72
+ from(sourceSets.main.get().output)
73
+ exclude(" META-INF/INDEX.LIST" , " META-INF/*.SF" , " META-INF/*.DSA" , " META-INF/*.RSA" , " module-info.class" )
74
+
75
+ configurations = listOf (configuration)
76
+
77
+ // see more details -- https://github.com/spring-projects/spring-boot/issues/1828
53
78
isZip64 = true
54
79
// Required for Spring
55
80
mergeServiceFiles()
@@ -62,14 +87,4 @@ tasks.shadowJar {
62
87
})
63
88
64
89
transform(Log4j2PluginsCacheFileTransformer ::class .java)
65
- archiveFileName.set(" utbot-spring-analyzer-shadow.jar" )
66
- }
67
-
68
- val springAnalyzerJar: Configuration by configurations.creating {
69
- isCanBeResolved = false
70
- isCanBeConsumed = true
71
- }
72
-
73
- artifacts {
74
- add(springAnalyzerJar.name, tasks.shadowJar)
75
90
}
0 commit comments