From Documentation

Jump to: navigation, search







Contents

How to Use ZK Maven Repository

This chapter describes how to use the Maven repository hosted by ZK. Here introduces you a simple example for using ZK maven repository in your maven build environment.

Add ZK Maven repository to your pom.xml file

By default while resolving project dependencies Maven will only look into Maven central repository [1]. In order to use ZK Maven repository add following <repositories> element into pom.xml under the root <project> element.

 <repositories>
    <repository>
      <id>ZK CE</id>
      <name>ZK CE Repository</name>
      <url>http://mavensync.zkoss.org/maven2</url>
    </repository>
  </repositories>

Note that ZK Maven repository URL is http://mavensync.zkoss.org/maven2.

Adding ZK library dependencies

Depending upon your project requirements your project might depend on various ZK libraries. You can declare these dependencies in pom.xml file and Maven can resolve them by automatically connecting to ZK Maven repository Here is how you can declare a dependency for main ZK library and zul library for your project.

<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zkbind</artifactId>
	<version>6.5.2</version>
</dependency>
<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zul</artifactId>
	<version>6.5.2</version>
</dependency>
<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zkplus</artifactId>
	<version>6.5.2</version>
</dependency>
<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zhtml</artifactId>
	<version>6.5.2</version>
</dependency>

In order for Maven to successfully resolve these dependencies groupid and artifactid must match with those published on ZK Maven repository as they constitute what is known as Maven repository coordinates. For a complete list of all ZK library groupid and artifactid combinations please take a look at a sample pom.xml file that lists dependencies for all publically available ZK libraries on ZK Maven repository.

Sample of pom.xml

Here is sample pom.xml for a simple Java project that uses the ZK maven repository.

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"   
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>zk.app</groupId>
  <artifactId>MyZKMavenApp</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <repositories>
    <repository>
      <id>ZK CE</id>
      <name>ZK CE Repository</name>
      <url>http://mavensync.zkoss.org/maven2</url>
    </repository>
    <repository>
      <id>ZK EVAL</id>
      <name>ZK Evaluation Repository</name>
      <url>http://mavensync.zkoss.org/eval</url>
    </repository>
  </repositories>
  <dependencies>
....
  </dependencies>
</project>

Sample of Dependencies

ZK CE

<dependencies>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zkplus</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zhtml</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zkbind</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zul</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>1.3.1</version>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.4</version>
    </dependency>
</dependencies>

ZK PE

<dependencies>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zkplus</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zhtml</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zkbind</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zkex</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>1.3.1</version>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.4</version>
    </dependency>
</dependencies>

ZK EE

<dependencies>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zkplus</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zhtml</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zkbind</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.zkoss.zk</groupId>
      <artifactId>zkmax</artifactId>
      <version>6.5.2</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>1.3.1</version>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.4</version>
    </dependency>
</dependencies>

How to Choose the Right ZK Maven Repository for a ZK Package

ZK has three editions: : CE, PE and EE. They are hosted in different Maven repository. I will guide you through how to choose the right edition, and set up the right ZK Maven repository.

Steps for choosing the right edition

Here are the steps for choosing the right edition of ZK:

Decide which edition to use:

  • There are three editions of ZK: CE, PE and EE
  • For more information, please refer to description about ZK Editions and the following section that summarizes the jar files.


Summary of JAR files

There're something you need to know about ZK's edition and package(s).

CE PE EE Description
zk.jar V V V ZK core functions, such as ZK Loader and Update Engine.
zul.jar V V V ZK XUL components (http://www.zkoss.org/2005/zul)
zhtml.jar V V V ZK XHTML components (http://www.w3c.org/1999/xhtml)
zcommon.jar V V V The common library that ZK depends on
zcommons-el.jar V V V ZK EL expressions (renamed as zel.jar since 6.0)
zel.jar V V V ZK EL expressions (since 6.0)
zkbind.jar V V V data binding, required when developing with MVVM
zweb.jar V V V The Web library that ZK depends on
zkplus.jar V V V ZK extra utilities integrated easily with other frameworks.
zkex.jar V V ZK additional components and features for PE
zkmax.jar V ZK additional components and features for EE
zuti.jar V shadow components for EE
zml.jar V
(only ZK 3)
V V ZK XML components for generating XML output

This will be helpful when you modify your dependencies of projects.

Add to your Maven projects

Choose the edition you want and add to you Super POM

1. CE (Freely avaialable under LGPL)

 <repositories>
    <repository>
      <id>ZK CE</id>
      <url>http://mavensync.zkoss.org/maven2</url>
    </repository>
  </repositories>

2. PE-eval / EE- eval (60-days free evaluation)

 <repositories>
    <repository>
      <id>ZK PE/EE Evaluation</id>
      <url>http://mavensync.zkoss.org/eval/</url>
    </repository>
  </repositories>
  • Note: Version number *-Eval has released since Jul. 18 2014. If you use it, please specify version to *-Eval for all of ZK dependencies. For example:
<dependency>
    <groupId>org.zkoss.zk</groupId>
    <artifactId>zk</artifactId>
    <version>7.0.2-Eval</version>
</dependency>

3. PE / EE (premium users only)

If you are our customer or ZOL licensed user you can contact info@zkoss.org to apply for a premium maven account to use ZK PE/EE (or any other licensed ZK product) maven repository. To use licensed ZK PE/EE or any other licensed ZK products you have to add both CE and EE repositories as illustrated as follows,

 <repositories>
   <repository>
     <id>ZK CE</id>
     <url>http://mavensync.zkoss.org/maven2</url>
   </repository>
    <repository>
      <id>ZK EE</id>
      <url>https://maven.zkoss.org/repo/zk/ee</url>
    </repository>
  </repositories>
Login authentication

Licensed Professional and Enterprise customers will be given a set of user name and password upon your request. According to the official doc of Apache Maven, users can create global settings for maven.

  • Location (if not existed, you can create it manually)
    • The Maven install: $M2_HOME/conf/settings.xml
    • A user's install: ${user.home}/.m2/settings.xml
  • Servers Element
  • If you add ZK PE or ZK EE as your repository, you need to add login authentication like following example
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
 		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 		xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
 		http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<servers>
		<server>
			<id>ZK EE</id><!-- Same as your repository name -->
			<!-- Your premium user name and password -->
			<username>ryanwu</username> 
			<password>2k055ecret</password> 
		</server>
	</servers>
</settings>
Sample of pom.xml for licensed Professional Package
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>zkpe</groupId>
	<artifactId>sample</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<properties>
		<!-- please change the version accordingly -->
		<zk.version>6.5.2</zk.version>
		<commons-io>1.3.1</commons-io>
		<zktimeline.version>2.3.1_50</zktimeline.version>
	</properties>
	<packaging>war</packaging>
	<name>The sample Project</name>
	<description>The sample Project</description>
	<repositories>
		<repository>
			<id>ZK CE</id>
			<name>ZK CE Repository</name>
			<url>http://mavensync.zkoss.org/maven2</url>
		</repository>
		<repository>
		    <id>ZK EE</id>
		    <url>https://maven.zkoss.org/repo/zk/ee</url>
		</repository>
	</repositories>
	<dependencies>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkbind</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zul</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkplus</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zhtml</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.common</groupId>
			<artifactId>zweb</artifactId>
			<version>${zk.version}</version>
		</dependency>
		
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>${commons-io}</version>
		</dependency>
		
		<!-- ZK PE -->
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkex</artifactId>
			<version>${zk.version}</version>
		</dependency>

		<!-- ZK Timeline-->
		<dependency>
			<groupId>org.zkoss.zkforge</groupId>
			<artifactId>timelinez</artifactId>
			<version>${zktimeline.version}</version>
		</dependency>
	</dependencies>
</project>
Sample of pom.xml for licensed Enterprise Package
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>zkee</groupId>
	<artifactId>sample</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<properties>
		<!-- please change the version accordingly -->
		<zk.version>6.5.2</zk.version>
		<commons-io>1.3.1</commons-io>
		<zkspring.version>3.1.1</zkspring.version>
		<zats.version>1.1.0</zats.version>
		<zkjsp.version>2.3</zkjsp.version>
		<zkcalendar.version>2.1.2</zkcalendar.version>
		<zkgmap.version>3.0.1</zkgmap.version>
		<zktimeline.version>2.3.1_50</zktimeline.version>
		<zktimeplot.version>1.1_50</zktimeplot.version>
	</properties>
	<packaging>war</packaging>
	<name>The sample Project</name>
	<description>The sample Project</description>
	<repositories>
		<repository>
			<id>ZK CE</id>
			<name>ZK CE Repository</name>
			<url>http://mavensync.zkoss.org/maven2</url>
		</repository>
		<repository>
			<id>ZK EE</id>
			<url>https://maven.zkoss.org/repo/zk/ee</url>
		</repository>
	</repositories>
	<dependencies>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkbind</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zul</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkplus</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zhtml</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.common</groupId>
			<artifactId>zweb</artifactId>
			<version>${zk.version}</version>
		</dependency>
		
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>${commons-io}</version>
		</dependency>
		
		<!-- ZK PE / EE -->
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkex</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkmax</artifactId>
			<version>${zk.version}</version>
		</dependency>

		<!-- ZATS Mimic -->
		<dependency>
			<groupId>org.zkoss.zats</groupId>
			<artifactId>zats-mimic-ext6</artifactId>
			<version>${zats.version}</version>
			<scope>test</scope>
		</dependency>

		<!-- ZK Spring -->
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkspring-core</artifactId>
			<version>${zkspring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkspring-security</artifactId>
			<version>${zkspring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkspring-webflow</artifactId>
			<version>${zkspring.version}</version>
		</dependency>

		<!-- ZK JSP -->
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zuljsp</artifactId>
			<version>${zkjsp.version}</version>
		</dependency>

		<!-- ZK Calendar -->
		<dependency>
			<groupId>org.zkoss.calendar</groupId>
			<artifactId>calendar</artifactId>
			<version>${zkcalendar.version}</version>
		</dependency>

		<!-- ZK Google Maps -->
		<dependency>
			<groupId>org.zkoss.zkforge</groupId>
			<artifactId>gmapsz</artifactId>
			<version>${zkgmap.version}</version>
		</dependency>

		<!-- ZK Timeline -->
		<dependency>
			<groupId>org.zkoss.zkforge</groupId>
			<artifactId>timelinez</artifactId>
			<version>${zktimeline.version}</version>
		</dependency>

		<!-- ZK Timeplot -->
		<dependency>
			<groupId>org.zkoss.zkforge</groupId>
			<artifactId>timeplotz</artifactId>
			<version>${zktimeplot.version}</version>
		</dependency>
	</dependencies>
</project>
Trouble Shooting

If you have problem switching from the evaluation repository to the licensed one, please check the followings:

Purge local repository evaluation cache
  • 1. Add purge-local-repository plugin in pom.xml
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>2.6</version>
				<executions>
					<execution>
						<id>purge-local-dependencies</id>
						<phase>clean</phase>
						<goals>
							<goal>purge-local-repository</goal>
						</goals>
						<configuration>
							<manualIncludes>
								<manualInclude>org.zkoss.zk:zkex</manualInclude>
								<manualInclude>org.zkoss.zk:zkmax</manualInclude>
							</manualIncludes>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
   *line 16: ZK PE
   *line 17: ZK EE
  • 2. Invoke maven clean to delete local zkex & zkmax repository
mvn clean

Version History

Last Update : 2017/1/12


Version Date Content
N/A July 2014 Self-signed certificate related section removed as EE maven repository is certified since Feb. 2014



Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.



You got stuck here?
Let us know how we can improve this page
For specific questions please use the forum