This page is part of the [[Developer Section]]. It demonstrates how [httphttps://maven.apache.org Maven] is used to compile and run BaseX, and embed it into other projects.
==Using Maven==
If you have [[Git|cloned our repositoriesrepository]] and installed Maven on your machine,
you can run the following commands from all local repository directories:
* <code>mvn compile</code>: the BaseX source files are compiled. To launch the project, type in <code>java -cp target/classes org.basex.BaseX</code>, or have a look at our [[Start Scripts]].* <code>mvn package</code>: JAR archives are created in the <code>{{Code|target</code> }} class directory, and all relevant libraries are created in the {{Code|lib}} directory. Packaging is useful if you want to use the start scripts.* <code>mvn install</code>: the JAR archive is installed to the local repository, and made available to other Maven projects. This is particularly useful if you are compiling a beta version of BaseX, for which no archives exist in the repositories.
By adding the flag <code>-DskipTests</code> you can skip the JUnit tests and speed up packaging. You may as well use [[Developing with Eclipse|Eclipse and m2eclipse]] to compile the BaseX sources. There are several alternatives for starting BaseX: * type in {{Code|java -cp target/classes org.basex.BaseX}} in the {{Code|basex-core}} directory to start BaseX on the command-line mode,* type in {{Code|mvn jetty:run}} in the {{Code|basex-api}} directory to start BaseX with Jetty and the HTTP servers,* run one of the [[Start Scripts]] contained in the {{Code|etc}} directory
==Artifacts==
You can easily embed BaseX into your own Maven projects by adding the following XML snippets to your {{Code|pom.xml}} file:
<pre classsyntaxhighlight lang="brush:xml"><<repositories>> <<repository>> <<id>>basex<</id>> <<name>>BaseX Maven Repository<</name>> <<url>>http://files.basex.org/maven<</url>> <</repository>><</repositories>></presyntaxhighlight>
===BaseX Main Package===
<pre classsyntaxhighlight lang="brush:xml"><<dependency>> <<groupId>>org.basex<</groupId>> <<artifactId>>basex<</artifactId>> <<version>>7.5<6</version>><</dependency>></presyntaxhighlight>
===APIs and Services===
<p>...including APIs and the [[REST]], [[RESTXQ]] and [[WebDAV]] services:</p>
<pre classsyntaxhighlight lang="brush:xml"><<dependency>> <<groupId>>org.basex<</groupId>> <<artifactId>>basex-api<</artifactId>> <<version>>7.5<6</version>><</dependency>></presyntaxhighlight>
===XQJ API===
<p>The XQJ API is hosted at http://xqj.net:</p>
<pre classsyntaxhighlight lang="brush:xml">
<repository>
<id>xqj</id>
<version>1.0</version>
</dependency>
</presyntaxhighlight> [[Category:Developer]]