diff --git a/.github/workflows/build-and-run-tests-from-branch.yml b/.github/workflows/build-and-run-tests-from-branch.yml index 7c2cdea3a0..67641da81f 100644 --- a/.github/workflows/build-and-run-tests-from-branch.yml +++ b/.github/workflows/build-and-run-tests-from-branch.yml @@ -135,7 +135,7 @@ jobs: - name: Run tests run: | - gradle --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx6g -Dkotlin.daemon.jvm.options=-Xmx4g :utbot-framework-test:test ${{ matrix.project.TESTS_TO_RUN }} + gradle -PprojectType=ExperimentalLanguages --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx6g -Dkotlin.daemon.jvm.options=-Xmx4g :utbot-framework-test:test ${{ matrix.project.TESTS_TO_RUN }} - name: Upload logs if: ${{ always() }} @@ -203,7 +203,7 @@ jobs: - name: Run tests run: | cd utbot-spring-test - gradle --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx6g -Dkotlin.daemon.jvm.options=-Xmx4g :utbot-spring-test:test + gradle -PprojectType=Spring --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx6g -Dkotlin.daemon.jvm.options=-Xmx4g :utbot-spring-test:test - name: Upload logs if: ${{ always() }} diff --git a/.github/workflows/publish-plugin-from-branch.yml b/.github/workflows/publish-plugin-from-branch.yml index 2b432556ea..26a19a4a55 100644 --- a/.github/workflows/publish-plugin-from-branch.yml +++ b/.github/workflows/publish-plugin-from-branch.yml @@ -45,9 +45,13 @@ jobs: matrix: configuration: - plugin_type: IC - extra_options: "-PideType=IC" + extra_options: "-PideType=IC -PprojectType=PureJava" - plugin_type: IU - extra_options: "-PideType=IU" + extra_options: "-PideType=IU -PprojectType=ExperimentalLanguages" + - plugin_type: IC-Spring + extra_options: "-PideType=IC -PprojectType=Spring" + - plugin_type: IU-Spring + extra_options: "-PideType=IU -PprojectType=Spring" runs-on: ubuntu-20.04 container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 steps: diff --git a/.github/workflows/run-chosen-tests-from-branch.yml b/.github/workflows/run-chosen-tests-from-branch.yml index 788f6187f4..e9029880fa 100644 --- a/.github/workflows/run-chosen-tests-from-branch.yml +++ b/.github/workflows/run-chosen-tests-from-branch.yml @@ -49,7 +49,7 @@ jobs: - name: Run chosen tests run: | - gradle :${{ github.event.inputs.project-name }}:test --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g --tests ${{ github.event.inputs.tests-bunch-name }} + gradle :${{ github.event.inputs.project-name }}:test -PprojectType=ExperimentalLanguages --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g --tests ${{ github.event.inputs.tests-bunch-name }} - name: Upload ${{ github.event.inputs.project-name }} tests report if tests have failed if: ${{ failure() }} diff --git a/gradle.properties b/gradle.properties index d92ad7cf52..603eb5e3b8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,17 @@ kotlin.code.style=official +#Project Type +# - PureJava: no additional features +# - ExperimentalLanguages: for Java + { Python, JavaScript, Go } +# - Spring: for Java + Spring +# - Ultimate: for all supported functionality +projectType=Ultimate + +pureJavaEdition=PureJava +languagesEdition=ExperimentalLanguages +springEdition=Spring +ultimateEdition=Ultimate + # IU, IC, PC, PY # IC for AndroidStudio ideType=IC diff --git a/settings.gradle.kts b/settings.gradle.kts index aa4bc94058..d901f2e15e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,9 @@ +val projectType: String by settings +val ultimateEdition: String by settings +val springEdition: String by settings +val languagesEdition: String by settings +val pureJavaEdition: String by settings + val ideType: String by settings val buildType: String by settings @@ -51,29 +57,35 @@ if (includeRiderInBuild.toBoolean()) { include("utbot-ui-commons") -if (pythonIde.split(",").contains(ideType)) { - include("utbot-python") - include("utbot-cli-python") - include("utbot-intellij-python") - include("utbot-python-parser") -} +include("utbot-spring-commons-api") +include("utbot-spring-commons") +include("utbot-spring-analyzer") + +if (projectType == languagesEdition || projectType == ultimateEdition) { + if (pythonIde.split(",").contains(ideType)) { + include("utbot-python") + include("utbot-cli-python") + include("utbot-intellij-python") + include("utbot-python-parser") + } -if (jsBuild == buildType || jsIde.split(",").contains(ideType)) { - include("utbot-js") - include("utbot-cli-js") - include("utbot-intellij-js") + if (jsBuild == buildType || jsIde.split(",").contains(ideType)) { + include("utbot-js") + include("utbot-cli-js") + include("utbot-intellij-js") + } + + if (goIde.split(",").contains(ideType)) { + include("utbot-go") + include("utbot-cli-go") + include("utbot-intellij-go") + } } -if (goIde.split(",").contains(ideType)) { - include("utbot-go") - include("utbot-cli-go") - include("utbot-intellij-go") +if (projectType == springEdition || projectType == ultimateEdition) { + include("utbot-spring-sample") + include("utbot-spring-test") } -include("utbot-spring-analyzer") -include("utbot-spring-commons") -include("utbot-spring-commons-api") -include("utbot-spring-sample") -include("utbot-spring-test") diff --git a/utbot-framework/build.gradle b/utbot-framework/build.gradle index 649a06b4ef..1d79027bb7 100644 --- a/utbot-framework/build.gradle +++ b/utbot-framework/build.gradle @@ -15,8 +15,6 @@ dependencies { api project(':utbot-framework-api') api project(':utbot-rd') - implementation project(':utbot-spring-commons-api') - implementation group: 'com.jetbrains.rd', name: 'rd-framework', version: rdVersion implementation group: 'com.jetbrains.rd', name: 'rd-core', version: rdVersion @@ -46,17 +44,23 @@ dependencies { implementation group: 'com.github.UnitTestBot.ksmt', name: 'ksmt-core', version: ksmtVersion implementation group: 'com.github.UnitTestBot.ksmt', name: 'ksmt-z3', version: ksmtVersion - implementation project(':utbot-spring-analyzer') - fetchSpringAnalyzerJar project(path: ':utbot-spring-analyzer', configuration: 'springAnalyzerJar') fetchInstrumentationJar project(path: ':utbot-instrumentation', configuration: 'instrumentationArchive') + + implementation project(':utbot-spring-commons-api') + implementation project(':utbot-spring-analyzer') + + if (projectType == springEdition || projectType==ultimateEdition) { + fetchSpringAnalyzerJar project(path: ':utbot-spring-analyzer', configuration: 'springAnalyzerJar') + } } processResources { - from(configurations.fetchSpringAnalyzerJar) { + from(configurations.fetchInstrumentationJar) { into "lib" } - from(configurations.fetchInstrumentationJar) { + + from(configurations.fetchSpringAnalyzerJar) { into "lib" } } diff --git a/utbot-instrumentation/build.gradle.kts b/utbot-instrumentation/build.gradle.kts index 1c839dd570..718aa6b29b 100644 --- a/utbot-instrumentation/build.gradle.kts +++ b/utbot-instrumentation/build.gradle.kts @@ -1,5 +1,11 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer +val projectType: String by rootProject +val ultimateEdition: String by rootProject +val springEdition: String by rootProject +val languagesEdition: String by rootProject +val pureJavaEdition: String by rootProject + val asmVersion: String by rootProject val kryoVersion: String by rootProject val kryoSerializersVersion: String by rootProject @@ -43,8 +49,6 @@ val fetchSpringCommonsJar: Configuration by configurations.creating { dependencies { implementation(project(":utbot-framework-api")) implementation(project(":utbot-rd")) - implementation(project(":utbot-spring-commons-api")) - implementation("org.ow2.asm:asm:$asmVersion") implementation("org.ow2.asm:asm-commons:$asmVersion") @@ -58,7 +62,10 @@ dependencies { implementation("org.mockito:mockito-core:$mockitoVersion") implementation("org.mockito:mockito-inline:$mockitoInlineVersion") - fetchSpringCommonsJar(project(":utbot-spring-commons", configuration = "springCommonsJar")) + implementation(project(":utbot-spring-commons-api")) + if (projectType == springEdition || projectType == ultimateEdition) { + fetchSpringCommonsJar(project(":utbot-spring-commons", configuration = "springCommonsJar")) + } } /** diff --git a/utbot-intellij/build.gradle.kts b/utbot-intellij/build.gradle.kts index d7b6525a2b..264a23a689 100644 --- a/utbot-intellij/build.gradle.kts +++ b/utbot-intellij/build.gradle.kts @@ -1,3 +1,9 @@ +val projectType: String by rootProject +val ultimateEdition: String by rootProject +val springEdition: String by rootProject +val languagesEdition: String by rootProject +val pureJavaEdition: String by rootProject + val intellijPluginVersion: String? by rootProject val kotlinLoggingVersion: String? by rootProject val apacheCommonsTextVersion: String? by rootProject @@ -37,6 +43,10 @@ intellij { "java" ) + val kotlinPlugins = mutableListOf( + "org.jetbrains.kotlin" + ) + androidStudioPath?.let { jvmPlugins += androidPlugins } val pythonCommunityPlugins = listOf( @@ -59,13 +69,19 @@ intellij { "org.jetbrains.idea.maven" ) + val basePluginSet = jvmPlugins + kotlinPlugins + mavenUtilsPlugins + androidPlugins + plugins.set( - when (ideType) { - "IC" -> jvmPlugins + pythonCommunityPlugins + androidPlugins + mavenUtilsPlugins - "IU" -> jvmPlugins + pythonUltimatePlugins + jsPlugins + goPlugins + androidPlugins + mavenUtilsPlugins - "PC" -> pythonCommunityPlugins - "PY" -> pythonUltimatePlugins // something else, JS? - else -> jvmPlugins + if (projectType == languagesEdition || projectType == ultimateEdition) { + when (ideType) { + "IC" -> basePluginSet + pythonCommunityPlugins + "IU" -> basePluginSet + pythonUltimatePlugins + jsPlugins + goPlugins + "PC" -> pythonCommunityPlugins + "PY" -> pythonUltimatePlugins // something else, JS? + else -> basePluginSet + } + } else { + basePluginSet } ) @@ -151,19 +167,21 @@ dependencies { implementation(project(":utbot-ui-commons")) //Family - if (pythonIde?.split(',')?.contains(ideType) == true) { - implementation(project(":utbot-python")) - implementation(project(":utbot-intellij-python")) - } + if (projectType == languagesEdition || projectType == ultimateEdition) { + if (pythonIde?.split(',')?.contains(ideType) == true) { + implementation(project(":utbot-python")) + implementation(project(":utbot-intellij-python")) + } - if (jsIde?.split(',')?.contains(ideType) == true) { - implementation(project(":utbot-js")) - implementation(project(":utbot-intellij-js")) - } + if (jsIde?.split(',')?.contains(ideType) == true) { + implementation(project(":utbot-js")) + implementation(project(":utbot-intellij-js")) + } - if (goIde?.split(',')?.contains(ideType) == true) { - implementation(project(":utbot-go")) - implementation(project(":utbot-intellij-go")) + if (goIde?.split(',')?.contains(ideType) == true) { + implementation(project(":utbot-go")) + implementation(project(":utbot-intellij-go")) + } } implementation(project(":utbot-android-studio")) diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt index 9e621d1fad..4234448588 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt @@ -367,8 +367,12 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m DependencyInjectionFramework.installedItems.forEach { it.testFrameworkInstalled = findDependencyInjectionTestLibrary(model.testModule, it) != null } + + val isUtBotSpringRuntimePresent = this::class.java.classLoader.getResource("lib/utbot-spring-analyzer-shadow.jar") != null + model.projectType = - if (DependencyInjectionFramework.installedItems.isNotEmpty()) ProjectType.Spring + // TODO show some warning, when we see Spring project, but don't have `utBotSpringRuntime` + if (isUtBotSpringRuntimePresent && DependencyInjectionFramework.installedItems.isNotEmpty()) ProjectType.Spring else ProjectType.PureJvm // Configure notification urls callbacks diff --git a/utbot-rd/build.gradle b/utbot-rd/build.gradle index 7f375a837e..da4497637c 100644 --- a/utbot-rd/build.gradle +++ b/utbot-rd/build.gradle @@ -257,31 +257,34 @@ task generateCommonModels(type: RdGenTask) { } } -task generateSpringModels(type: RdGenTask) { - def currentProjectDir = project.projectDir - def ideaPluginProjectDir = project.rootProject.childProjects["utbot-spring-analyzer"].projectDir - def generatedOutputDir = new File(ideaPluginProjectDir, "src/main/kotlin/org/utbot/spring/generated") - def hashDir = generatedOutputDir - def sourcesDir = new File(currentProjectDir, "src/main/rdgen/org/utbot/rd/models") - def rdParams = extensions.getByName("params") as RdGenExtension +if (projectType == springEdition || projectType == ultimateEdition) { + task generateSpringModels(type: RdGenTask) { + def currentProjectDir = project.projectDir + def ideaPluginProjectDir = project.rootProject.childProjects["utbot-spring-analyzer"].projectDir + def generatedOutputDir = new File(ideaPluginProjectDir, "src/main/kotlin/org/utbot/spring/generated") + def hashDir = generatedOutputDir + def sourcesDir = new File(currentProjectDir, "src/main/rdgen/org/utbot/rd/models") + def rdParams = extensions.getByName("params") as RdGenExtension - group = "rdgen" - rdParams.verbose = true - rdParams.sources(sourcesDir) - rdParams.hashFolder = hashDir.canonicalPath - // where to search roots - rdParams.packages = "org.utbot.rd.models" + group = "rdgen" + rdParams.verbose = true + rdParams.sources(sourcesDir) + rdParams.hashFolder = hashDir.canonicalPath + // where to search roots + rdParams.packages = "org.utbot.rd.models" - rdParams.generator { - language = "kotlin" - transform = "symmetric" - root = "org.utbot.rd.models.SpringAnalyzerRoot" + rdParams.generator { + language = "kotlin" + transform = "symmetric" + root = "org.utbot.rd.models.SpringAnalyzerRoot" - directory = generatedOutputDir.canonicalPath - namespace = "org.utbot.spring.generated" + directory = generatedOutputDir.canonicalPath + namespace = "org.utbot.spring.generated" + } } } + task generateCSharpModels(type: RdGenTask) { def currentProjectDir = project.projectDir def riderPluginProjectDir = project.rootProject.projectDir.toPath().resolve("utbot-rider").toFile()