Skip to content

Commit

Permalink
Created browsermob-dist module to package an executable jar and zip f…
Browse files Browse the repository at this point in the history
…ile. Using maven shade plugin and static unix and windows scripts instead of dynamically-generated scripts using appassembler plugin.
  • Loading branch information
jekh committed Jan 25, 2015
1 parent e89bcb7 commit e03fe1c
Show file tree
Hide file tree
Showing 10 changed files with 403 additions and 105 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -7,4 +7,5 @@ target
/.project
/.idea
atlassian-ide-plugin.xml
.DS_Store
.DS_Store
dependency-reduced-pom.xml
1 change: 1 addition & 0 deletions browsermob-core/pom.xml
Expand Up @@ -12,6 +12,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>browsermob-core</artifactId>
<name>BrowserMob Proxy Core Module</name>

<dependencies>
<dependency>
Expand Down
55 changes: 55 additions & 0 deletions browsermob-dist/assembly.xml
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/..</directory>
<includes>
<include>LICENSE.txt</include>
<include>README.txt</include>
<include>README.md</include>
</includes>
<outputDirectory>./</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/scripts</directory>
<outputDirectory>bin</outputDirectory>
<lineEnding>keep</lineEnding>
<fileMode>0744</fileMode>
<directoryMode>0755</directoryMode>
</fileSet>
<fileSet>
<directory>${project.basedir}/../browsermob-core/target</directory>
<includes>
<include>*-sources.jar</include>
<include>*-javadoc.jar</include>
</includes>
<outputDirectory>./</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/../browsermob-rest/target</directory>
<includes>
<include>*-sources.jar</include>
<include>*-javadoc.jar</include>
</includes>
<outputDirectory>./</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/config</directory>
<includes/>
<outputDirectory>bin/conf</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/target</directory>
<includes>
<include>${project.build.finalName}.jar</include>
</includes>
<outputDirectory>lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
125 changes: 125 additions & 0 deletions browsermob-dist/pom.xml
@@ -0,0 +1,125 @@
<?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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>browsermob-proxy</artifactId>
<groupId>net.lightbody.bmp</groupId>
<version>2.0-beta-10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>browsermob-dist</artifactId>
<packaging>jar</packaging>

<name>BrowserMob Proxy Distributable</name>

<properties>
<zip.name>${project.parent.artifactId}-${project.version}</zip.name>
</properties>

<dependencies>
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-rest</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<defaultGoal>package</defaultGoal>
<plugins>
<!-- Don't create an empty browsermob-proxy-dist jar file unless we are releasing -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
</plugin>
<!-- Don't install the executable jar in the maven repo -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>

</plugins>
</build>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<!-- Always create the jar file when releasing, to avoid problems with the shade plugin trying to re-shade a shaded jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<forceCreation>true</forceCreation>
<skipIfEmpty>false</skipIfEmpty>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>net.lightbody.bmp.proxy.Main</mainClass>
</transformer>
</transformers>
<shadedArtifactAttached>false</shadedArtifactAttached>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<executions>
<execution>
<id>make-bundles</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<finalName>${zip.name}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
File renamed without changes.
100 changes: 100 additions & 0 deletions browsermob-dist/src/main/scripts/browsermob-proxy
@@ -0,0 +1,100 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Copyright 2001-2006 The Apache Software Foundation.
#
# Licensed 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.
# ----------------------------------------------------------------------------

# Copyright (c) 2001-2002 The Apache Software Foundation. All rights
# reserved.

BASEDIR=`dirname $0`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`



# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
case "`uname`" in
CYGWIN*) cygwin=true ;;
Darwin*) darwin=true
if [ -z "$JAVA_VERSION" ] ; then
JAVA_VERSION="CurrentJDK"
else
echo "Using Java version: $JAVA_VERSION"
fi
if [ -z "$JAVA_HOME" ] ; then
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
fi
;;
esac

if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi

# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi

# If a specific java binary isn't specified search for the standard 'java' binary
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD=`which java`
fi
fi

if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly."
echo " We cannot execute $JAVACMD"
exit 1
fi

if [ -z "$REPO" ]
then
REPO="$BASEDIR"/lib
fi

CLASSPATH=$CLASSPATH_PREFIX:"$BASEDIR"/etc:"$REPO"/*
EXTRA_JVM_ARGUMENTS=""

# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
[ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
[ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
fi

exec "$JAVACMD" $JAVA_OPTS \
$EXTRA_JVM_ARGUMENTS \
-classpath "$CLASSPATH" \
-Dapp.name="browsermob-proxy" \
-Dapp.pid="$$" \
-Dapp.repo="$REPO" \
-Dbasedir="$BASEDIR" \
net.lightbody.bmp.proxy.Main \
"$@"

0 comments on commit e03fe1c

Please sign in to comment.