Skip to content
Draft
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
23 changes: 23 additions & 0 deletions doc/Example-Ivy-Project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
This file is part of JavaSMT,
an API wrapper for a collection of SMT solvers:
https://github.com/sosy-lab/java-smt

SPDX-FileCopyrightText: 2025 Dirk Beyer <https://www.sosy-lab.org>

SPDX-License-Identifier: Apache-2.0
-->

This is an example application for using JavaSMT with Ant/Ivy.
The example application prints a table of the available SMT solvers, along with their version
number.

The project supports the following build steps:

- `resolve` retrieve dependencies with Ivy
- `compile` compile the project
- `package` build a .jar
- `run` run the program
- `clean` clean the project

Calling `ant` with no target will build and then execute the project.
122 changes: 122 additions & 0 deletions doc/Example-Ivy-Project/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<!--
This file is part of JavaSMT,
an API wrapper for a collection of SMT solvers:
https://github.com/sosy-lab/java-smt

SPDX-FileCopyrightText: 2025 Dirk Beyer <https://www.sosy-lab.org>

SPDX-License-Identifier: Apache-2.0
-->

<project xmlns:ivy="antlib:org.apache.ivy.ant" name="javasmt-ivy-example" default="run">
<!-- Organization and module name for the project -->
<property name="project.organization" value="org.sosy_lab.java_smt_example"/>
<property name="project.module" value="${ant.project.name}"/>
<property name="project.jar" value="${project.module}.jar"/>

<!-- Path to the "main" function -->
<property name="project.main" value="example.Main"/>

<target name="download-ivy" unless="skip.download">
<mkdir dir="lib"/>
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/2.5.0/ivy-2.5.0.jar"
dest="lib/ivy.jar" usetimestamp="true"/>
</target>

<target name="init-ivy" depends="download-ivy">
<path id="ivy.path">
<fileset dir="lib" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.path"/>
<ivy:settings file="lib/ivy-settings.xml"/>
</target>

<target name="resolve" depends="init-ivy" description="--> retrieve dependencies with Ivy">
<ivy:resolve log="download-only"/>
<ivy:retrieve pattern="lib/java/[conf]/([arch]/)[artifact](-[classifier]).[ext]"/>
</target>

<target name="copy" depends="resolve" description="--> copy solver libraries">
<mkdir dir="lib/native/x86_64-windows"/>
<copy todir="lib/native/x86_64-windows" flatten="true">
<fileset dir="lib/java/default">
<include name="**/*.dll"/>
<exclude name="arm64/*.dll"/>
</fileset>
</copy>
<mkdir dir="lib/native/arm64-windows"/>
<copy todir="lib/native/arm64-windows" flatten="true">
<fileset dir="lib/java/default">
<include name="arm64/*.dll"/>
</fileset>
</copy>
<mkdir dir="lib/native/x86_64-linux"/>
<copy todir="lib/native/x86_64-linux" flatten="true">
<fileset dir="lib/java/default">
<include name="**/*.so"/>
<exclude name="arm64/*.so"/>
</fileset>
</copy>
<mkdir dir="lib/native/arm64-linux"/>
<copy todir="lib/native/arm64-linux" flatten="true">
<fileset dir="lib/java/default">
<include name="arm64/*.so"/>
</fileset>
</copy>
<mkdir dir="lib/native/x86_64-macos"/>
<copy todir="lib/native/x86_64-macos" flatten="true">
<fileset dir="lib/java/default">
<include name="**/*.dylib"/>
<exclude name="arm64/*.dylib"/>
</fileset>
</copy>
<mkdir dir="lib/native/arm64-macos"/>
<copy todir="lib/native/arm64-macos" flatten="true">
<fileset dir="lib/java/default">
<include name="arm64/*.dll"/>
</fileset>
</copy>
</target>

<target name="compile" depends="copy" description="--> compile the project">
<mkdir dir="build"/>
<path id="classpath.build">
<pathelement location="build"/>
<fileset dir="lib/java" includes="**/*.jar"/>
</path>
<javac srcdir="src" destdir="build" classpathref="classpath.build"/>
</target>

<target name="package" depends="compile" description="--> build a .jar">
<manifestclasspath property="classpath.jar" jarfile="${project.jar}">
<classpath>
<fileset dir="lib/java/default" includes="*.jar"/>
</classpath>
</manifestclasspath>
<jar basedir="build"
destfile="${project.jar}"
includes="**"
whenmanifestonly="fail">
<manifest>
<attribute name="Class-Path" value="${classpath.jar}"/>
<attribute name="Main-Class" value="${project.main}"/>
</manifest>
</jar>
</target>

<target name="run" depends="package" description="--> run the program">
<java jar="${project.jar}" fork="true"/>
</target>

<target name="clean" description="--> clean the project">
<delete includeemptydirs="true" quiet="true">
<fileset dir=".">
<include name="build/**"/>
<include name="lib/ivy.jar"/>
<include name="lib/java/**"/>
<include name="lib/native/**"/>
<include name="${project.jar}"/>
</fileset>
</delete>
</target>
</project>
16 changes: 16 additions & 0 deletions doc/Example-Ivy-Project/ivy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
This file is part of JavaSMT,
an API wrapper for a collection of SMT solvers:
https://github.com/sosy-lab/java-smt

SPDX-FileCopyrightText: 2025 Dirk Beyer <https://www.sosy-lab.org>

SPDX-License-Identifier: Apache-2.0
-->

<ivy-module version="2.0">
<info organisation="${project.organization}" module="${project.module}"/>
<dependencies>
<dependency org="org.sosy_lab" name="java-smt" rev="5.0.1-618-ga6bdbf912" conf="default->runtime-x64,runtime-arm64"/>
</dependencies>
</ivy-module>
25 changes: 25 additions & 0 deletions doc/Example-Ivy-Project/lib/ivy-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
This file is part of JavaSMT,
an API wrapper for a collection of SMT solvers:
https://github.com/sosy-lab/java-smt

SPDX-FileCopyrightText: 2025 Dirk Beyer <https://www.sosy-lab.org>

SPDX-License-Identifier: Apache-2.0
-->

<ivysettings>
<settings defaultResolver="Sosy-Lab"/>
<property name="ivy.repo.url" value="https://www.sosy-lab.org/ivy"/>
<resolvers>
<url name="Sosy-Lab" descriptor="required">
<ivy pattern="${ivy.repo.url}/[organisation]/[module]/ivy-[revision].xml"/>
<artifact pattern="${ivy.repo.url}/[organisation]/[module]/([arch]/)[artifact]-[revision](-[classifier]).[ext]"/>
</url>
</resolvers>

<caches defaultCacheDir="${user.home}/.ivy2/cache"
artifactPattern="[organisation]/[module]/[type]s/([arch]/)[artifact]-[revision](-[classifier]).[ext]"/>
</ivysettings>
34 changes: 34 additions & 0 deletions doc/Example-Ivy-Project/src/example/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of JavaSMT,
// an API wrapper for a collection of SMT solvers:
// https://github.com/sosy-lab/java-smt
//
// SPDX-FileCopyrightText: 2025 Dirk Beyer <https://www.sosy-lab.org>
//
// SPDX-License-Identifier: Apache-2.0

package example;

import org.sosy_lab.common.ShutdownNotifier;
import org.sosy_lab.common.configuration.Configuration;
import org.sosy_lab.common.configuration.InvalidConfigurationException;
import org.sosy_lab.common.log.LogManager;
import org.sosy_lab.java_smt.SolverContextFactory;
import org.sosy_lab.java_smt.SolverContextFactory.Solvers;
import org.sosy_lab.java_smt.api.SolverContext;

public class Main {
public static void main(String[] args) {
Configuration config = Configuration.defaultConfiguration();
LogManager logger = LogManager.createNullLogManager();
ShutdownNotifier notifier = ShutdownNotifier.createDummy();

for (Solvers solver : Solvers.values()) {
try (SolverContext context =
SolverContextFactory.createSolverContext(config, logger, notifier, solver)) {
System.out.println(solver + ", " + context.getVersion());
} catch (InvalidConfigurationException e) {
System.out.println(solver + " not available");
}
}
}
}