Overhaul our build system to only create a WAR file

We're a web application.  There is no reason to create anything else
other than a single stand-alone WAR file out of our build.  Using the
appjar, appdist, devdb projects all in the same repository is chaos
and difficult to maintain.

The Hudson continuous integration project has their entire WAR file
as a self-contained application, which can be run directly off the
command line with "java -jar hudson.war".  This is rather nice, as
it makes it a lot easier for users to run the application code that
comes along with the web application.

This change moves everything into a single WAR file, and thus can
cut our overall download by 6 MB by reducing the copies of each
dependency JAR down from 2 (one in the .tar.bz2, one in the WAR
embedded in the .tar.bz2) to only 1 (the one in the WAR itself).

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-02-02 15:39:12 -08:00
parent 38272d5d82
commit b8527eab37
26 changed files with 262 additions and 944 deletions

View File

@@ -56,7 +56,7 @@ Ensure mina_sshd has been installed in your maven repository:
Import Projects
---------------
Import appdist using General -> Maven Projects
Import appjar using General -> Maven Projects
If you also want source projects for gwtorm, gwtjsonrpc or mina_sshd,
import their top-level directories the same way. Note that you
@@ -80,16 +80,10 @@ Configure Database
You may have already done this step earlier, based on the
instructions in link:dev-readme.html[Developer Setup].
* Open gerrit-devdb/src/main/config
* Open gerrit-appjar/src/main/java
* Copy `GerritServer.properties_example` to `GerritServer.properties`
* Configure your database for debugging in hosted mode.
Sometimes Eclipse doesn't correctly update gerrit-devdb after you
create or make changes to GerritServer.properties. Its a good
idea to use Project -> Clean... to clean this project, and also
right click Refresh to ensure Eclipse has fully updated the runtime
location with the most current property file.
Launch Gerrit
-------------

View File

@@ -39,7 +39,7 @@ gwtorm supports (or add the necessary dialect support to gwtorm,
and then configure your workspace anyway).
====
cd devdb/src/main/config/
cd appjar/src/main/java
cp GerritServer.properties_example GerritServer.properties
====
@@ -100,13 +100,13 @@ Building
From the command line:
====
(cd appdist && mvn install)
(cd appjar && mvn package)
====
Output packages will be placed in:
Output WAR will be placed in:
====
appdst/target/gerrit-*-bin.*
appjar/target/gerrit-*.war
====

View File

@@ -83,8 +83,7 @@ the database name *must* be the default of `reviewdb`, unless you
modify `devutil/1-to-2.sh`.
====
cd devdb/src/main/config/
cp GerritServer.properties_example GerritServer.properties
./gerrit.war --cat extra/GerritServer.properties_example >GerritServer.properties
====
Make sure the user exists in PostgreSQL:

View File

@@ -19,9 +19,8 @@ the downloads page at the project site:
* http://code.google.com/p/gerrit/downloads/list[Gerrit Downloads]
Download a `*.bin.tar.bz2` package and untar it locally with
`tar jtf gerrit-2.0.bin.tar.bz2` (or whatever the downloaded
file was).
Download any current `*.war` package.
Building Gerrit From Source
---------------------------
@@ -37,18 +36,17 @@ Maven from a source download obtained directly from Git:
(cd jgit/jgit-maven/jgit && mvn install)
(cd mina_sshd && mvn install)
cd appdist
mvn clean install
cd target/gerrit-*-bin.dir/gerrit-*
(cd appjar && mvn clean package)
cp appjar/target/gerrit-*.war ...YOUR.DEST.../gerrit.war
====
The first build may take a while as dependencies are searched
for and downloaded from Maven distribution repositories.
Unfortunately you need to install to your local Maven repository
(typically under `~/.m2`) in order to fully build all of the source
based dependencies. Some core dependencies for Gerrit are still
under active development and have not made final releases yet.
Unfortunately you need to install snapshots of both JGit and MINA
SSHD to your local Maven repository (typically under `~/.m2`).
These core dependencies are still under active development and have
not made final releases yet.
Apache Maven:
@@ -85,12 +83,13 @@ Initialize the Schema
Create the Gerrit 2 Tables
~~~~~~~~~~~~~~~~~~~~~~~~~~
Either run CreateSchema from the command line (requires writing
a `GerritServer.properties`, see `GerritServer.properties_example`
under `devdb/src/main/config`):
Either run CreateSchema from the command line:
====
bin/gerrit2.sh --config=GerritServer.properties CreateSchema
java -jar gerrit.war --cat extra/GerritServer.properties_example >GerritServer.properties
edit GerritServer.properties
java -jar gerrit.war CreateSchema
====
Or, run the application once in a container to force it to initialize
@@ -108,7 +107,7 @@ can avoid table scans when looking up information. Run the
e.g. with PostgreSQL:
====
psql -f sql/query_index.sql reviewdb
java -jar gerrit.war --cat sql/query_index.sql | psql reviewdb
====
Configure site_path
@@ -185,12 +184,17 @@ call the unpacked directory `$JETTY_HOME`.
* http://dist.codehaus.org/jetty/[Jetty Downloads]
Install the JDBC drivers, using either the ones that come embedded
with Gerrit, or by downloading them yourself from their mirrors:
====
java -jar gerrit.war --cat lib/c3p0-0.9.1.2.jar >$JETTY_HOME/lib/plus/c3p0-0.9.1.2.jar
java -jar gerrit.war --cat lib/postgresql-8.3-603.jdbc3.jar >$JETTY_HOME/lib/plus/postgresql-8.3-603.jdbc3.jar
====
Copy Gerrit into the deployment:
====
cp jdbc/c3p0-*.jar $JETTY_HOME/lib/plus/
cp jdbc/postgresql-*.jdbc*.jar $JETTY_HOME/lib/plus/
cp www/jetty_gerrit.xml $JETTY_HOME/contexts/gerrit.xml
cp www/gerrit-*.war $JETTY_HOME/webapps/gerrit.war
java -jar gerrit.war --cat extra/jetty_gerrit.xml >$JETTY_HOME/contexts/gerrit.xml
cp gerrit.war $JETTY_HOME/webapps/gerrit.war
rm -f $JETTY_HOME/context/test.xml
====
@@ -232,7 +236,7 @@ Under Jetty, restarting the web application (e.g. after modifying
Other Servlet Containers
~~~~~~~~~~~~~~~~~~~~~~~~
Deploy the `www/gerrit-*.war` file to your application server as
Deploy the `gerrit-*.war` file to your application server as
`gerrit.war`.
Configure the JNDI DataSource `jdbc/ReviewDb` for the Gerrit web

5
appdist/.gitignore vendored
View File

@@ -1,5 +0,0 @@
/target
/bin
/.classpath
/.project
/.settings

View File

@@ -1,64 +0,0 @@
<assembly>
<id>bin</id>
<formats>
<format>dir</format>
<format>tar.bz2</format>
</formats>
<moduleSets>
<moduleSet>
<includes>
<include>gerrit:gerrit-appjar</include>
</includes>
<binaries>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
<moduleSet>
<includes>
<include>gerrit:gerrit-appwar</include>
</includes>
<binaries>
<outputDirectory>www</outputDirectory>
<unpack>false</unpack>
<includeDependencies>false</includeDependencies>
</binaries>
</moduleSet>
<moduleSet>
<includes>
<include>gerrit:gerrit-devdb</include>
</includes>
<binaries>
<outputDirectory>jdbc</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
<fileSets>
<fileSet>
<directory>src/main/bin</directory>
<outputDirectory>bin</outputDirectory>
<lineEnding>unix</lineEnding>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>src/main/sql</directory>
<outputDirectory>sql</outputDirectory>
<lineEnding>unix</lineEnding>
<fileMode>644</fileMode>
</fileSet>
<fileSet>
<directory>src/main/www</directory>
<outputDirectory>www</outputDirectory>
<lineEnding>unix</lineEnding>
<fileMode>644</fileMode>
</fileSet>
</fileSets>
</assembly>

View File

@@ -1,282 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008 Google Inc.
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.
-->
<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>gerrit</groupId>
<artifactId>gerrit</artifactId>
<packaging>pom</packaging>
<version>2.0.1-SNAPSHOT</version>
<name>gerrit</name>
<description>Gerrit - Web Based Code Review</description>
<url>http://android.git.kernel.org/?p=tools/gerrit.git</url>
<mailingLists>
<mailingList>
<name>repo-discuss mailing list</name>
<post>repo-discuss@googlegroups.com</post>
</mailingList>
</mailingLists>
<developers>
<developer>
<name>Shawn O. Pearce</name>
<email>sop@google.com</email>
<roles>
<role>Maintainer</role>
</roles>
</developer>
</developers>
<licenses>
<license>
<name>Apache License, 2.0</name>
<comments>
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
</comments>
</license>
</licenses>
<modules>
<module>../devdb</module>
<module>../appjar</module>
<module>../appwar</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>distribution.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,82 +0,0 @@
#!/bin/sh
#
# Copyright 2008 Google Inc.
#
# 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.
if [ -z "$GERRIT2_HOME" ]
then
GERRIT2_HOME=`which $0 2>/dev/null`
GERRIT2_HOME=`dirname $GERRIT2_HOME`
GERRIT2_HOME=`dirname $GERRIT2_HOME`
fi
if [ -z "$GERRIT2_HOME" ]
then
echo >&2 "error: GERRIT2_HOME not set, cannot guess"
exit 1
fi
if [ -z "$GERRIT2_JAVA" ]
then
GERRIT2_JAVA=java
fi
config_dir=
case "$1" in
--config=*)
config_dir=`echo "$1" | sed s/^--config=//`
if ! [ -f "$config_dir" ]
then
echo >&2 "error: $config_dir not found"
exit 1
fi
case "$config_dir" in
*/GerritServer.properties)
config_dir=`dirname "$config_dir"`
shift
;;
*)
echo >&2 "error: --config must point to GerritServer.properties"
exit 1
;;
esac
;;
esac
if [ -z "$config_dir" ] || [ $# = 0 ]
then
echo >&2 "usage: $0 --config=gs.prop AppName [args]"
exit 1
fi
app=$1
shift
CLASSPATH=$config_dir
for j in $GERRIT2_HOME/lib/*.jar $GERRIT2_HOME/jdbc/*.jar
do
if [ -f "$j" ]
then
if [ -z "$CLASSPATH" ]
then
CLASSPATH=$j
else
CLASSPATH=$CLASSPATH:$j
fi
fi
done
export CLASSPATH
umask 0022
exec $GERRIT2_JAVA com.google.gerrit.pgm.$app "$@"

1
appjar/.gitignore vendored
View File

@@ -2,6 +2,7 @@
/.classpath
/.project
/.settings/org.maven.ide.eclipse.prefs
/src/main/java/GerritServer.properties
/src/main/java/com/google/gerrit/client/GerritVersion.properties
/src/main/java/com/google/gerrit/client/GerritVersion_*.properties
/gwt_www

View File

@@ -23,5 +23,5 @@
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-out gwt_www com.google.gerrit.Gerrit/Gerrit.html"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit-appjar"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M -DGerritServer=${resource_loc:/gerrit-appjar/src/main/java/GerritServer.properties}"/>
</launchConfiguration>

View File

@@ -24,5 +24,5 @@
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-out gwt_www com.google.gerrit.Gerrit/Gerrit.html"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit-appjar"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M -XstartOnFirstThread"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M -XstartOnFirstThread -DGerritServer=${resource_loc:/gerrit-appjar/src/main/java/GerritServer.properties}"/>
</launchConfiguration>

View File

@@ -20,7 +20,7 @@ limitations under the License.
<modelVersion>4.0.0</modelVersion>
<groupId>gerrit</groupId>
<artifactId>gerrit-appjar</artifactId>
<packaging>jar</packaging>
<packaging>war</packaging>
<version>2.0.1-SNAPSHOT</version>
<name>gerrit-appjar</name>
<description>Gerrit - Web Based Code Review</description>
@@ -280,6 +280,70 @@ limitations under the License.
</configuration>
</plugin>
<plugin>
<groupId>com.totsp.gwt</groupId>
<artifactId>maven-googlewebtoolkit2-plugin</artifactId>
<version>2.0-beta26</version>
<configuration>
<compileTargets>
<value>com.google.gerrit.Gerrit</value>
</compileTargets>
<runTarget>com.google.gerrit.Gerrit/Gerrit.html</runTarget>
<noServer>false</noServer>
<extraJvmArgs>-Xmx512m</extraJvmArgs>
<gwtVersion>${gwtVersion}</gwtVersion>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
<archiveClasses>true</archiveClasses>
<archive>
<manifest>
<mainClass>ExecutableWarMain</mainClass>
</manifest>
<manifestEntries>
<Executable-War-Package>com.google.gerrit.pgm</Executable-War-Package>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>make-executable</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>gerrit</groupId>
<artifactId>executablewar</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/executablewar</outputDirectory>
<includes>**/*.class</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
@@ -300,19 +364,53 @@ limitations under the License.
<goal>run</goal>
</goals>
</execution>
<execution>
<id>fix-output</id>
<phase>process-classes</phase>
<configuration>
<tasks>
<property name="d" location="${basedir}/target/${project.name}-${project.version}"/>
<copy todir="${d}">
<fileset dir="${basedir}/target/executablewar" includes="**/*"/>
</copy>
<copy todir="${d}/WEB-INF/extra">
<fileset dir="${basedir}/src/main/java">
<include name="GerritServer.properties_example"/>
</fileset>
</copy>
<move todir="${d}">
<fileset dir="${d}/com.google.gerrit.Gerrit">
<exclude name="Gerrit.html" />
<exclude name="SetCookie.html" />
<exclude name="hosted.html" />
</fileset>
</move>
<delete dir="${d}/com.google.gerrit.Gerrit" />
<apply executable="gzip" addsourcefile="false">
<arg value="-9"/>
<fileset dir="${d}"
includes="**/*.html,**/*.css"/>
<redirector>
<inputmapper type="glob" from="*" to="${d}/*"/>
<outputmapper type="glob" from="*" to="${d}/*.gz"/>
</redirector>
</apply>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>gerrit</groupId>
<artifactId>gerrit-devdb</artifactId>
<version>2.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>gwtorm</groupId>
<artifactId>gwtorm</artifactId>
@@ -327,6 +425,13 @@ limitations under the License.
<scope>compile</scope>
</dependency>
<dependency>
<groupId>gerrit</groupId>
<artifactId>executablewar</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dyuproject</groupId>
<artifactId>dyuproject-openid</artifactId>
@@ -369,6 +474,27 @@ limitations under the License.
<scope>compile</scope>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-603.jdbc3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.1.106</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
<scope>runtime</scope>
</dependency>
<!-- GWT -->
<dependency>
<groupId>com.google.gwt</groupId>

View File

@@ -0,0 +1,60 @@
// Copyright 2009 Google Inc.
//
// 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.
package com.google.gerrit.pgm;
import com.google.gerrit.client.GerritVersion;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/** Display the version of Gerrit. */
public class Version {
private static String version;
public static String getVersion() {
if (version == null) {
final Properties p = new Properties();
final InputStream in =
GerritVersion.class.getResourceAsStream(GerritVersion.class
.getSimpleName()
+ ".properties");
if (in == null) {
return null;
}
try {
try {
p.load(in);
} finally {
in.close();
}
version = p.getProperty("version");
} catch (IOException e) {
return null;
}
}
return version;
}
public static void main(final String[] argv) {
final String v = getVersion();
if (v == null) {
System.err.println("fatal: version unavailable");
System.exit(1);
}
System.out.println("gerrit version " + v);
}
}

View File

@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
import org.spearce.jgit.lib.PersonIdent;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
@@ -147,36 +148,34 @@ public class GerritServer {
private Database<ReviewDb> createDatabase() throws OrmException {
final String dsName = "java:comp/env/jdbc/ReviewDb";
final String pName = "GerritServer.properties";
DataSource ds;
try {
ds = (DataSource) new InitialContext().lookup(dsName);
} catch (NamingException namingErr) {
final Properties p = readGerritDataSource(pName);
final Properties p = readGerritDataSource();
if (p == null) {
throw new OrmException("No DataSource " + dsName + " and no " + pName
+ " in CLASSPATH. GerritServer requires either format.", namingErr);
throw new OrmException("Initialization error:\n" + " * No DataSource "
+ dsName + "\n" + " * No -DGerritServer=GerritServer.properties"
+ " on Java command line", namingErr);
}
try {
ds = new SimpleDataSource(p);
} catch (SQLException se) {
throw new OrmException("Database in " + pName + " unavailable", se);
throw new OrmException("Database unavailable", se);
}
}
return new Database<ReviewDb>(ds, ReviewDb.class);
}
private Properties readGerritDataSource(final String name)
throws OrmException {
private Properties readGerritDataSource() throws OrmException {
final Properties srvprop = new Properties();
final InputStream in;
in = getClass().getClassLoader().getResourceAsStream(name);
if (in == null) {
return null;
String name = System.getProperty("GerritServer");
if (name == null) {
name = "GerritServer.properties";
}
try {
final InputStream in = new FileInputStream(name);
try {
srvprop.load(in);
} finally {

View File

@@ -8,3 +8,8 @@ log4j.appender.stderr.layout.ConversionPattern=%d::%-5p: %c %x - %m%n
#
log4j.logger.org.apache.sshd.common=WARN
log4j.logger.org.apache.sshd.server=WARN
# Silence non-critical messages from c3p0 (if used).
#
log4j.logger.com.mchange.v2.c3p0=WARN
log4j.logger.com.mchange.v2.resourcepool=WARN

5
appwar/.gitignore vendored
View File

@@ -1,5 +0,0 @@
/target
/.classpath
/.project
/.settings/org.maven.ide.eclipse.prefs
/.settings/org.eclipse.jdt.core.prefs

View File

@@ -1,343 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008 Google Inc.
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.
-->
<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>gerrit</groupId>
<artifactId>gerrit-appwar</artifactId>
<packaging>war</packaging>
<version>2.0.1-SNAPSHOT</version>
<name>gerrit-appwar</name>
<description>Gerrit - Web Based Code Review</description>
<url>http://android.git.kernel.org/?p=tools/gerrit.git</url>
<mailingLists>
<mailingList>
<name>repo-discuss mailing list</name>
<post>repo-discuss@googlegroups.com</post>
</mailingList>
</mailingLists>
<developers>
<developer>
<name>Shawn O. Pearce</name>
<email>sop@google.com</email>
<roles>
<role>Maintainer</role>
</roles>
</developer>
</developers>
<licenses>
<license>
<name>Apache License, 2.0</name>
<comments>
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
</comments>
</license>
</licenses>
<properties>
<gwtVersion>1.5.3</gwtVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.totsp.gwt</groupId>
<artifactId>maven-googlewebtoolkit2-plugin</artifactId>
<version>2.0-beta26</version>
<configuration>
<compileTargets>
<value>com.google.gerrit.Gerrit</value>
</compileTargets>
<runTarget>com.google.gerrit.Gerrit/Gerrit.html</runTarget>
<noServer>false</noServer>
<extraJvmArgs>-Xmx512m</extraJvmArgs>
<gwtVersion>${gwtVersion}</gwtVersion>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>fixOutput</id>
<phase>process-classes</phase>
<configuration>
<tasks>
<property name="d" location="${basedir}/target/${project.name}-${project.version}"/>
<move todir="${d}">
<fileset dir="${d}/com.google.gerrit.Gerrit">
<exclude name="Gerrit.html" />
<exclude name="SetCookie.html" />
<exclude name="hosted.html" />
</fileset>
</move>
<delete dir="${d}/com.google.gerrit.Gerrit" />
<apply executable="gzip" addsourcefile="false">
<arg value="-9"/>
<fileset dir="${d}"
includes="**/*.html,**/*.css"/>
<redirector>
<inputmapper type="glob" from="*" to="${d}/*"/>
<outputmapper type="glob" from="*" to="${d}/*.gz"/>
</redirector>
</apply>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>gerrit</groupId>
<artifactId>gerrit-appjar</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>gwt-maven-plugins</id>
<url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url>
</pluginRepository>
</pluginRepositories>
</project>

5
devdb/.gitignore vendored
View File

@@ -1,5 +0,0 @@
/target
/.classpath
/.project
/.settings
/src/main/config/GerritServer.properties

View File

@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008 Google Inc.
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.
-->
<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>gerrit</groupId>
<artifactId>gerrit-devdb</artifactId>
<packaging>jar</packaging>
<version>2.0.1-SNAPSHOT</version>
<name>gerrit-devdb</name>
<description>Gerrit - Hosted Mode Debugging Support</description>
<url>http://android.git.kernel.org/?p=tools/gerrit.git</url>
<build>
<testResources>
<testResource>
<directory>src/main/config</directory>
<includes>
<include>GerritServer.properties</include>
</includes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-603.jdbc3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.1.106</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>

View File

@@ -22,15 +22,14 @@ fi
dstdb=reviewdb
user=gerrit2
gscfg=devdb/src/main/config/GerritServer.properties
if [ -z "$nobuild" ]
then
(cd appdist && mvn install) || exit
(cd appjar && mvn package) || exit
fi
out=$(cd appdist/target/gerrit-*-bin.dir/gerrit-* && pwd)
g2="$out/bin/gerrit2.sh --config=$gscfg"
out=appjar/target/gerrit-*.war
g2="java -jar $out"
dropdb $dstdb
createdb -E UTF-8 -O $user $dstdb || exit
@@ -44,7 +43,7 @@ psql -f devutil/import_gerrit1_b.sql $dstdb || exit
echo >&2
echo >&2 "Creating secondary indexes..."
echo >&2 " ignore failures unless on a production system"
psql -f $out/sql/query_index.sql $dstdb
$g2 --cat sql/query_index.sql | psql $dstdb
echo >&2
psql -c 'DROP SCHEMA gerrit1 CASCADE' $dstdb

View File

@@ -3,10 +3,9 @@
# Builds and deploys into Jetty; primarily for debugging
jetty=$1
fast=$2
if [ -z "$jetty" ]
then
echo >&2 "usage: $0 jettydir [--fast]"
echo >&2 "usage: $0 jettydir"
exit 1
fi
if ! [ -f "$jetty/etc/jetty.xml" ]
@@ -17,30 +16,22 @@ fi
ctx="$jetty/contexts/gerrit.xml" &&
if [ -f "$ctx" -a -n "$fast" ]
(cd appjar && mvn package) &&
war=appjar/target/gerrit-*.war &&
cp $war "$jetty/webapps/gerrit.war" &&
if [ -f "$ctx" ]
then
echo >&2 "warning: Using fast mode to build only GWT..."
echo >&2
(cd appjar && mvn install) &&
(cd appwar && mvn package) &&
cp appwar/target/gerrit-*.war "$jetty/webapps/gerrit.war" &&
touch "$ctx"
else
(cd appdist && mvn clean install) &&
out=$(cd appdist/target/gerrit-*-bin.dir/gerrit-* && pwd) &&
for f in postgresql-8.3-603.jdbc3.jar c3p0-0.9.1.2.jar
do
$war --cat lib/$f >"$jetty/lib/plus/$f"
done
cp $out/www/gerrit-*.war "$jetty/webapps/gerrit.war" &&
if [ -f "$ctx" ]
then
touch "$ctx"
else
cp $out/jdbc/c3p0-*.jar "$jetty/lib/plus" &&
cp $out/jdbc/postgresql-*jdbc*.jar "$jetty/lib/plus" &&
rm -f "$jetty/contexts/test.xml" &&
$war --cat extra/jetty_gerrit.xml >"$ctx" &&
rm -f "$jetty/contexts/test.xml" &&
cp $out/www/jetty_gerrit.xml "$ctx" &&
echo >&2 &&
echo >&2 "You need to edit and configure $ctx"
fi
echo >&2 &&
echo >&2 "You need to edit and configure $ctx"
fi