-
Notifications
You must be signed in to change notification settings - Fork 46
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
Example Gradle Project #224
Comments
Thank you for your interest in JavaSMT. |
Gradle searches for a pom.xml per default and it fails because some of our artifacts don't have any (or no useful ones).
|
I've added a Gradle example project that includes Z3. |
I left comments on f2b6c1d, mainly because the example project in its current form is incompatible with the most recent release of Gradle. |
Off Topic: Congratulations on acceptance of your paper at CAV2021! In fact, my interest in JavaSMT is motivated by the development of ATLAS, which is covered in another CAV2021 paper! |
Thank you very much! The incompatibilities should be fixed now. If you find anything else please feel free to comment again! Would you say that the Gradle example is helpful for your work, or would a more advanced example be more helpful? |
Is there anything left to do? Otherwise we could merge this and apply potential fixes later. |
From my point of view we can merge it. |
I have updated the Gradle example project some more:
@kfriedberger I've added a comment explaining how to run the project only with Yices2. Does this suffice or do i need to create another project just for Yices2? |
I've added tests for Boolector and Yices2. Now all available solvers get tested when building the project. However, since parts of the tests rely on our examples, and in the current release of JavaSMT some of the needed methods are private, we need to make a small release or disable the tests. The rest of the Gradle example is done and can be reviewed and merged. |
I have encountered a number of issues configuring this project with Gradle. First, it seems like there are two outdated artifacts on Maven Central. For Z3, when I copy the default snippet for the Gradle Kotlin DSL into my build script as follows:
This produces the error:
I have tried different variations, including:
In particular, configuring the
Has anyone been successful in configuring the third-party SMT solvers with Gradle? It would be helpful to provide a version of the Getting Started Guide for the Gradle Kotlin DSL. |
@breandan, I think you you need to swap the version number with what comes after.
I managed to get it to work in another project.
Definitely. |
@lorenzleutgeb should be right. Please try to use version |
Thank you for your replies. I tried both
Unfortunately, both versions returned the following error:
I have pasted below the output from running
Please let me know if you need any further information to diagnose. edit: It just occurs to me that since I am running |
You can use a natively-installed version of Z3.
|
@kfriedberger Thanks, I appreciate the info. However, I would prefer to avoid interacting with native libraries and all the FFI stuff. Shouldn't there be a way to bypass all of that and generate SMT-LIB 2.0 syntax directly, without needing any extra JARs? I just want to output the constraints to a file, feed it to Z3 via |
JavaSMT does not provide a way to use process- or pipe-based interaction with SMT solvers (which seems to be your intent), but only provides interaction via native APIs. This was a design-decision that comes from the early times of JavaSMT and it has several benefits, for example, control over the SMT solver in terms of runtime, cancelation, and resource limits. In general, dumping and reading single SMTLIB-formatted queries (ASSERT only, no PUSH or POP) is already supported for most included SMT solvers. A user can dump SMTLIB from one SMT solver (e.g. SMTInterpol) and read the String into another SMT solver like Z3. However, to use JavaSMT in the way you have described, the user needs to implement the process-based interaction on his own. Also note, that there can be minor variations in the SMT solvers' implementation of the SMTLIB standard. |
@breandan i am running arch64 as well, that should not be a problem. Did you change anything besides the dependency versions? I'm gonna take a closer look. |
I can't recreate your problem despite being on Arch64 myself and having the same Gradle version as you @breandan. I've even tried including the imports as described by @lorenzleutgeb and couldn't find a problem (btw. you have 1 import twice ;D). Did you try other solvers besides Z3? |
@baierd Thank you for investigating. I am not sure what the issue is, but it seems like Gradle does not like the POM format? Here is the result from running |
@breandan could you try replacing the dot in If that does not help, could you copy & paste your |
As advised, I tried replacing the
This still produces the same error:
Here is the
If you want to create a sample project containing a |
Ah i think i know whats causing the problem. Please try using the following repository options:
This way it looks for a useable POM first and if it can't find any (your error) it simply uses the artifact that the dependency points to. |
After updating the
I have |
Now try version |
I'm facing the same problem as breandan:
But I can see these files in
build.gradle.kts: repositories {
mavenCentral {
metadataSources {
mavenPom()
}
}
mavenCentral {
metadataSources {
artifact()
}
}
}
dependencies {
implementation("org.sosy-lab:java-smt:3.12.0")
runtimeOnly("org.sosy-lab:javasmt-solver-z3:4.8.10:com.microsoft.z3@jar")
runtimeOnly("org.sosy-lab:javasmt-solver-z3:4.8.10:libz3@so")
runtimeOnly("org.sosy-lab:javasmt-solver-z3:4.8.10:libz3java@so")
implementation(files("build/dependencies/*.jar"))
}
configurations {
register("javaSMTConfig").configure {
extendsFrom(runtimeOnly.get())
}
}
tasks.register<Copy>("copyDependencies") {
dependsOn("cleanDownloadedDependencies")
from(configurations["javaSMTConfig"])
into("build/dependencies")
rename(".*(lib[^-]*)-?.*.so", "\$1.so")
}
tasks.register<Delete>("cleanDownloadedDependencies") {
delete(file("build/dependencies"))
}
tasks.compileKotlin {
dependsOn("copyDependencies")
}
tasks.clean {
dependsOn("cleanDownloadedDependencies")
} Edit: Found the issue. This script now works by replacing configurations {
register("javaSMTConfig").configure {
extendsFrom(runtimeOnly.get())
}
} with configurations {
register("javaSMTConfig").configure {
dependencies.addAll(runtimeOnly.get().dependencies.filter { it.group == "org.sosy-lab" })
dependencies.addAll(implementation.get().dependencies.filter { it.group == "org.sosy-lab" })
}
} and replacing implementation(files("build/dependencies/*.jar")) with implementation(fileTree("dir" to "build/dependencies", "include" to "*.jar")) Maybe it is worth considering adding an example of a kotlin build script to the |
@breandan all versions up to and including @d-costa thank you for your input! I'll update the Gradle example project with your solutions! |
@d-costa i've added a Kotlin example similar to the existing Gradle example. Could you take a look/try it out and report back? Its located parallel to the existing example in doc/Example-Gradle-Project-Kotlin |
Thank you very much for that! @d-costa no there is no real reason. I tried different options and that stuck. Would it be more in line with Kotlin to use |
I am trying to use JavaSMT within a project that is built with Gradle, and am having difficulties, especially with the Z3 dependencies. I already posted a question on StackOverflow, and would be very glad if you could help me out.
However, independently from my project, I think it would be beneficial to add an example setup using Gradle to JavaSMT.
The text was updated successfully, but these errors were encountered: