Skip to content

Commit

Permalink
ZOOKEEPER-3755: Use maven to create fatjar
Browse files Browse the repository at this point in the history
- replace ant build.xml with maven pom.xml for zookeeper-contrib-fatjar module
- create maven profile "fatjar" to build a fatjar file.
- update readme files

Author: Sushant Mane <sushant.mane@sjsu.edu>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Benjamin Reed <breed@apache.org>

Closes #1284 from sushantmane/master
  • Loading branch information
sushantmane authored and Enrico Olivelli committed Mar 26, 2020
1 parent b4a3238 commit 1ff1b77
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 91 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Expand Up @@ -261,6 +261,13 @@
<module>zookeeper-contrib</module>
</modules>
</profile>
<profile>
<id>fatjar</id>
<modules>
<module>zookeeper-it</module>
<module>zookeeper-contrib/zookeeper-contrib-fatjar</module>
</modules>
</profile>
<profile>
<id>java-build</id>
<activation>
Expand Down
9 changes: 9 additions & 0 deletions zookeeper-contrib/pom.xml
Expand Up @@ -40,6 +40,15 @@
<module>zookeeper-contrib-zooinspector</module>
</modules>

<profiles>
<profile>
<id>fatjar</id>
<modules>
<module>zookeeper-contrib-fatjar</module>
</modules>
</profile>
</profiles>

<build>
<pluginManagement>
<plugins>
Expand Down
21 changes: 21 additions & 0 deletions zookeeper-contrib/zookeeper-contrib-fatjar/README.md
@@ -0,0 +1,21 @@
ZooKeeper Fatjar
================

This package contains build to create a fat zookeeper jar. Fatjar can be used to run:
- zookeeper server
- zookeeper client
- distributed load generator for testing (generateLoad)
- container that will instantiate classes as directed by an instance manager (ic)
- system test (systest)
- jmh micro benchmarks (jmh)


Use following command to build fatjar
```
mvn clean install -P fatjar -DskipTests
```

To run the fatjar use:
```
java -jar zoookeeper-<version>-fatjar.jar
```
2 changes: 0 additions & 2 deletions zookeeper-contrib/zookeeper-contrib-fatjar/README.txt

This file was deleted.

74 changes: 0 additions & 74 deletions zookeeper-contrib/zookeeper-contrib-fatjar/build.xml

This file was deleted.

145 changes: 145 additions & 0 deletions zookeeper-contrib/zookeeper-contrib-fatjar/pom.xml
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper-contrib</artifactId>
<version>3.7.0-SNAPSHOT</version>
</parent>

<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper-contrib-fatjar</artifactId>
<packaging>jar</packaging>
<name>Apache ZooKeeper - Contrib - Fatjar</name>

<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
<maven.source.skip>true</maven.source.skip>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper-jute</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper-it</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${project.basedir}/../../conf</directory>
<includes>
<include>log4j.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.apache.zookeeper.util.FatJarMain</mainClass>
</manifest>
</archive>
<finalName>zookeeper-${project.version}-fatjar</finalName>
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Expand Up @@ -4,8 +4,6 @@ client:org.apache.zookeeper.ZooKeeperMain:Client shell to ZooKeeper
server:org.apache.zookeeper.server.quorum.QuorumPeerMain:Start ZooKeeper server
::Test Commands
generateLoad:org.apache.zookeeper.test.system.GenerateLoad:A distributed load generator for testing
quorumBench:org.apache.zookeeper.server.QuorumBenchmark:A benchmark of just the quorum protocol
abBench:org.apache.zookeeper.server.quorum.AtomicBroadcastBenchmark:A benchmark of just the atomic broadcast
ic:org.apache.zookeeper.test.system.InstanceContainer:A container that will instantiate classes as directed by an instance manager
systest:org.apache.zookeeper.test.system.BaseSysTest:Start system test
jmh:org.apache.zookeeper.BenchMain:Run jmh micro benchmarks
9 changes: 5 additions & 4 deletions zookeeper-it/README.txt
Expand Up @@ -7,11 +7,12 @@ The easiest way to do all of this is to use the zookeeper fat jar.

Steps to run system test
------------------------
1) transfer the fatjar from the release directory to all systems
participating in the test. fatjar is in contrib/fatjar directory.
1) build and transfer the fatjar from the `zookeeper-contrib/zookeeper-contrib-fatjar/target`
directory to all systems participating in the test

(developers can generate by running "ant jar compile-test"
targets in trunk, then compiling using "ant jar" in src/contrib/jarjar)
Command to build fatjar without executing the tests:

`mvn clean install -P fatjar -DskipTests`

2) run a zookeeper standalone instance (cluster is ok too)

Expand Down
77 changes: 77 additions & 0 deletions zookeeper-it/pom.xml
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.zookeeper</groupId>
<artifactId>parent</artifactId>
<version>3.7.0-SNAPSHOT</version>
</parent>

<artifactId>zookeeper-it</artifactId>
<packaging>jar</packaging>
<name>Apache ZooKeeper - Tests</name>
<description>
ZooKeeper system tests
</description>

<dependencies>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.23</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.23</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<sourcepath>src</sourcepath>
</configuration>
</plugin>
</plugins>
</build>
</project>
Expand Up @@ -35,9 +35,9 @@ public class WatchBench {
static final EventType event = EventType.NodeDataChanged;

static IWatchManager createWatchManager(String className) throws Exception {
Class clazz = Class.forName(
Class<?> clazz = Class.forName(
"org.apache.zookeeper.server.watch." + className);
return (IWatchManager) clazz.newInstance();
return (IWatchManager) clazz.getConstructor().newInstance();
}

static void forceGC() {
Expand Down

0 comments on commit 1ff1b77

Please sign in to comment.