Difference between revisions of "Maven"

From BaseX Documentation
Jump to navigation Jump to search
(27 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page is part of the [[Developer Section]]. It demonstrates how [http://maven.apache.org Maven] is used to compile and run BaseX, and embed it into other projects.
+
This page is part of the [[Developer Section]]. It demonstrates how [https://maven.apache.org Maven] is used to compile and run BaseX, and embed it into other projects.
  
 
==Using Maven==
 
==Using Maven==
 
   
 
   
If the standalone version of [http://maven.apache.org Maven] is installed,
+
If you have [[Git|cloned our repository]] and installed Maven on your machine,
you can use the following commands in any of the BaseX repositories:
+
you can run the following commands from all local repository directories:
  
* <code>mvn compile</code>: the BaseX source files are is 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 compile</code>: the BaseX source files are compiled.
* <code>mvn package</code>: JAR archives are created in the <code>target</code> class directory.
+
* <code>mvn package</code>: JAR archives are created in the {{Code|target}} 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.
+
* <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=true</code> you can skip running the JUnit tests and speed up the packaging procedure. You may as well use [[Integrate|Eclipse and m2eclipse]] to compile the BaseX sources.
 
 
   
 
   
 +
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==
 
==Artifacts==
  
<p>As BaseX is offered in a Maven repository, you can easily embed it into your own projects.
+
You can easily embed BaseX into your own Maven projects by adding the following XML snippets to your {{Code|pom.xml}} file:
To use the BaseX Maven Artifacts, add the following lines to your
+
 
<code>pom.xml</code> file:</p>
+
<syntaxhighlight lang="xml"><repositories>
<pre class="brush:xml">&lt;repositories&gt;
+
   <repository>
   &lt;repository&gt;
+
     <id>basex</id>
     &lt;id&gt;basex&lt;/id&gt;
+
     <name>BaseX Maven Repository</name>
     &lt;name&gt;BaseX Maven Repository&lt;/name&gt;
+
     <url>http://files.basex.org/maven</url>
     &lt;url&gt;http://files.basex.org/maven&lt;/url&gt;
+
   </repository>
   &lt;/repository&gt;
+
</repositories></syntaxhighlight>  
&lt;/repositories&gt;</pre>  
 
 
   
 
   
===BaseX===  
+
===BaseX Main Package===  
<pre class="brush:xml">&lt;dependency&gt;
+
 
   &lt;groupId&gt;org.basex&lt;/groupId&gt;
+
<syntaxhighlight lang="xml"><dependency>
   &lt;artifactId&gt;basex&lt;/artifactId&gt;
+
   <groupId>org.basex</groupId>
   &lt;version&gt;6.7.1&lt;/version&gt;
+
   <artifactId>basex</artifactId>
&lt;/dependency&gt;</pre>
+
   <version>7.6</version>
 +
</dependency></syntaxhighlight>
 +
 
 +
===APIs and Services===
 +
 
 +
<p>...including APIs and the [[REST]], [[RESTXQ]] and [[WebDAV]] services:</p>
 +
<syntaxhighlight lang="xml"><dependency>
 +
  <groupId>org.basex</groupId>
 +
  <artifactId>basex-api</artifactId>
 +
  <version>7.6</version>
 +
</dependency></syntaxhighlight>
  
===BaseX API===  
+
===XQJ API===  
<p>...including the [[REST]], [http://sourceforge.net/projects/xmldb-org XML:DB]
 
and [http://jcp.org/en/jsr/detail?id=225 XQJ] APIs:</p>
 
<pre class="brush:xml">&lt;dependency&gt;
 
  &lt;groupId&gt;org.basex&lt;/groupId&gt;
 
  &lt;artifactId&gt;basex-api&lt;/artifactId&gt;
 
  &lt;version&gt;6.7.1&lt;/version&gt;
 
&lt;/dependency&gt;</pre>
 
  
[[Category:Developer]]
+
<p>The XQJ API is hosted at http://xqj.net:</p>
 +
<syntaxhighlight lang="xml">
 +
<repository>
 +
  <id>xqj</id>
 +
  <name>XQJ Maven Repository</name>
 +
  <url>http://xqj.net/maven</url>
 +
</repository>
 +
...
 +
<dependency>
 +
  <groupId>net.xqj</groupId>
 +
  <artifactId>basex-xqj</artifactId>
 +
  <version>1.2.0</version>
 +
</dependency>
 +
<dependency>
 +
  <groupId>com.xqj2</groupId>
 +
  <artifactId>xqj2</artifactId>
 +
  <version>0.1.0</version>
 +
</dependency>
 +
<dependency>
 +
  <groupId>javax.xml.xquery</groupId>
 +
  <artifactId>xqj-api</artifactId>
 +
  <version>1.0</version>
 +
</dependency>
 +
</syntaxhighlight>

Revision as of 09:52, 29 July 2020

This page is part of the Developer Section. It demonstrates how Maven is used to compile and run BaseX, and embed it into other projects.

Using Maven

If you have cloned our repository and installed Maven on your machine, you can run the following commands from all local repository directories:

  • mvn compile: the BaseX source files are compiled.
  • mvn package: JAR archives are created in the target class directory, and all relevant libraries are created in the lib directory. Packaging is useful if you want to use the start scripts.
  • mvn install: 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 -DskipTests you can skip the JUnit tests and speed up packaging. You may as well use Eclipse and m2eclipse to compile the BaseX sources.

There are several alternatives for starting BaseX:

  • type in java -cp target/classes org.basex.BaseX in the basex-core directory to start BaseX on the command-line mode,
  • type in mvn jetty:run in the basex-api directory to start BaseX with Jetty and the HTTP servers,
  • run one of the Start Scripts contained in the etc directory

Artifacts

You can easily embed BaseX into your own Maven projects by adding the following XML snippets to your pom.xml file:

<syntaxhighlight lang="xml"><repositories>

 <repository>
   <id>basex</id>
   <name>BaseX Maven Repository</name>
   <url>http://files.basex.org/maven</url>
 </repository>

</repositories></syntaxhighlight>

BaseX Main Package

<syntaxhighlight lang="xml"><dependency>

 <groupId>org.basex</groupId>
 <artifactId>basex</artifactId>
 <version>7.6</version>

</dependency></syntaxhighlight>

APIs and Services

...including APIs and the REST, RESTXQ and WebDAV services:

<syntaxhighlight lang="xml"><dependency>

 <groupId>org.basex</groupId>
 <artifactId>basex-api</artifactId>
 <version>7.6</version>

</dependency></syntaxhighlight>

XQJ API

The XQJ API is hosted at http://xqj.net:

<syntaxhighlight lang="xml"> <repository>

 <id>xqj</id>
 <name>XQJ Maven Repository</name>
 <url>http://xqj.net/maven</url>

</repository> ... <dependency>

 <groupId>net.xqj</groupId>
 <artifactId>basex-xqj</artifactId>
 <version>1.2.0</version>

</dependency> <dependency>

 <groupId>com.xqj2</groupId>
 <artifactId>xqj2</artifactId>
 <version>0.1.0</version>

</dependency> <dependency>

 <groupId>javax.xml.xquery</groupId>
 <artifactId>xqj-api</artifactId>
 <version>1.0</version>

</dependency> </syntaxhighlight>