Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3341c9f

Browse files
Fix non ability to find dependencies on test and mock frameworks in Fat JARcloses#34 (#40)
1 parentab2a63f commit3341c9f

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

‎utbot-cli/build.gradle‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ classes {
4444
jar {
4545
manifest {
4646
attributes'Main-Class':'org.utbot.cli.ApplicationKt'
47+
attributes'Bundle-SymbolicName':'org.utbot.cli'
48+
attributes'Bundle-Version':"${project.version}"
49+
attributes'Implementation-Title':'UtBot Java CLI'
50+
attributes'JAR-Type':'Fat JAR'
4751
}
4852

4953
version project.version

‎utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/DependencyUtils.kt‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ fun checkFrameworkDependencies(dependencyPaths: String?) {
2424
//TODO: JIRA:1659
2525
// check (somehow) that [UtExecutionInstrumentation] is in dependency path: in one of jars or folders
2626

27-
val dependencyNames= dependencyPaths
28-
.splitToSequence(File.pathSeparatorChar)
27+
val dependencyPathsSequence= dependencyPaths.splitToSequence(File.pathSeparatorChar)
28+
29+
val dependencyNames= dependencyPathsSequence
2930
.mapNotNull { findDependencyName(it) }
3031
.map { it.toLowerCase() }
3132
.toSet()
3233

3334
val testFrameworkPatterns=TestFramework.allItems.map { it.patterns() }
34-
val testFrameworkFound= dependencyNames.matchesAnyOf(testFrameworkPatterns)
35+
val testFrameworkFound= dependencyNames.matchesAnyOf(testFrameworkPatterns)||
36+
dependencyPathsSequence.any { checkDependencyIsFatJar(it) }
37+
3538
if (!testFrameworkFound) {
3639
error("""
3740
Test frameworks are not found in dependency path$dependencyPaths, dependency names are:
@@ -41,7 +44,9 @@ fun checkFrameworkDependencies(dependencyPaths: String?) {
4144
}
4245

4346
val mockFrameworkPatterns=MockFramework.allItems.map { it.patterns() }
44-
val mockFrameworkFound= dependencyNames.matchesAnyOf(mockFrameworkPatterns)
47+
val mockFrameworkFound= dependencyNames.matchesAnyOf(mockFrameworkPatterns)||
48+
dependencyPathsSequence.any { checkDependencyIsFatJar(it) }
49+
4550
if (!mockFrameworkFound) {
4651
error("""
4752
Mock frameworks are not found in dependency path$dependencyPaths, dependency names are:
@@ -75,4 +80,18 @@ private fun findDependencyName(jarPath: String): String? {
7580
}
7681

7782
returnnull
78-
}
83+
}
84+
85+
// We consider Fat JARs contain test frameworks and mock frameworks in the dependencies.
86+
privatefuncheckDependencyIsFatJar(jarPath:String):Boolean {
87+
try {
88+
val attributes=JarFile(jarPath).manifest.mainAttributes
89+
val jarType= attributes.getValue("JAR-Type")
90+
91+
return jarType=="Fat JAR"
92+
}catch (e:Exception) {
93+
logger.warn {"Unexpected error during parsing$jarPath manifest file$e" }
94+
}
95+
96+
returnfalse
97+
}

‎utbot-junit-contest/build.gradle‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ jar { dependsOn classes
7070

7171
manifest {
7272
attributes'Main-Class':'org.utbot.contest.ContestKt'
73+
attributes'Bundle-SymbolicName':'org.utbot.contest'
74+
attributes'Bundle-Version':"${project.version}"
75+
attributes'Implementation-Title':'UtBot JUnit contest'
76+
attributes'JAR-Type':'Fat JAR'
7377
}
7478

7579
version'1.0'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp