blob: 52c9192a4cda4ecfd49bafb507aa42c38a3c996f [file] [log] [blame] [view]
David Pursehoused45b0f82016-08-25 09:37:29 +09001# Developer Guide
2
3[TOC]
4
5## Building
6
David Ostrovskybf2c3912016-11-21 01:37:28 +01007Gitiles requires [Bazel](https://bazel.build/) to build.
8
Ian McKellar1bda1c22017-07-24 15:23:40 -07009You need to use Java for building Gitiles. You can install Bazel from
10bazel.build: https://bazel.build/versions/master/docs/install.html
David Pursehoused45b0f82016-08-25 09:37:29 +090011
12```
ev1stensberg966c93a2018-09-26 10:56:49 +020013 bazel build //:gitiles
David Ostrovskybf2c3912016-11-21 01:37:28 +010014 bazel test //...
David Pursehoused45b0f82016-08-25 09:37:29 +090015```
16
17
ev1stensberg966c93a2018-09-26 10:56:49 +020018## Running Locally and Testing
David Pursehoused45b0f82016-08-25 09:37:29 +090019
20```
21cd /path/to/repositories # Don't run from the gitiles repo.
22/path/to/gitiles/tools/run_dev.sh
23```
24
25This will recompile and start a development server. Open
26http://localhost:8080/ to view your local copy of gitiles, which
27will serve any repositories under `/path/to/repositories`.
28
David Ostrovskybf2c3912016-11-21 01:37:28 +010029To run unit tests, run `bazel test ...`.
David Pursehoused45b0f82016-08-25 09:37:29 +090030
31
32## Eclipse IDE
33
34If you'd like to use Eclipse to edit Gitiles, first generate a project file:
35
36```
David Ostrovskybf2c3912016-11-21 01:37:28 +010037tools/eclipse/project.sh
David Pursehoused45b0f82016-08-25 09:37:29 +090038```
39
40Import the project in Eclipse:
41
42```
43File -> Import -> Existing Projects into Workpace
44```
45
46The project only needs to be rebuilt if the source roots or third-party
47libraries have changed. For best results, ensure the project is closed in
48Eclipse before rebuilding.
49
Saša Živkov83d066f2016-10-05 16:00:32 +020050## Running/Debugging from Eclipse IDE
51
52Running Gitiles from Eclipse requires setting the
53`com.google.gitiles.sourcePath` system property. The property value has to be
54the root folder of the Gitiles source code, for example:
55
56````
57-Dcom.google.gitiles.sourcePath=/home/johndoe/git/gitiles
58````
David Pursehoused45b0f82016-08-25 09:37:29 +090059
60## Code Style
61
62Java code in Gitiles follows the [Google Java Style Guide][java-style]
63with a 100-column limit.
64
65Code should be automatically formatted using [google-java-format][fmt]
66prior to sending a code review. There is currently no Eclipse
67formatter, but the tool can be run from the command line:
68
69```
David Pursehousef35521a2018-09-27 17:05:08 +090070java -jar /path/to/google-java-format.jar -i path/to/java/File.java
David Pursehoused45b0f82016-08-25 09:37:29 +090071```
72
73CSS in Gitiles follows the [SUIT CSS naming conventions][suit].
74
75[java-style]: https://google.github.io/styleguide/javaguide.html
76[fmt]: https://github.com/google/google-java-format
77[suit]: https://github.com/suitcss/suit/blob/master/doc/naming-conventions.md
78
79## Code Review
80
81Gitiles uses Gerrit for code review:
82https://gerrit-review.googlesource.com/
83
84Gitiles uses the ["git push" workflow][1] with server
85https://gerrit.googlesource.com/gitiles. You will need a
86[generated cookie][2].
87
88[1]: https://gerrit-review.googlesource.com/Documentation/user-upload.html#_git_push
89[2]: https://gerrit.googlesource.com/new-password
90
91Gerrit depends on "Change-Id" annotations in your commit message.
92If you try to push a commit without one, it will explain how to
93install the proper git-hook:
94
95```
96curl -Lo `git rev-parse --git-dir`/hooks/commit-msg \
97 https://gerrit-review.googlesource.com/tools/hooks/commit-msg
98chmod +x `git rev-parse --git-dir`/hooks/commit-msg
99```
100
101Before you create your local commit (which you'll push to Gerrit)
102you will need to set your email to match your Gerrit account:
103
104```
105git config --local --add user.email [email protected]
106```
107
108Normally you will create code reviews by pushing for master:
109
110```
111git push origin HEAD:refs/for/master
112```
Dave Borowitz004c6c02017-08-28 14:36:28 -0400113
114## Releases
115
116Gitiles artifacts are published to the [gerrit-maven
117bucket](http://gerrit-maven.storage.googleapis.com/). To release a new version,
118you must have write access to this bucket.
119
120First, increment `GITILES_VERSION` in `version.bzl`. Technically, Gitiles uses
121the
122["build number" scheme](http://mojo.codehaus.org/versions-maven-plugin/version-rules.html),
123which in practice just means incrementing the last component (after the `-`) by
124one. Get your change reviewed and submitted.
125
126Then, run:
127
128```
129./tools/maven/mvn.sh deploy
130```
131
David Pursehousee34a28c2017-08-29 08:47:11 +0900132Tag the release with an annotated tag matching the version number.
133
Dave Borowitz004c6c02017-08-28 14:36:28 -0400134Once released, Maven projects can consume the new version as long as they point
135at the proper repository URL. Similarly, Bazel projects using the `maven_jar`
136bazlet can use the new version with `repository = GERRIT`.