Skip to content

Include usvm via GitHub packages #2687

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,19 @@ commonsIOVersion=2.11.0
javaxVersion=2.2
jakartaVersion=3.1.0
jacoDbVersion=1.3.0
usvmVersion=1.0.0-competition

# use latest Java 8 compaitable Spring and Spring Boot versions
springVersion=5.3.28
springBootVersion=2.7.13
springSecurityVersion=5.8.5

# Put your GitHub username here to use utbot-junit-contest with usvm
githubActor=<github_actor>
# Use your GitHub token generated here -- https://github.com/settings/tokens/new?description=USVM&scopes=read:packages
# Keep `read:packages` checkbox selected
githubToken=<github token>

# configuration for build server
#
# the following options are passed to gradle command explicitly (see appropriate workflow):
Expand Down
3 changes: 0 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,3 @@ if (projectType == ultimateEdition) {
include("utbot-light")

//include("utbot-intellij-main")

// TODO usvm-sbft-merge: add if here if we want merge contest it into main
includeBuild("../usvm")
38 changes: 24 additions & 14 deletions utbot-analytics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,27 @@ processResources {
}
}

jar {
dependsOn classes
manifest {
attributes 'Main-Class': 'org.utbot.QualityAnalysisKt'
}

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

duplicatesStrategy = DuplicatesStrategy.EXCLUDE
zip64 = true
}
// TODO if you need utbot-analytics fat jar, use shadow jar to create a SEPARATE task for a fat jar.
// Do not use main jar for a fat jar, because it breaks Gradle conflict resolution, here's how:
// 1. utbot-analytics depends on library A version 1.0 (and adds it to own main jar)
// 2. utbot-junit-contest depends on utbot-analytics and library A version 1.1
// 3. Both library A version 1.0 and version 1.1 end up on the classpath and it's a matter of chance which one is earlier
// If utbot-analytics were to only declare its dependency on library A version 1.0 and not force it by adding it to a
// main jar, then Gradle would be able to recognize the conflict of library A version 1.0 and version 1.1 and resolve
// it according to a conflict resolution strategy, which by default picks the latest version, which works in most cases.
// But if you put library A version 1.0 into some fat jar, Gradle will no longer be able to exclude it from the fat jar
// in favor of a newer version when it needs to resolve dependency conflicts.
//jar {
// dependsOn classes
// manifest {
// attributes 'Main-Class': 'org.utbot.QualityAnalysisKt'
// }
//
// dependsOn configurations.runtimeClasspath
// from {
// configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
// }
//
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// zip64 = true
//}
87 changes: 82 additions & 5 deletions utbot-junit-contest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,29 @@ plugins {
}
apply plugin: 'jacoco'

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven {
url = uri('https://maven.pkg.github.com/UnitTestBot/usvm')
credentials {
username = project.githubActor // System.getenv("GITHUB_ACTOR")
password = project.githubToken // System.getenv("GITHUB_TOKEN")
}
}
}

configurations {
fetchInstrumentationJar
approximations
usvmApproximationsApi
usvmInstrumentationCollector
usvmInstrumentationRunner
}

def approximationsRepo = "com.github.UnitTestBot.java-stdlib-approximations"
def approximationsVersion = "53ceeb23ea"

compileJava {
options.compilerArgs << '-XDignore.symbol.file'
}
Expand Down Expand Up @@ -44,7 +63,10 @@ sourceSets {

test {
useJUnit()
jvmArgs =[
if (JavaVersion.current() < JavaVersion.VERSION_1_9) {
jvmArgs = []
} else {
jvmArgs = [
"--add-opens", "java.base/java.util.concurrent.atomic=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens", "java.base/java.util.concurrent=ALL-UNNAMED",
Expand Down Expand Up @@ -95,7 +117,8 @@ test {
"--add-opens", "java.base/jdk.internal.util.xml.impl=ALL-UNNAMED",
"--add-opens", "java.base/jdk.internal.vm=ALL-UNNAMED",
"--add-opens", "java.base/jdk.internal.vm.annotation=ALL-UNNAMED"
]
]
}
finalizedBy jacocoTestReport
}

Expand Down Expand Up @@ -136,16 +159,19 @@ dependencies {
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlinLoggingVersion
implementation group: 'org.jsoup', name: 'jsoup', version: '1.6.2'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1'
implementation group: 'com.google.guava', name: 'guava', version: guavaVersion
// need for tests
implementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
implementation group: 'org.mockito', name: 'mockito-inline', version: mockitoInlineVersion
implementation 'junit:junit:4.13.2'

implementation "org.burningwave:core:12.62.7"

implementation('org.usvm:usvm-core')
implementation('org.usvm:usvm-jvm')
implementation('org.usvm:usvm-jvm-instrumentation')
implementation group: "org.usvm", name: "usvm-core", version: usvmVersion
implementation group: "org.usvm", name: "usvm-jvm", version: usvmVersion
implementation group: "org.usvm", name: "usvm-jvm-api", version: usvmVersion
implementation group: "org.usvm", name: "usvm-jvm-instrumentation", version: usvmVersion
implementation group: "org.usvm", name: "usvm-jvm-instrumentation-collectors", version: usvmVersion

implementation group: "org.jacodb", name: "jacodb-core", version: jacoDbVersion
implementation group: "org.jacodb", name: "jacodb-analysis", version: jacoDbVersion
Expand All @@ -160,6 +186,12 @@ dependencies {
testImplementation files('src/main/resources/evosuite/evosuite-standalone-runtime-1.2.0.jar')

fetchInstrumentationJar project(path: ':utbot-instrumentation', configuration: 'instrumentationArchive')

approximations "$approximationsRepo:approximations:$approximationsVersion"
usvmApproximationsApi "org.usvm:usvm-jvm-api:$usvmVersion"
usvmInstrumentationCollector "org.usvm:usvm-jvm-instrumentation-collectors:$usvmVersion"
usvmInstrumentationRunner "org.usvm:usvm-jvm-instrumentation:$usvmVersion"
usvmInstrumentationRunner "org.usvm:usvm-jvm-instrumentation-collectors:$usvmVersion"
}

processResources {
Expand Down Expand Up @@ -214,3 +246,48 @@ task monitoringJar(type: Jar) {

duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

// TODO usvm-sbft-saloed: replace with runner from usvm (unavailable due to huge jar size)
task usvmInstrumentationRunnerJar(type: Jar) {
archiveBaseName = "usvm-instrumentation-runner"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
"Main-Class": "org.usvm.instrumentation.rd.InstrumentedProcessKt",
"Premain-Class": "org.usvm.instrumentation.agent.Agent",
"Can-Retransform-Classes": "true",
"Can-Redefine-Classes": "true"
)
}

from {
configurations.usvmInstrumentationRunner.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}

task run(type: JavaExec) {
mainClass.set("org.utbot.contest.ContestEstimatorKt")
classpath = sourceSets.main.runtimeClasspath
workingDir = project.rootProject.projectDir

def usvmApproximationJarPath = configurations.approximations.resolvedConfiguration.files.find()
def usvmApproximationApiJarPath = configurations.usvmApproximationsApi.resolvedConfiguration.files.find()
environment "usvm.jvm.api.jar.path", usvmApproximationApiJarPath.absolutePath
environment "usvm.jvm.approximations.jar.path", usvmApproximationJarPath.absolutePath

def usvmInstrumentationCollectorJarPath = configurations.usvmInstrumentationCollector.resolvedConfiguration.files.find()
environment "usvm-jvm-collectors-jar", usvmInstrumentationCollectorJarPath.absolutePath

dependsOn(usvmInstrumentationRunnerJar)
environment "usvm-jvm-instrumentation-jar", usvmInstrumentationRunnerJar.outputs.files.singleFile

// "JAVA_HOME" specifies Java path for instrumented process and JacoDB,
// while `System.getProperty('java.home')` is Java used by this process.
// We want both of them to be the same and we also need JDK (not JRE), since we use `javac` to compile tests.
def javaHome = System.getProperty('java.home')
def jreSuffix = "${File.separatorChar}jre"
if (javaHome.endsWith(jreSuffix)) javaHome = javaHome.dropRight(jreSuffix.length())
environment "JAVA_HOME", javaHome
}