Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to create separate artifacts for Spring and Experimental languages #2423

Merged
merged 10 commits into from
Jul 24, 2023
4 changes: 2 additions & 2 deletions .github/workflows/build-and-run-tests-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down Expand Up @@ -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() }}
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/publish-plugin-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-chosen-tests-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down
12 changes: 12 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
50 changes: 31 additions & 19 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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")

16 changes: 10 additions & 6 deletions utbot-framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
}
}
13 changes: 10 additions & 3 deletions utbot-instrumentation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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"))
}
}

/**
Expand Down
52 changes: 35 additions & 17 deletions utbot-intellij/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -37,6 +43,10 @@ intellij {
"java"
)

val kotlinPlugins = mutableListOf(
"org.jetbrains.kotlin"
)

androidStudioPath?.let { jvmPlugins += androidPlugins }

val pythonCommunityPlugins = listOf(
Expand All @@ -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
}
)

Expand Down Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 22 additions & 19 deletions utbot-rd/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down