49 Commits

Author SHA1 Message Date
Dave Borowitz
292fa154c1 Format all Java files with google-java-format
Having a standard tool for formatting saves reviewers' valuable time.
google-java-format is Google's standard formatter and is somewhat
inspired by gofmt[1]. This commit formats everything using
google-java-format version 1.2.

The downside of this one-off formatting is breaking blame. This can be
somewhat hacked around with a tool like git-hyper-blame[2], but it's
definitely not optimal until/unless this kind of feature makes its way
to git core.

Not in this change:
* Tool support, e.g. Eclipse. The command must be run manually [3].
* Documentation of best practice, e.g. new 100-column default.

[1] https://talks.golang.org/2015/gofmt-en.slide#3
[2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html
[3] git ls-files | grep java$ | xargs google-java-format -i

Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
2017-02-07 10:04:39 +09:00
David Ostrovsky
fdbfcad77d Remove Buck based build
Bug: Issue 5302
Change-Id: I6e860446ef30ff0ad1c7c49fc0e39d39d921820b
2017-01-23 12:44:58 +00:00
David Ostrovsky
92416412f8 gerrit-main: Bump to Java 1.8
This is a preparation change to activate Error Prone for Buck driven
build. This fix is needed, otherwise the compilation is failing with:

  Source option 1.2 is no longer supported. Use 1.6 or later.
  Target option 1.2 is no longer supported. Use 1.6 or later.

Change-Id: I1ef45eee87dec788522873cabe4612bf7ac2ef5b
2016-12-12 05:36:37 +00:00
David Ostrovsky
fa18907d7f Bazel: Reformat build files
Reformat the Bazel build files with the buildifier tool [1].

The style is different for Bazel files. Most notably, indentation level
is 4 spaces instead of 2, and " is used instead of '.

[1] https://github.com/bazelbuild/buildifier

Change-Id: I95c0c6f11b6d76572797853b4ebb5cee5ebd3c98
2016-12-07 11:33:07 +00:00
David Ostrovsky
071060903b Merge changes from topic 'bazel-build'
* changes:
  Bazel: Build gerrit WAR with GWT UI
  Bazel: Build GWT UI
  Implement Bazel build for gerrit-gwtui project
  Implement Bazel build for codemirror library
  Bazel: Produce headless war
  Implement Bazel build for gerrit-war project
  Implement Bazel build for gerrit-main project
  Bazel: add java_doc rule
  Bazel: Create sources for plugin API
2016-09-20 11:57:48 +00:00
David Ostrovsky
3931c16bdb Build with Java 8
Change-Id: I06f811fc46a606b719582c0724e8d0c89e823b37
2016-09-20 10:19:52 +02:00
David Ostrovsky
2ae12283b3 Implement Bazel build for gerrit-main project
Change-Id: Ic4ed364306ff9225d0e24c0141997a3d5046b2d3
2016-09-19 16:57:25 +02:00
David Pursehouse
323247227d Enable and fix 'Statement unnecessarily nested within else clause' warnings
Change-Id: Ida6df4593fc2ab3c11581309b2b4a638229ea093
2016-06-02 10:20:37 +09:00
David Pursehouse
d70fc02a99 Replace C-style array declarations with Java-style declarations
int[] array;

instead of

  int array[];

Change-Id: I4fb02ac0bcdff75ec094ba61b36d40097a4e25b9
2015-03-19 12:15:43 +09:00
Shawn Pearce
ab21a266b1 Build Main for Java 1.2
This tiny class uses a very ancient and limited API so it runs on any
JVM. Its entire purpose is to check the minimum Java version, fail if
it is too low, otherwise jump into the real class in another package.

The Maven build used to create this class for Java 1.2, so it would be
helpful to users attempting to launch Gerrit on the wrong JVM. That flag
was lost when the build moved to Buck.

Reset the source and target level to 1.2 so the warning message might
be useful again, especially during the jump from Java 6 to Java 7.

Change-Id: I9187e13ee67c9c482a8e11296649fcf712e5aad1
2013-11-30 01:53:00 -08:00
Shawn Pearce
72fb6cc514 Remove unused .gitignore
These were necessary only for the Maven based build.

Change-Id: Ie26669e6ccae60a52d2db1b8ad362e2fa88a26f2
2013-11-28 22:56:51 -08:00
David Ostrovsky
c53fd3ae49 Delete eclipse left-over files from the Maven poop era
Change-Id: Ie3a75e8c6a2d274cd39e362259ab20cff474eb8d
2013-11-28 22:55:09 -08:00
David Ostrovsky
00d636b0f3 Add startup check for Java 7
Change-Id: I0ebcc126b46d0c948c1d249188bf95f0a8564c9e
2013-11-26 19:56:52 -08:00
David Ostrovsky
dcee57212f Delete Maven based build
The Maven build does not work since the introduction of CodeMirror.
Remove the build until to prevent people from trying to use a broken
build process.  If buck is rejected this commit will be reverted, and
we will attempt to fix the Maven build to include CodeMirror.  If buck
is accepted, we just saved time by avoiding a messy Maven change.

Change-Id: I147d8d1741d52f59de1d2ddce8e5e82583990c14
2013-05-21 20:28:56 -07:00
Shawn Pearce
82e66ee4e5 Move Eclipse related stuff into tools/eclipse
Try to reduce the size of the top-level BUCK file by moving
anything that has to do with Eclipse project generation and
classpath management into tools/eclipse.

Change-Id: Id779eaff4fe732908b28a8e3441004e364b59e21
2013-05-10 12:42:54 -07:00
Shawn Pearce
fd6bb9f6a5 Build with Buck
Implement a new build system using Buck[1], Facebook's
open source clone of Google's internal build system.

  Pros:
  - Concise build language
  - Test and build output is concise
  - Test failures and stack traces show on terminal
  - Reliable incrementals; clean is unnecessary
  - Extensible with simple blocks of Python
  - Fast
      buck: clean: 0.452s, full 1m21.083s [*], no-op:  7.145s,
      mvn:  clean: 4.596s, full 2m53.776s,     no-op: 59.108s,

      [*] full build includes downloading all dependencies,
          time can vary due to remote server performance.

  Cons:
  - No Windows support
  - No native Maven Central support (added by macros)
  - No native GWT, Prolog, or WAR support (added by macros)
  - Bootstrap of buck requires Ant

Getting started:

  git clone https://gerrit.googlesource.com/buck
  cd buck
  ant

  Mac OS X:
    PATH="`pwd`/bin:/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands:$PATH"

  Linux:
    PATH="`pwd`/bin:$PATH"

Importing into Eclipse:

  $ time buck build :eclipse
  0m48.949s

  Import existing project from `pwd`
  Import 'gerrit' (do not import other Maven based projects)
  Expand 'gerrit'
  Right click 'buck-out' > Properties
  Under Attributes check 'Derived'

  If the code doesn't currently compile but an updated classpath
  is needed, refresh the configs and obtain missing JARs:

  $ buck build :eclipse_project :download

Running JUnit tests:

  $ time buck test --all -e slow  # skip slow tests
  0m19.320s

  $ time buck test --all          # includes acceptance tests
  5m17.517s

Building WAR:

  $ buck build :gerrit
  $ java -jar buck-out/gen/gerrit.war

Building release:

  $ buck test --all && buck build :api :release
  $ java -jar buck-out/gen/release.war
  $ ls -lh buck-out/gen/{extension,plugin}-api.jar

Downloading dependencies:

  Dependencies are normally downloaded automatically, but Buck can
  inspect its graph and download missing dependencies so future
  compiles can run without the network:

  $ buck build :download

[1] http://facebook.github.io/buck/

Change-Id: I40853b108bd8e153cefa0896a5280a9a5ff81655
2013-05-09 13:40:36 +00:00
Shawn Pearce
9240c299f0 Begin 2.8
Change-Id: Ie0bc733853be435fba147dd64ef8cbc5a0027ee0
2013-05-06 19:39:10 -07:00
Shawn Pearce
d47ca8a66d Start 2.7 development
Change-Id: I08dc590bb1f62af67d88eb11313d5d4cfe2423c4
2013-03-21 12:12:47 -07:00
Edwin Kempin
20f99685d9 Update versions in pom's to start Gerrit 2.6 development
Change-Id: I4fb8cb41250c5b640a8d9e47caf97dc4670ff428
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-08-22 14:09:52 +02:00
Sasa Zivkov
90119f8256 Remove timestamp from all org.eclipse.core.resources.prefs files.
Eclipse overwrites these files when we import projects using m2e.
Eclipse 3 writes a timestamp at the top of these files making the Git
working tree dirty.  Eclipse 4 (Juno) still overwrites these files but
doesn't write the timestamp.  This should help keeping the working tree
clean.  However, since the timestamp is currently present in these
files, Eclispe 4 would still make them dirty by overwriting and
effectively removing the timestamp.

This change removes the timestamp from these files. This help those
using Eclipse 4 and doesn't make it worse for those still using Eclispe
3.

Change-Id: Ic23299a12ac80f7294bcc602c8565889069a0d10
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2012-07-04 14:06:09 +02:00
Anatol Pomazau
2f12c650ec Add Intellij IDEA files to ignore list
Change-Id: Ie948a1b3c9df95e79fc09ef343d0d49ff3b267c2
2012-05-03 13:17:43 -07:00
Edwin Kempin
daf6bd9865 Update parent version in pom.xml's to 2.5-SNAPSHOT
Change-Id: I3b2f0f532fc10b98657de117c80113fe0eac3bc4
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-05-03 09:49:17 +02:00
Sasa Zivkov
17e17dd8b9 Change version in pom.xml to 2.4-SNAPSHOT
The 2.3 was released and what we have in the master branch
is targeted for 2.4.

Change-Id: Idca8a12aaef1dc5ea5f628b3640881e66f04dc9c
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2012-04-18 12:55:40 +02:00
Martin Fick
7f7eadff20 Update poms to Gerrit 2.3-SNAPSHOT
Change-Id: I6f54a783959c58fb75114251e07a6871bc889904
2012-02-22 17:19:32 -07:00
Mohan Zhang
3a6dbe93c3 Add entries to .gitignore for m2e settings/preference files
Change-Id: Ie70c285440b6200ad7f4dd8dea8a97317e1e62fc
2011-12-12 16:56:53 -06:00
Eric Anderson
a68b89fd53 Updating eclipse settings for 3.7 and m2e 1.0
Change-Id: Ic0f134719769e3d8b8cfb6f70703f9a61fcd2538
2011-07-29 08:29:51 -07:00
Shawn O. Pearce
4e67700dab Change version to 2.2-SNAPSHOT
Change-Id: I1d3e6c42bc678536162a81d2b13372659a1c3dec
Signed-off-by: Shawn O. Pearce <sop@google.com>
2011-05-31 10:30:57 -07:00
Shawn O. Pearce
f855f399f8 Fix all of our pom.xml versions to be 2.1-SNAPSHOT
I meant to keep reusing the 2.1 version number for the entire
2.1 series during development, but botched it during the 2.1.4
development cycle and set it to 2.1.4-SNAPSHOT by mistake.  Put
it back to 2.1-SNAPSHOT since 2.1.4 is released.

Change-Id: I37e206c0609bf3fd94a5aab8ea301c98b7fb013e
Signed-off-by: Shawn O. Pearce <sop@google.com>
2010-08-12 16:24:43 -07:00
Shawn O. Pearce
faee655254 Start 2.1.4 development
Change-Id: I71719c85b0d50707333517b8ef956853b04efa14
Signed-off-by: Shawn O. Pearce <sop@google.com>
2010-06-21 17:41:54 -07:00
Shawn O. Pearce
f51d48c111 gerrit 2.1.3
Change-Id: I93386d5b71e8361219c03d95ab7476dc46e7d6b0
Signed-off-by: Shawn O. Pearce <sop@google.com>
2010-06-21 14:40:34 -07:00
Nico Sallembien
63ecb0f7e6 Fixing Eclipse settings file
Maven auto-fixes it all the time, otherwise.

Change-Id: I17e6acae09747a9282c9e26545f3f8dcf139dc07
2010-01-20 15:17:02 -08:00
Shawn O. Pearce
b150f25480 Be specific about the Maven plugin groupId
Change-Id: I2d170ad046164d62eaf5d50f0cfaacd252a81c1d
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-30 17:19:49 -08:00
Shawn O. Pearce
99cdf558f9 Cleanup Maven build by using common plugin management
Most of our build will want to assume the same version of each
plugin across all components, just like do with our dependencies.

Also, start populating some data into the manifest of each created
JAR file, to better document where the JAR came from.

Change-Id: I38c62949dfb0e14603a31e9045e4ab5f7ca1424b
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-30 17:19:48 -08:00
Shawn O. Pearce
d1a3f68b80 Cleanup Maven build by pushing component dependencies down
Rather than listing all of our build projects in the parent pom,
list them where they are actually required to compile.

Change-Id: I27954f3e4affdaa258ee024c0899f0cacd3f2ae4
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-30 17:19:47 -08:00
Shawn O. Pearce
0e060b257d Start next release development
Change-Id: I5a69e2b7a3e64664f0ca32649d153cb8cde27b27
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-21 13:27:30 -08:00
Shawn O. Pearce
a02df64b0f gerrit 2.1
Change-Id: Ic864f71b0899af24334c76b8558c2757a2f79750
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-21 11:19:02 -08:00
Shawn O. Pearce
6ee0554f27 Teach Main to check the Java runtime version
To run Gerrit Code Review we require Java 6, because our class
files are compiled against the Java 6 SDK, use methods from it,
and are in the Java 6 bytecode file format.  We cannot run on a
JRE that predates the Java 6 specification.

Rather than giving users who are trying to run us on an outdated
virutal machine an obtuse stack trace like the following:

  Exception in thread "main" java.lang.UnsupportedClassVersionError:
      Bad version number in .class file
	at java.lang.ClassLoader.defineClass1(Native Method)
        ...

we should give them a specific message describing the problem,
and our minimum version requirement.

To get a custom error message we compile our Main springboard class
in Java 1.2 format, against only APIs that are available since Java
1.2, and we check the specification of our runtime to verify it can
support us.  This allows us to execute on a really old JRE and at
least report a descriptive error message.

In order to use Java 6 APIs in GerritLauncher we had to move it
to its own Maven component, where the runtime environment is still
described as Java 6.

Change-Id: I47bfcfb5076427d491c896a2815dd091ca205bfc
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-18 15:33:40 -08:00
Shawn O. Pearce
3b279fa8d8 Call the next version 2.1
We've changed so much since the 2.0.24 release that I'm really not
comfortable calling it 2.0.25.

Change-Id: I9cf28b0a97e0f74838bf893b79ce3105e0a7bfdb
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-12 20:17:29 -08:00
Shawn O. Pearce
46ade82099 Get the canonical path to our temporary directory
When we access ~/.gerritcodereview/tmp we might find out that tmp has
actually be symlinked to a different part of the local filesystem,
such as /tmp.  Resolve the link as early as possible during startup so
that if ~/ is on NFS we remove our dependency on the NFS server as
early as possible and won't be impacted later on should it go down.

Change-Id: Ib631add17338c08c55dd84762dc4fd105308d7c2
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-11 17:43:38 -08:00
Shawn O. Pearce
ec4495eb5a daemon: Unpack the WAR contents to a local directory
Jetty can serve a file directly from local disk using low-level APIs
like sendfile(), but only if the file it is reading from is actually
stored on the local filesystem.  Loading it dynamically from a JAR
where its been compressed completely defeats this feature of the
DefaultServlet we are trying to take advantage of.

To enable Jetty's more optimized IO path, we now unpack our WAR
contents to our temporary directory, under the gerrit_war folder.

Change-Id: I7be7c90029720f1664bc35ae2f7ff77e247161df
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-07 15:16:54 -08:00
Shawn O. Pearce
a68b89452f Clean up stale empty temporary directories from prior executions
Some NFS based filesystems seem to have a problem deleting the
temporary directory we create to hold our JARs.  Something on the
NFS server is pegging the directory open until the JVM exits,
which means we may wind up leaving an infinite number of empty
directories in ~/.gerritcodereview/tmp.

This appears to be isolated to certain NFS servers, because my local
/tmp doesn't suffer from the same problem, the temporary directory
is deleted on JVM exit.

We use a simple rule here, any empty directory with a modification
date older than 7 days is assumed to be garbage and removed.
Any directory that is non-empty can be assumed to be a running
daemon, even if it has a modification date of older than 7 days,
and is thus left alone.

Change-Id: I3d4e697863f347e66e5b142e4a7ad8e99a08956d
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-07 14:10:11 -08:00
Shawn O. Pearce
79860d1ddb Default temporary directory to $HOME/.gerritcodereview/tmp
Some operating system distributions include a cron script which
cleans /tmp by unlinking any files not modified in the past 7 days.
This can kill a running Gerrit server by deleting its JAR files,
preventing it from lazily-loading any code after the unlink occurs.

Work around this by unpacking our JARs into a directory below the
user's home directory.  This matches the behavior of Hudson CI,
which also suffered from having their JARs disappear at runtime
due to these automatic /tmp cleaning scripts.

Change-Id: Ia83c65d61310658fc9afd1c663b4b3877c457a3c
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-07 13:58:36 -08:00
Shawn O. Pearce
dc5d1ee12d cat, ls: move inside our main program package
I've never liked having these be special cases.  Lets move them to
the pgm package where they aren't special anymore.

Change-Id: Ib76fd6c7fe806b92ee5658ece4c788e67bcacdbc
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-07 12:51:17 -08:00
Shawn O. Pearce
f0b848506f launcher: Refactor how we return the status code to the shell
Instead of doing a direct System.exit() use return to return the
exit code to the caller, which is the true main method for the
application.  This simplifies the calling strategy considerably.

Change-Id: I3b056579726a56bd9a1ab7186265dc5c5ebeeacc
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-07 12:27:23 -08:00
Shawn O. Pearce
7c5941ba4c Implement query tool on command line and over SSH
This little query tool is primarily intended for use when running an
embedded H2 database where there really is no other way to access the
in-memory files and state.

It is however handy for quick queries against any other database.

Bug: issue 327
Change-Id: I77a96c0833026d432103a16b48ec36f315c352ec
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-11-17 20:47:04 -08:00
Shawn O. Pearce
2fe738b4ad init: Create a command to setup a new Gerrit installation
The init command uses an interactive prompting process to help the
user get a basic website configured.

The --import-projects option will automatically search for and import
any Git repositories which are discovered within gerrit.basePath.

Bug: issue 323
Bug: issue 330
Change-Id: I3d6e8f9f5fea8bfc78f6dfb1fc8f284bebfba670
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-11-17 14:52:07 -08:00
Shawn O. Pearce
f7063bc2ae launcher: Don't print stack trace with reflection frames
We don't really care that the reflection based invocation of a method
failed with an InvocationTargetException, what's really relevant for
us to display is the cause of this exception.

Change-Id: Ifd6332a44c2b19b073c14b73b631210030321889
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-11-13 10:33:09 -08:00
Shawn O. Pearce
8ef01904d1 Launcher: Clarify the purpose of the daemon command
Since we embedded Jetty into our WAR and automatically launch the
web server when our daemon command is invoked its no longer true that
we run only the SSH daemon.  Correct this misleading description.

Change-Id: I440b1b484a43d7e9c6ba57c313fde55762dfc49e
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-11-12 18:39:53 -08:00
Shawn O. Pearce
44671f5c69 Rewrite our build as modular maven components
This refactoring splits the code up into different components, with
their own per-component CLASSPATH.  By moving all of our classes
into isolated components we can better isolate the classpaths and
try to avoid unexpected dependency problems.  It also allows us to
more clearly define which components are used by the GWT UI and
thus must be compiled under GWT, and which components are run on
the server and can therefore use more of the J2SE API.

Change-Id: I833cc22bacc5655d1c9099ed7c2b0e0a5b08855a
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-11-11 16:54:06 -08:00