ZK Installation Guide/Setting up IDE/Maven/Use ZK Maven Artifacts/Resolving ZK Framework Artifacts via Maven
From Documentation
Search this book:
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.
Setup a simple Maven Web application project
A simple Web application project will be created using Maven archetype plugin and archetype:generate goal. Please refer to the Maven reference for more information on archetype [1]
mvn archetype:generate -DgroupId=com.mycompany -DartifactId=mywebapp -DpackageName=com.mycompany -Dversion=1.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-webapp
Here DgroupId, DartifactId, DpackageName and Dversion are user application specific whereas you can choose one of the Maven provided archetypes [2] for DarchetypeArtifactId parameter. Execute the above command on your command line and it will generate a simple web application project with default maven defined structure for you.
Upon the creation of this project to navigate to project directory and you can see a default pom.xml file already generated by Maven. It will look something like this
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>mywebapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>mywebapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>mywebapp</finalName>
</build>
</project>
Add ZK Maven repository to your pom.xml file
By default while resolving project dependencies Maven will only look into Maven central repository [3]. In order to use ZK Maven repository add following <repositories> element into pom.xml under the root <project> element.
<repositories>
<repository>
<id>zk repository</id>
<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>zk</artifactId>
<version>5.0.4</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zul</artifactId>
<version>5.0.4</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.0.0</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zhtml</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkbind</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zul</artifactId>
<version>6.0.0</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.0.0</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zhtml</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkbind</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkex</artifactId>
<version>6.0.0</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.0.0</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zhtml</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkbind</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkmax</artifactId>
<version>6.0.0</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>
Download / Customize pom.xml
Download directly
Download Latest PE pom.xml (Evaluation Only)
Download Latest EE pom.xml (Evaluation Only)
Customize your own pom.xml
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.
Add to your Maven projects
Choose the edition you want and add to you Super POM
1. CE (Freely avaialable under LGPL)
- http://mavensync.zkoss.org/maven2
- Sample Config
<repositories>
<repository>
<id>ZK CE</id>
<url>http://mavensync.zkoss.org/maven2</url>
</repository>
</repositories>
2. PE-eval / EE- eval (60-days free evaluation)
- http://mavensync.zkoss.org/eval/
- Sample Config
<repositories>
<repository>
<id>ZK PE/EE Evaluation</id>
<url>http://mavensync.zkoss.org/eval/</url>
</repository>
</repositories>
- Notice : Need Login authentication
If you are our customer or ZOL licensed user you can apply for a premium account to use ZK PE/EE maven repository. To use ZK PE/EE maven files 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
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>
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 |
| 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 | ||
| 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. 'Italic text'
Version History
Last Update : 2012/5/14
| Version | Date | Content |
|---|---|---|
| Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |
TOC
Use ZK Maven Artifacts
Use ZK Maven Artifacts 
