25 Commits

Author SHA1 Message Date
David Ostrovsky
aceab96289 Remove internal Eclipse java formatter
This is a preparation change to support gjf Eclipse plugin.

Change-Id: I5ea3946c87f64f37087952f31e509832822dd60f
2017-02-10 09:20:15 +00:00
David Ostrovsky
3931c16bdb Build with Java 8
Change-Id: I06f811fc46a606b719582c0724e8d0c89e823b37
2016-09-20 10:19:52 +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
9cc6f03a53 Eclipse: Update default compiler settings from Mars.1 Release (4.5.1)
Making a no-op change to the settings and then saving causes the
preferences file to be updated with defaults from the newer version.

Change-Id: I5c321ce1196af9a328d6f97c69c23686e57cd464
2016-02-24 13:26:35 +00:00
David Pursehouse
0b7517a06e Eclipse: Warn on incomplete switch cases even when default exists
We already have the warning "Incomplete 'switch' cases on enum" enabled,
but it does not warn when a case is missing if the switch has a default
block.

Enable the "Signal even if 'default' case exists" option. This would
have enabled us to catch the problem that was fixed in Ied8ff0f8f.

In most instances of the warning we can simply add the missing case(s)
above the 'default', meaning there is no change in behaviour.

However there are some instances where the missing case is a bug and
should be handled correctly. These are fixed separately in follow-up
commits.

Change-Id: I3675d29981423043266a26b1a78932c5708a6272
2016-01-22 15:14:56 +09:00
David Pursehouse
7a7dffedd1 Update Eclipse code formatter settings
Automatically updated by Eclipse Mars.

Change-Id: I0113fc4cfc7acd629df65591c174399dfd335629
2015-08-31 07:03:36 +00:00
David Pursehouse
5e615fcc4f Enable Eclipse warning 'resource not managed via try-with-resource'
Change-Id: I5a03c7c6152223735aa50b8c096bc5220b574594
2015-08-27 18:01:01 +09:00
Dave Borowitz
450b7d5cde Enable Eclipse Javadoc warnings about malformed syntax
Fix warnings about unmatched {} in inline tags.

Enabling any more than this set of warnings introduces hundreds of
warnings about things like missing @throws tags, which we may want to
fix, but is a lot more work.

Change-Id: Ic671fb600d2e1ba49b7e855158811c6c98b6cda1
2015-06-13 12:52:20 +00:00
Dave Borowitz
eac3acc3e0 Update import order settings to list all top-level packages
Eclipse installations disagree about where to put unmatched top-level
packages. Settle this ambiguity by listing all top-level packages used
by Gerrit. Also explicitly include unmatched static imports.

The import order thus listed corresponds to the Google Java Style
Guide:

https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s3.3.3-import-ordering-and-spacing

Organize all imports to reflect the new reality.

Change-Id: I7c541b1c522e66869669d2291dcf78ff1d8784d0
2015-03-25 20:36:56 +00:00
David Pursehouse
2fbf716c54 Update FindBugs configuration
New settings introduced with upgrade to version 3.0.1.20150306-5afe4d1
of the FindBugs plugin for Eclipse.

Change-Id: I42e9dd32e4e8a74c5bb994166fc0f5357ea04dd2
2015-03-20 14:29:25 +00:00
David Pursehouse
f4d0ad1197 Add FindBugs settings
Generated with FindBugs plugin version 3.0.0.20140706-2cfb468

Change-Id: I7487645d9db208298b3a1c3cb7b939fba6365412
2015-03-19 03:14:09 +00:00
David Pursehouse
9bbffa71b3 RFC: Enable Eclipse warning about fall-through cases in switch statements
Enable the "'switch' case fall-through" warning in Eclipse to catch
unintentional fall-through to the following 'case' block when a 'break'
statement is omitted.

All warnings raised in the current codebase are caused by intentional
fall-throughs, so add "//$FALL-THROUGH$" comments to suppress those
warnings.

This change was inspired by the coverity report [1] which found the
problem in PutConfig (see CID 19880) but interestingly did not report
anything for the other ones.

RFC because I'm not sure if the "//$FALL-THROUGH$" comments will cause
the warnings to be suppressed on subsequent coverity scans.

[1] https://scan.coverity.com/projects/4032

Change-Id: Iad003bd7d086c67cccdbfb1312c8bd82d17fcc57
2015-02-03 12:17:49 +09:00
Dave Borowitz
08180de4de Support AutoValue
AutoValue[1] is a lightweight annotation-processor-based library for
implementing classes with simple, obvious value semantics.

Add support for AutoValue to build rules and Eclipse project
generation. Buck does not currently have an officially-supported
interface for specifying annotation processor dependencies[2], so we
have to take the slightly ugly approach of monkey-patching
java_library and java_test to add annotation processor arguments to
each rule that requires annotation processing; hopefully this ugliness
can be reduced in the future.

[1] https://github.com/google/auto/tree/master/value
[2] https://github.com/facebook/buck/issues/85

Change-Id: I8b49d6f9f25d61688b667d964848c6ce106ae4ec
2014-11-08 08:31:08 -08:00
David Pursehouse
7a05f9f6a8 Enable and fix more Eclipse warnings
Enable and fix warnings:

- Missing `hashCode` method on classes that define `equals`
- Redundant null check

Also enable "possible accidental boolean assignment" warning.  There
are currently no instances of this but it might be useful to enable.

Change-Id: I7659ae66bedb6a17e088c90d2165282b7fe33695
2014-11-04 10:07:19 +09:00
David Pursehouse
41abb376ca Enable and fix Eclipse warnings about redundant type arguments
Since Java 7 it is possible to replace the type arguments required to
invoke the constructor of a generic class with an empty set of type
parameters (<>) as long as the compiler can infer the type arguments
from the context [1].

Enable the Eclipse warning about redundant type arguments, and remove
the ones it warns about.

[1] http://goo.gl/SG21kM

Change-Id: I422882949a6a6a57391580d881f73120b2843a0e
2014-10-31 08:27:01 +00:00
Dave Borowitz
e78f3bb48a Add some more warnings to the Eclipse preferences
These don't introduce any new warnings, but are automatically added
every time I click "Apply" in the errors/warnings project properties,
so add them to reduce churn.

Change-Id: Ie42de594ba0f33d4e66cca97bb05e04e5b2a1dfc
2014-10-30 11:45:47 -07:00
Dave Borowitz
54df81ff93 Enable warnings for missing @Override annotations
Somehow between turning this on and submitting I743917787 I managed to
turn this back off.

Suppress this warning in an instance where a new interface method was
added in Servlet API 3.0, as the code needs to continue to compile
against earlier versions. Unfortunately Eclipse does not give us a
more specific suppression token than "all", but in this case the
method body is small enough we're probably not missing anything.

Change-Id: I78ecf82f6cd4042417c9f3b1f6a4b473d29182d9
2014-10-30 11:43:01 -07:00
Dave Borowitz
8b42ec5bd5 Turn on many more Eclipse warnings, and fix them
- Warn on empty statements, e.g. "for (;;);". These may be
   typos and are easily replaced by "for (;;) {}" which is more
   explicit.
 - Warn on field hiding. This allows cleanup of many acceptance test
   members, at the cost of a couple of renames and the occasional
   suppression (when the field is in a public nested enum that shadows
   a public constant).
 - Warn on unnecessary casts.
 - Warn on unused declared thrown exceptions. In addition to reducing
   method signature length and number of imports, this also eliminated
   some impossible catch blocks.
 - Warn on missing @Override annotations.
 - Warn on unused parameters. This is likely the most controversial,
   as a few relatively common patterns require unused parameters in a
   way that Eclipse can't ignore. However, it also resulted in cleanup
   of a lot of unnecessary injections and method parameters, so I
   think the cost was worth it.

Change-Id: I7224be8b1c798613a127c88507e8cce400679e5d
2014-10-29 15:00:17 -07:00
David Ostrovsky
a791cc4fdc Eclipse: Bump java source and target level to 7
Change-Id: I53aea923c09d80aeff16726bab736ab74976fcdf
2013-11-29 00:15:50 +01:00
David Pursehouse
fcc910b6a3 Suppress Eclipse warning "annotation should not be used as a superinterface"
This warning was suppressed on subprojects with commit f1264f4, but that
is no longer effective with the new Eclipse project structure after the
buck build was integrated.

Now we suppress the warning on the top level project.

Change-Id: I0e9a22a62d9950d2c364b48aa76cf914a185aafd
2013-05-10 10:31:19 -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 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
Shawn O. Pearce
5775075e37 Configure Eclipse projects to cleanup trailing whitespace on save
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-29 11:32:25 -07:00
Shawn O. Pearce
0da2b72506 Start targeting Java 1.6
gwtjsonrpc 1.1 and later is targeted for Java 1.6 source and bytecode,
so we might as well start doing the same here in Gerrit before we move
to the 1.1 code line.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-05-13 12:02:24 -07:00
Shawn O. Pearce
263786e2fd Move appjar contents up one level to normalize our structure
In general we map one Maven project description to one Git
repository, as each Maven project has its own unique version
number for its artifact.

This change pulls everything up one level so its a much more
typical directory layout, where the pom.xml is at the root
of the directory structure.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-02-02 16:04:52 -08:00