diff --git a/utbot-cli/build.gradle b/utbot-cli/build.gradle index de3e078ae0..0f9d0bec4d 100644 --- a/utbot-cli/build.gradle +++ b/utbot-cli/build.gradle @@ -44,6 +44,10 @@ classes { jar { manifest { attributes 'Main-Class': 'org.utbot.cli.ApplicationKt' + attributes 'Bundle-SymbolicName': 'org.utbot.cli' + attributes 'Bundle-Version': "${project.version}" + attributes 'Implementation-Title': 'UtBot Java CLI' + attributes 'JAR-Type': 'Fat JAR' } version project.version diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/DependencyUtils.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/DependencyUtils.kt index 2407eb0fae..fcaff8be3e 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/DependencyUtils.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/DependencyUtils.kt @@ -24,14 +24,17 @@ fun checkFrameworkDependencies(dependencyPaths: String?) { //TODO: JIRA:1659 // check (somehow) that [UtExecutionInstrumentation] is in dependency path: in one of jars or folders - val dependencyNames = dependencyPaths - .splitToSequence(File.pathSeparatorChar) + val dependencyPathsSequence = dependencyPaths.splitToSequence(File.pathSeparatorChar) + + val dependencyNames = dependencyPathsSequence .mapNotNull { findDependencyName(it) } .map { it.toLowerCase() } .toSet() val testFrameworkPatterns = TestFramework.allItems.map { it.patterns() } - val testFrameworkFound = dependencyNames.matchesAnyOf(testFrameworkPatterns) + val testFrameworkFound = dependencyNames.matchesAnyOf(testFrameworkPatterns) || + dependencyPathsSequence.any { checkDependencyIsFatJar(it) } + if (!testFrameworkFound) { error(""" Test frameworks are not found in dependency path $dependencyPaths, dependency names are: @@ -41,7 +44,9 @@ fun checkFrameworkDependencies(dependencyPaths: String?) { } val mockFrameworkPatterns = MockFramework.allItems.map { it.patterns() } - val mockFrameworkFound = dependencyNames.matchesAnyOf(mockFrameworkPatterns) + val mockFrameworkFound = dependencyNames.matchesAnyOf(mockFrameworkPatterns) || + dependencyPathsSequence.any { checkDependencyIsFatJar(it) } + if (!mockFrameworkFound) { error(""" Mock frameworks are not found in dependency path $dependencyPaths, dependency names are: @@ -75,4 +80,18 @@ private fun findDependencyName(jarPath: String): String? { } return null -} \ No newline at end of file +} + +// We consider Fat JARs contain test frameworks and mock frameworks in the dependencies. +private fun checkDependencyIsFatJar(jarPath: String): Boolean { + try { + val attributes = JarFile(jarPath).manifest.mainAttributes + val jarType = attributes.getValue("JAR-Type") + + return jarType == "Fat JAR" + } catch (e: Exception) { + logger.warn { "Unexpected error during parsing $jarPath manifest file $e" } + } + + return false +} diff --git a/utbot-junit-contest/build.gradle b/utbot-junit-contest/build.gradle index 95cc9fd72d..eb766fab19 100644 --- a/utbot-junit-contest/build.gradle +++ b/utbot-junit-contest/build.gradle @@ -70,6 +70,10 @@ jar { dependsOn classes manifest { attributes 'Main-Class': 'org.utbot.contest.ContestKt' + attributes 'Bundle-SymbolicName': 'org.utbot.contest' + attributes 'Bundle-Version': "${project.version}" + attributes 'Implementation-Title': 'UtBot JUnit contest' + attributes 'JAR-Type': 'Fat JAR' } version '1.0'