Skip to content

Commit 2a73f74

Browse files
committed
Java 11 migration
1 parent f8e75b7 commit 2a73f74

File tree

37 files changed

+333
-270
lines changed

37 files changed

+333
-270
lines changed

.github/workflows/build-and-run-tests-from-branch.yml

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,55 @@ name: "[M] UTBot Java: build and run tests"
22

33
on:
44
workflow_dispatch
5-
5+
66
jobs:
77
build-and-run-tests:
88
runs-on: ubuntu-20.04
9+
# container: unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc-1.7.0
10+
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
911
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-java@v2
12-
with:
13-
java-version: '8'
14-
distribution: 'zulu'
15-
java-package: jdk+fx
16-
cache: gradle
17-
- uses: gradle/gradle-build-action@v2
18-
with:
19-
gradle-version: 6.8
20-
21-
- name: Build and run tests in UTBot Java
22-
run: |
23-
export KOTLIN_HOME="/usr"
24-
gradle clean build --no-daemon
25-
26-
- name: Upload utbot-framework logs
27-
if: ${{ always() }}
28-
uses: actions/upload-artifact@v2
29-
with:
30-
name: utbot_framework_logs
31-
path: utbot-framework/logs/*
32-
33-
- name: Upload utbot-framework tests report artifacts if tests have failed
34-
if: ${{ failure() }}
35-
uses: actions/upload-artifact@v2
36-
with:
37-
name: utbot_framework_tests_report
38-
path: utbot-framework/build/reports/tests/test/*
39-
40-
- name: Upload utbot-intellij tests report artifacts if tests have failed
41-
if: ${{ failure() }}
42-
uses: actions/upload-artifact@v2
43-
with:
44-
name: utbot_intellij_tests_report
45-
path: utbot-intellij/build/reports/tests/test/*
12+
- uses: actions/checkout@v2
13+
14+
- name: Build and run tests in UTBot Java
15+
run: |
16+
gradle clean build --no-daemon --stacktrace --scan
17+
18+
- name: Upload utbot-framework logs
19+
if: ${{ always() }}
20+
uses: actions/upload-artifact@v2
21+
with:
22+
name: utbot_framework_logs
23+
path: utbot-framework/logs/*
24+
25+
- name: Upload utbot-framework tests report artifacts if tests have failed
26+
if: ${{ failure() }}
27+
uses: actions/upload-artifact@v2
28+
with:
29+
name: utbot_framework_tests_report
30+
path: utbot-framework/build/reports/tests/test/*
31+
32+
- name: Upload utbot-instrumentation tests report artifacts if tests have failed
33+
if: ${{ failure() }}
34+
uses: actions/upload-artifact@v2
35+
with:
36+
name: utbot_instrumentation_tests_report
37+
path: utbot-instrumentation/build/reports/tests/test/*
38+
39+
- name: Upload utbot-intellij tests report artifacts if tests have failed
40+
if: ${{ failure() }}
41+
uses: actions/upload-artifact@v2
42+
with:
43+
name: utbot_intellij_tests_report
44+
path: utbot-intellij/build/reports/tests/test/*
45+
46+
- name: Setup tmate session
47+
if: ${{ always() }}
48+
uses: mxschmitt/action-tmate@v3
49+
with:
50+
sudo: false
51+
52+
- name: Grant execute permission for gradlew
53+
run: chmod +x gradlew
54+
55+
- name: Build with Gradle
56+
run: ./gradlew build

build.gradle

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
group 'org.utbot'
22

3-
apply plugin: 'java'
3+
apply plugin: 'java-library'
44

55
if (project.hasProperty('semVer')) {
66
project.version = project.semVer
77
} else {
88
project.version = '1.0-SNAPSHOT'
99
}
1010

11+
//noinspection GroovyAssignabilityCheck
1112
buildscript {
13+
//noinspection GroovyAssignabilityCheck
1214
repositories {
1315
mavenCentral()
1416
}
@@ -24,11 +26,12 @@ subprojects {
2426
version = rootProject.version
2527

2628
apply plugin: 'base'
27-
apply plugin: 'java'
29+
apply plugin: 'java-library'
2830
apply plugin: 'maven-publish'
2931

3032
publishing {
3133
publications {
34+
//noinspection GroovyAssignabilityCheck
3235
jar(MavenPublication) {
3336
from components.java
3437
groupId 'org.utbot'
@@ -37,22 +40,24 @@ subprojects {
3740
}
3841
}
3942

43+
//noinspection GroovyAssignabilityCheck
4044
repositories {
4145
mavenCentral()
4246
maven { url 'https://jitpack.io' }
4347
}
4448
}
4549

4650
configure([
47-
project(':utbot-api'),
48-
project(':utbot-core'),
49-
project(':utbot-framework'),
50-
project(':utbot-framework-api'),
51-
project(':utbot-fuzzers'),
52-
project(':utbot-instrumentation'),
53-
project(':utbot-summary')
51+
project(':utbot-api'),
52+
project(':utbot-core'),
53+
project(':utbot-framework'),
54+
project(':utbot-framework-api'),
55+
project(':utbot-fuzzers'),
56+
project(':utbot-instrumentation'),
57+
project(':utbot-summary')
5458
]) {
5559
publishing {
60+
//noinspection GroovyAssignabilityCheck
5661
repositories {
5762
maven {
5863
name = "GitHubPackages"

gradle.properties

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
kotlin.code.style=official
2+
23
org.gradle.caching=false
34
junit5_version=5.8.0-RC1
45
junit4_version=4.4
56
junit4_platform_version=1.7.1
67
mockito_version=3.5.13
78
z3_version=4.8.9.1
89
z3_java_api_version=4.8.9
9-
soot_commit_hash=13be158
10-
kotlin_version=1.4.20
10+
soot_commit_hash=c6c78d9
11+
kotlin_version=1.7.10
1112
log4j2_version=2.13.3
12-
coroutines_version=1.4.1
13+
coroutines_version=1.6.3
1314
collections_version=0.3.4
14-
intellij_plugin_version=0.6.4
15-
jacoco_version=0.8.5
15+
intellij_plugin_version=1.7.0
16+
jacoco_version=0.8.8
1617
commons_lang_version=3.11
18+
commons_io_version=2.8.0
1719
kotlin_logging_version=1.8.3
1820
ktor_version=1.4.1
1921
clikt_version=3.2.0
@@ -22,9 +24,9 @@ apache_commons_exec_version=1.2
2224
rgxgen_version=1.3
2325
apache_commons_text_version=1.9
2426
antlr_version=4.9.2
25-
kryo_version=5.1.1
27+
kryo_version=5.3.0
2628
kryo_serializers_version=0.45
27-
asm_version=8.0.1
29+
asm_version=9.2
2830
testng_version=7.4.0
2931
mockito_inline_version=4.0.0
3032
jackson_version = 2.12.3
@@ -43,4 +45,6 @@ djl_api_version=0.17.0
4345
pytorch_native_version=1.9.1
4446
# soot also depends on asm, so there could be two different versions
4547

46-
kotlin.stdlib.default.dependency=false
48+
kotlin.stdlib.default.dependency=false
49+
50+
org.gradle.jvmargs=-Xmx6144m

gradle/include/jvm-project.gradle

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,32 @@ dependencies {
77
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: kotlin_version
88
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version
99

10-
testImplementation("org.junit.jupiter:junit-jupiter:$junit5_version"){
11-
force = true
10+
testImplementation("org.junit.jupiter:junit-jupiter"){
11+
version {
12+
strictly junit5_version
13+
}
1214
}
1315
}
1416

1517
compileKotlin {
1618
kotlinOptions {
17-
jvmTarget = JavaVersion.VERSION_1_8
18-
freeCompilerArgs += ["-Xallow-result-return-type", "-Xinline-classes"]
19+
jvmTarget = JavaVersion.VERSION_11
20+
freeCompilerArgs += ["-Xallow-result-return-type", "-Xsam-conversions=class"]
1921
allWarningsAsErrors = false
2022
}
2123
}
2224

2325
compileTestKotlin {
2426
kotlinOptions {
25-
jvmTarget = JavaVersion.VERSION_1_8
26-
freeCompilerArgs += ["-Xallow-result-return-type", "-Xinline-classes"]
27+
jvmTarget = JavaVersion.VERSION_11
28+
freeCompilerArgs += ["-Xallow-result-return-type", "-Xsam-conversions=class"]
2729
allWarningsAsErrors = false
2830
}
2931
}
3032

3133
java {
32-
sourceCompatibility = JavaVersion.VERSION_1_8
33-
targetCompatibility = JavaVersion.VERSION_1_8
34+
sourceCompatibility = JavaVersion.VERSION_11
35+
targetCompatibility = JavaVersion.VERSION_11
3436
}
3537

3638
compileJava {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ include 'utbot-instrumentation-tests'
1515

1616
include 'utbot-summary'
1717
include 'utbot-gradle'
18-
include 'utbot-maven'
18+
//include 'utbot-maven'
1919
include 'utbot-summary-tests'
2020

utbot-analytics/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ if (osName == "mac") osName = "macosx"
99
String classifier = osName + "-x86_64"
1010

1111
evaluationDependsOn(':utbot-framework')
12+
compileKotlin.dependsOn project(':utbot-instrumentation').tasks.jar
1213
compileTestJava.dependsOn tasks.getByPath(':utbot-framework:testClasses')
1314

1415
dependencies {
16+
implementation(project(":utbot-api"))
17+
implementation(project(":utbot-core"))
18+
implementation(project(":utbot-summary"))
19+
implementation(project(":utbot-framework-api"))
20+
implementation(project(":utbot-fuzzers"))
21+
implementation(project(":utbot-instrumentation"))
1522
implementation(project(":utbot-framework"))
16-
compile(project(':utbot-instrumentation'))
17-
implementation(project(':utbot-summary'))
1823
testImplementation project(':utbot-sample')
1924
testImplementation group: 'junit', name: 'junit', version: junit4_version
2025

@@ -43,7 +48,7 @@ dependencies {
4348
implementation "ai.djl.pytorch:pytorch-engine:$djl_api_version"
4449
implementation "ai.djl.pytorch:pytorch-native-auto:$pytorch_native_version"
4550

46-
testCompile project(':utbot-framework').sourceSets.test.output
51+
testImplementation project(':utbot-framework').sourceSets.test.output
4752
}
4853

4954
test {

utbot-cli/build.gradle

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
apply from: "${parent.projectDir}/gradle/include/jvm-project.gradle"
22

3+
//noinspection GroovyAssignabilityCheck
34
configurations {
45
fetchInstrumentationJar
56
}
67

78
compileKotlin {
9+
dependsOn project(':utbot-instrumentation').tasks.jar
810
kotlinOptions {
911
allWarningsAsErrors = false
1012
}
1113
}
1214

1315
dependencies {
14-
api project(":utbot-framework")
16+
api project(':utbot-framework-api')
17+
implementation project(':utbot-framework')
1518
api project(':utbot-summary')
1619

1720
implementation group: 'org.mockito', name: 'mockito-core', version: mockito_version
@@ -24,9 +27,10 @@ dependencies {
2427
implementation group: 'com.github.ajalt.clikt', name: 'clikt', version: clikt_version
2528
implementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: junit5_version
2629
implementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junit5_version
27-
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4j2_version
28-
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4j2_version
30+
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4j2_version
31+
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4j2_version
2932
implementation group: 'org.jacoco', name: 'org.jacoco.report', version: jacoco_version
33+
//noinspection GroovyAssignabilityCheck
3034
fetchInstrumentationJar project(path: ':utbot-instrumentation', configuration:'instrumentationArchive')
3135
}
3236

@@ -40,6 +44,7 @@ task createProperties(dependsOn: processResources) {
4044
doLast {
4145
new File("$buildDir/resources/main/version.properties").withWriter { w ->
4246
Properties properties = new Properties()
47+
//noinspection GroovyAssignabilityCheck
4348
properties['version'] = project.version.toString()
4449
properties.store w, null
4550
}
@@ -59,7 +64,7 @@ jar {
5964
attributes 'JAR-Type': 'Fat JAR'
6065
}
6166

62-
version project.version
67+
archiveVersion.set(project.version as String)
6368

6469
from {
6570
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/util/IdUtil.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import org.utbot.framework.plugin.api.MethodId
1111
import org.utbot.framework.plugin.api.UtModel
1212
import org.utbot.framework.plugin.api.UtNullModel
1313
import org.utbot.framework.plugin.api.UtPrimitiveModel
14-
import java.lang.reflect.Constructor
15-
import java.lang.reflect.Executable
16-
import java.lang.reflect.Field
17-
import java.lang.reflect.Method
14+
import java.lang.reflect.*
1815
import java.util.concurrent.atomic.AtomicInteger
1916
import kotlin.contracts.ExperimentalContracts
2017
import kotlin.contracts.contract
@@ -262,6 +259,13 @@ val Class<*>.id: ClassId
262259
else -> ClassId(name)
263260
}
264261

262+
val Type.id: ClassId
263+
get() = when {
264+
javaClass.isArray -> ClassId(javaClass.name)
265+
javaClass.isPrimitive -> primitiveToId[this]!!
266+
else -> ClassId(javaClass.name)
267+
}
268+
265269
val KClass<*>.id: ClassId
266270
get() = java.id
267271

0 commit comments

Comments
 (0)