Add 2P-Kt as a dependency¶
How to pull one or more 2P-Kt modules into your own Gradle, Maven, or npm project.
2P-Kt is published under the Maven group ID it.unibo.tuprolog (JVM/Kotlin modules, via Maven Central and
GitHub Packages) and under the @tuprolog npm organization (JS modules).
Every module name below (core, solve-prolog, parser-impl, ...) maps directly to a Maven/Gradle artifact
ID. npm is the one exception — see step 3 below.
1. Pick the module(s) you need¶
2P-Kt is split into ~33 incrementally-dependent modules. The full, currently-published set is:
include(":utils")
include(":core")
include(":unify")
include(":theory")
include(":datalog")
include(":bdd")
include(":dsl-core")
include(":dsl-unify")
include(":dsl-theory")
include(":dsl-solve")
include(":solve")
include(":solve-prolog")
include(":solve-concurrent")
include(":test-solve")
include(":test-dsl")
include(":parser-core")
include(":parser-impl")
include(":parser-theory")
include(":solve-plp")
include(":solve-problog")
include(":serialize-core")
include(":serialize-theory")
include(":repl")
include(":oop-lib")
include(":io-lib")
include(":examples")
include(":full")
// BEGIN 2P-KT GUI REFACTOR MODULES
include(":gui")
include(":gui-plp")
include(":ide-swing")
include(":ide-plp-swing")
include(":ide-web")
// END 2P-KT GUI REFACTOR MODULES
Dependencies between modules are resolved transitively: importing theory automatically pulls in unify and
core; importing solve-prolog pulls in solve, theory, unify, and core; and so on. Pick the
highest-level module that covers your use case — e.g. solve-prolog for an SLD-resolution Prolog engine,
parser-impl for parsing terms/theories from text.
2. Add the 2P-Kt repositories¶
Gradle (Kotlin DSL):
Maven:
mavenCentral() alone is enough for stable releases; add the GitHub Packages repository too if you need a
dev/pre-release build (authentication may be required for GitHub Packages).
npm users don't need this step: the @tuprolog packages are public on the default npm registry.
3. Declare the dependency¶
Replace 2P_MODULE with the module name from step 1, and 2P_VERSION with the version you want
(e.g. the latest release).
Gradle (Kotlin DSL):
Maven:
npm: because of how the Kotlin/JS compiler works, splitting the published npm packages per-module the way the
JVM/Maven artifacts are doesn't make sense; use the @tuprolog/2p-full package (note the 2p- prefix — every
2P-Kt npm package is published as @tuprolog/2p-<module>) regardless of which module(s) you actually need:
4. JVM-only projects: use the -jvm suffix¶
If your Gradle/Maven project only targets the JVM (i.e. it's not a Kotlin Multiplatform project), append -jvm
to the artifact ID to avoid pulling in the multiplatform metadata artifact:
Gradle (Kotlin DSL):
Maven:
<dependency>
<groupId>it.unibo.tuprolog</groupId>
<artifactId>2P_MODULE-jvm</artifactId>
<version>2P_VERSION</version>
</dependency>
npm packages are JS-only and don't have a -jvm variant.
Verify¶
Once the dependency resolves, a quick smoke test with the core module is enough to confirm the setup works:
import it.unibo.tuprolog.core.Atom
import it.unibo.tuprolog.core.Struct
fun main() {
println(Struct.of("foo", Atom.of("bar")))
}
See the Reference section for the full API surface of each module.