Merge changes from topic 'kill-bower'
* changes: Daemon: Add flag to force PolyGerrit development mode Add polygerrit.war target to build only PolyGerrit UI Buck: Package PolyGerrit in gerrit.war Vulcanize PolyGerrit in Buck build
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
firefox = //:firefox
|
firefox = //:firefox
|
||||||
gerrit = //:gerrit
|
gerrit = //:gerrit
|
||||||
headless = //:headless
|
headless = //:headless
|
||||||
|
polygerrit = //:polygerrit
|
||||||
release = //:release
|
release = //:release
|
||||||
safari = //:safari
|
safari = //:safari
|
||||||
soyc = //gerrit-gwtui:ui_soyc
|
soyc = //gerrit-gwtui:ui_soyc
|
||||||
|
|||||||
9
BUCK
9
BUCK
@@ -1,10 +1,11 @@
|
|||||||
include_defs('//tools/build.defs')
|
include_defs('//tools/build.defs')
|
||||||
|
|
||||||
gerrit_war(name = 'gerrit')
|
gerrit_war(name = 'gerrit')
|
||||||
gerrit_war(name = 'headless', ui = None)
|
gerrit_war(name = 'headless', ui = None)
|
||||||
gerrit_war(name = 'chrome', ui = 'ui_chrome')
|
gerrit_war(name = 'chrome', ui = 'ui_chrome')
|
||||||
gerrit_war(name = 'firefox', ui = 'ui_firefox')
|
gerrit_war(name = 'firefox', ui = 'ui_firefox')
|
||||||
gerrit_war(name = 'safari', ui = 'ui_safari')
|
gerrit_war(name = 'safari', ui = 'ui_safari')
|
||||||
|
gerrit_war(name = 'polygerrit', ui = 'polygerrit')
|
||||||
gerrit_war(name = 'withdocs', docs = True)
|
gerrit_war(name = 'withdocs', docs = True)
|
||||||
gerrit_war(name = 'release', ui = 'ui_optdbg_r', docs = True, context = ['//plugins:core'], visibility = ['//tools/maven:'])
|
gerrit_war(name = 'release', ui = 'ui_optdbg_r', docs = True, context = ['//plugins:core'], visibility = ['//tools/maven:'])
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ include_defs('//tools/git.defs')
|
|||||||
DOC_DIR = 'Documentation'
|
DOC_DIR = 'Documentation'
|
||||||
|
|
||||||
JSUI_JAVA_DEPS = ['//gerrit-gwtui:ui_module']
|
JSUI_JAVA_DEPS = ['//gerrit-gwtui:ui_module']
|
||||||
JSUI_NON_JAVA_DEPS = ['//polygerrit-ui:polygerrit_components']
|
JSUI_NON_JAVA_DEPS = ['//polygerrit-ui/app:polygerrit_ui']
|
||||||
MAIN_JAVA_DEPS = ['//gerrit-pgm:pgm']
|
MAIN_JAVA_DEPS = ['//gerrit-pgm:pgm']
|
||||||
SRCS = glob(['*.txt'], excludes = ['licenses.txt'])
|
SRCS = glob(['*.txt'], excludes = ['licenses.txt'])
|
||||||
|
|
||||||
|
|||||||
@@ -53,12 +53,6 @@ def parse_graph():
|
|||||||
for target, attrs in obj.iteritems():
|
for target, attrs in obj.iteritems():
|
||||||
for dep in attrs['buck.direct_dependencies']:
|
for dep in attrs['buck.direct_dependencies']:
|
||||||
|
|
||||||
# bower is only used by the build process; skip it in those cases, even if
|
|
||||||
# --partial is not passed.
|
|
||||||
if ((target == '//tools/js:download_bower'
|
|
||||||
or target.startswith('//lib/js:')
|
|
||||||
and dep == '//lib/js:bower')):
|
|
||||||
continue
|
|
||||||
if target in KNOWN_PROVIDED_DEPS:
|
if target in KNOWN_PROVIDED_DEPS:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -19,16 +19,20 @@ import org.eclipse.jgit.lib.Config;
|
|||||||
public class GerritOptions {
|
public class GerritOptions {
|
||||||
private final boolean headless;
|
private final boolean headless;
|
||||||
private final boolean slave;
|
private final boolean slave;
|
||||||
private final boolean polyGerrit;
|
private final boolean enablePolyGerrit;
|
||||||
|
private final boolean forcePolyGerritDev;
|
||||||
|
|
||||||
public GerritOptions(Config cfg, boolean headless, boolean slave) {
|
public GerritOptions(Config cfg, boolean headless, boolean slave,
|
||||||
|
boolean forcePolyGerritDev) {
|
||||||
this.headless = headless;
|
this.headless = headless;
|
||||||
this.slave = slave;
|
this.slave = slave;
|
||||||
this.polyGerrit = cfg.getBoolean("gerrit", null, "enablePolyGerrit", false);
|
this.enablePolyGerrit = forcePolyGerritDev
|
||||||
|
|| cfg.getBoolean("gerrit", null, "enablePolyGerrit", false);
|
||||||
|
this.forcePolyGerritDev = forcePolyGerritDev;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableDefaultUi() {
|
public boolean enableDefaultUi() {
|
||||||
return !headless && !polyGerrit;
|
return !headless && !enablePolyGerrit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableMasterFeatures() {
|
public boolean enableMasterFeatures() {
|
||||||
@@ -36,6 +40,10 @@ public class GerritOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean enablePolyGerrit() {
|
public boolean enablePolyGerrit() {
|
||||||
return !headless && polyGerrit;
|
return !headless && enablePolyGerrit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean forcePolyGerritDev() {
|
||||||
|
return !headless && forcePolyGerritDev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.httpd.raw;
|
package com.google.gerrit.httpd.raw;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.gerrit.httpd.GerritOptions;
|
import com.google.gerrit.httpd.GerritOptions;
|
||||||
import com.google.gerrit.httpd.raw.ResourceServlet.Resource;
|
import com.google.gerrit.httpd.raw.ResourceServlet.Resource;
|
||||||
@@ -146,9 +148,14 @@ public class StaticModule extends ServletModule {
|
|||||||
|
|
||||||
private Path polyGerritBasePath() {
|
private Path polyGerritBasePath() {
|
||||||
Paths p = getPaths();
|
Paths p = getPaths();
|
||||||
return p.warFs != null
|
boolean forceDev = options.forcePolyGerritDev();
|
||||||
? p.warFs.getPath("/polygerrit_ui")
|
if (forceDev) {
|
||||||
: p.buckOut.getParent().resolve("polygerrit-ui").resolve("app");
|
checkArgument(p.buckOut != null,
|
||||||
|
"no buck-out directory found for PolyGerrit developer mode");
|
||||||
|
}
|
||||||
|
return forceDev || p.warFs == null
|
||||||
|
? p.buckOut.getParent().resolve("polygerrit-ui").resolve("app")
|
||||||
|
: p.warFs.getPath("/polygerrit_ui");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -580,41 +580,35 @@ public final class GerritLauncher {
|
|||||||
URL u = self.getResource(self.getSimpleName() + ".class");
|
URL u = self.getResource(self.getSimpleName() + ".class");
|
||||||
if (u == null) {
|
if (u == null) {
|
||||||
throw new FileNotFoundException("Cannot find class " + self.getName());
|
throw new FileNotFoundException("Cannot find class " + self.getName());
|
||||||
} else if (!"file".equals(u.getProtocol())) {
|
} else if ("jar".equals(u.getProtocol())) {
|
||||||
|
String p = u.getPath();
|
||||||
|
try {
|
||||||
|
u = new URL(p.substring(0, p.indexOf('!')));
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
FileNotFoundException fnfe =
|
||||||
|
new FileNotFoundException("Not a valid jar file: " + u);
|
||||||
|
fnfe.initCause(e);
|
||||||
|
throw fnfe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!"file".equals(u.getProtocol())) {
|
||||||
throw new FileNotFoundException("Cannot find extract path from " + u);
|
throw new FileNotFoundException("Cannot find extract path from " + u);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pop up to the top level classes folder that contains us.
|
// Pop up to the top level classes folder that contains us.
|
||||||
Path dir = Paths.get(u.getPath());
|
Path dir = Paths.get(u.getPath());
|
||||||
String myName = self.getName();
|
while (!name(dir).equals("buck-out")) {
|
||||||
for (;;) {
|
Path parent = dir.getParent();
|
||||||
int dot = myName.lastIndexOf('.');
|
if (parent == null || parent.equals(dir)) {
|
||||||
if (dot < 0) {
|
throw new FileNotFoundException("Cannot find buck-out from " + u);
|
||||||
dir = dir.getParent();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
myName = myName.substring(0, dot);
|
dir = parent;
|
||||||
dir = dir.getParent();
|
|
||||||
}
|
}
|
||||||
|
return dir;
|
||||||
dir = popdir(u, dir, "classes");
|
|
||||||
dir = popdir(u, dir, "eclipse");
|
|
||||||
if (last(dir).equals("buck-out")) {
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
throw new FileNotFoundException("Cannot find buck-out from " + u);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String last(Path dir) {
|
private static String name(Path dir) {
|
||||||
return dir.getName(dir.getNameCount() - 1).toString();
|
return dir.getFileName().toString();
|
||||||
}
|
|
||||||
|
|
||||||
private static Path popdir(URL u, Path dir, String name)
|
|
||||||
throws FileNotFoundException {
|
|
||||||
if (last(dir).equals(name)) {
|
|
||||||
return dir.getParent();
|
|
||||||
}
|
|
||||||
throw new FileNotFoundException("Cannot find buck-out from " + u);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ClassLoader useDevClasspath()
|
private static ClassLoader useDevClasspath()
|
||||||
|
|||||||
@@ -142,6 +142,9 @@ public class Daemon extends SiteProgram {
|
|||||||
@Option(name = "--headless", usage = "Don't start the UI frontend")
|
@Option(name = "--headless", usage = "Don't start the UI frontend")
|
||||||
private boolean headless;
|
private boolean headless;
|
||||||
|
|
||||||
|
@Option(name = "--polygerrit-dev", usage = "Force PolyGerrit UI for development")
|
||||||
|
private boolean polyGerritDev;
|
||||||
|
|
||||||
@Option(name = "--init", aliases = {"-i"},
|
@Option(name = "--init", aliases = {"-i"},
|
||||||
usage = "Init site before starting the daemon")
|
usage = "Init site before starting the daemon")
|
||||||
private boolean doInit;
|
private boolean doInit;
|
||||||
@@ -370,8 +373,8 @@ public class Daemon extends SiteProgram {
|
|||||||
modules.add(new AbstractModule() {
|
modules.add(new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(GerritOptions.class)
|
bind(GerritOptions.class).toInstance(
|
||||||
.toInstance(new GerritOptions(config, headless, slave));
|
new GerritOptions(config, headless, slave, polyGerritDev));
|
||||||
if (test) {
|
if (test) {
|
||||||
bind(String.class).annotatedWith(SecureStoreClassName.class)
|
bind(String.class).annotatedWith(SecureStoreClassName.class)
|
||||||
.toInstance(DefaultSecureStore.class.getName());
|
.toInstance(DefaultSecureStore.class.getName());
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ public class WebAppInitializer extends GuiceServletContextListener
|
|||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(GerritOptions.class)
|
bind(GerritOptions.class)
|
||||||
.toInstance(new GerritOptions(config, false, false));
|
.toInstance(new GerritOptions(config, false, false, false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
modules.add(new GarbageCollectionModule());
|
modules.add(new GarbageCollectionModule());
|
||||||
|
|||||||
33
lib/js.defs
33
lib/js.defs
@@ -15,6 +15,9 @@
|
|||||||
NPMJS = 'NPMJS'
|
NPMJS = 'NPMJS'
|
||||||
GERRIT = 'GERRIT'
|
GERRIT = 'GERRIT'
|
||||||
|
|
||||||
|
# NOTE: npm_binary rules do not get their licenses checked by gen_licenses.py,
|
||||||
|
# as we would have to cut too many edges. DO NOT include these binaries in
|
||||||
|
# build outputs. Using them in the build _process_ is ok.
|
||||||
def npm_binary(
|
def npm_binary(
|
||||||
name,
|
name,
|
||||||
version,
|
version,
|
||||||
@@ -38,7 +41,6 @@ def npm_binary(
|
|||||||
name = name,
|
name = name,
|
||||||
cmd = ' '.join(cmd),
|
cmd = ' '.join(cmd),
|
||||||
out = dest,
|
out = dest,
|
||||||
license = 'DO_NOT_DISTRIBUTE',
|
|
||||||
visibility = visibility,
|
visibility = visibility,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -86,3 +88,32 @@ def bower_components(
|
|||||||
out = '%s.bower_components.zip' % name,
|
out = '%s.bower_components.zip' % name,
|
||||||
visibility = visibility,
|
visibility = visibility,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
VULCANIZE_FLAGS = [
|
||||||
|
'--inline-scripts',
|
||||||
|
'--inline-css',
|
||||||
|
'--strip-comments',
|
||||||
|
]
|
||||||
|
|
||||||
|
def vulcanize(
|
||||||
|
name,
|
||||||
|
app,
|
||||||
|
srcs,
|
||||||
|
components,
|
||||||
|
extra_flags = [],
|
||||||
|
visibility = ['PUBLIC']):
|
||||||
|
genrule(
|
||||||
|
name = name,
|
||||||
|
cmd = ' '.join([
|
||||||
|
'unzip', '-qd', '$SRCDIR',
|
||||||
|
] + ['$(location %s)' % c for c in components] + [
|
||||||
|
'&&', run_npm_binary('//lib/js:vulcanize')
|
||||||
|
] + VULCANIZE_FLAGS + extra_flags + [
|
||||||
|
'--out-html', '$OUT',
|
||||||
|
'$SRCDIR/%s' % app,
|
||||||
|
]),
|
||||||
|
srcs = srcs,
|
||||||
|
out = '%s.html' % name,
|
||||||
|
visibility = visibility,
|
||||||
|
)
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ npm_binary(
|
|||||||
sha1 = '59d457122a161e42cc1625bbab8179c214b7ac11',
|
sha1 = '59d457122a161e42cc1625bbab8179c214b7ac11',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
npm_binary(
|
||||||
|
name = 'vulcanize',
|
||||||
|
version = '1.14.0',
|
||||||
|
sha1 = '91eac280d031b5bbcafb5f86bb6ed30515fa2564',
|
||||||
|
repository = GERRIT,
|
||||||
|
)
|
||||||
|
|
||||||
# bower_components are listed without transitive dependencies; the whole
|
# bower_components are listed without transitive dependencies; the whole
|
||||||
# flattened dependency tree needs to be included in
|
# flattened dependency tree needs to be included in
|
||||||
# //polygerrit-ui:polygerrit_components.
|
# //polygerrit-ui:polygerrit_components.
|
||||||
|
|||||||
44
polygerrit-ui/app/BUCK
Normal file
44
polygerrit-ui/app/BUCK
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
include_defs('//lib/js.defs')
|
||||||
|
|
||||||
|
WEBJS = 'bower_components/webcomponentsjs/webcomponents-lite.js'
|
||||||
|
|
||||||
|
# TODO(dborowitz): Putting these rules in this package avoids having to handle
|
||||||
|
# the app/ prefix like we would have to if this were in the parent directory.
|
||||||
|
# The only reason for the app subdirectory in the first place was convenience
|
||||||
|
# when witing server.go; when that goes away, we can just move all the files and
|
||||||
|
# these rules up one directory.
|
||||||
|
genrule(
|
||||||
|
name = 'polygerrit_ui',
|
||||||
|
cmd = ' && '.join([
|
||||||
|
'mkdir $TMP/polygerrit_ui',
|
||||||
|
'cd $TMP/polygerrit_ui',
|
||||||
|
'cp $(location :processed_index) index.html',
|
||||||
|
'mkdir -p {elements,bower_components/webcomponentsjs}',
|
||||||
|
'cp $(location :polygerrit) elements/gr-app.vulcanized.html',
|
||||||
|
'cp -rp $SRCDIR/* .',
|
||||||
|
'unzip -p $(location //polygerrit-ui:polygerrit_components) %s>%s' % (WEBJS, WEBJS),
|
||||||
|
'cd $TMP',
|
||||||
|
'zip -9qr $OUT .',
|
||||||
|
]),
|
||||||
|
srcs = glob([
|
||||||
|
'favicon.ico',
|
||||||
|
'styles/**/*.css'
|
||||||
|
]),
|
||||||
|
out = 'polygerrit_ui.zip',
|
||||||
|
visibility = ['PUBLIC'],
|
||||||
|
)
|
||||||
|
|
||||||
|
genrule(
|
||||||
|
name = 'processed_index',
|
||||||
|
cmd = 'sed "s/gr-app.html/gr-app.vulcanized.html/g" $SRCS >$OUT',
|
||||||
|
srcs = ['index.html'],
|
||||||
|
out = 'index_processed.html',
|
||||||
|
)
|
||||||
|
|
||||||
|
vulcanize(
|
||||||
|
name = 'polygerrit',
|
||||||
|
app = 'elements/gr-app.html',
|
||||||
|
srcs = glob(['**'], excludes = ['index.html']),
|
||||||
|
components = ['//polygerrit-ui:polygerrit_components'],
|
||||||
|
)
|
||||||
|
|
||||||
@@ -61,15 +61,19 @@ def war(
|
|||||||
)
|
)
|
||||||
|
|
||||||
def gerrit_war(name, ui = 'ui_optdbg', context = [], docs = False, visibility = []):
|
def gerrit_war(name, ui = 'ui_optdbg', context = [], docs = False, visibility = []):
|
||||||
|
ui_deps = []
|
||||||
|
if ui:
|
||||||
|
ui_deps.append('//polygerrit-ui/app:polygerrit_ui')
|
||||||
|
if ui != 'polygerrit':
|
||||||
|
ui_deps.append('//gerrit-gwtui:%s' % ui)
|
||||||
war(
|
war(
|
||||||
name = name,
|
name = name,
|
||||||
libs = LIBS + ['//gerrit-war:version'],
|
libs = LIBS + ['//gerrit-war:version'],
|
||||||
pgmlibs = PGMLIBS,
|
pgmlibs = PGMLIBS,
|
||||||
context = [
|
context = ui_deps + context + [
|
||||||
'//gerrit-main:main_bin',
|
'//gerrit-main:main_bin',
|
||||||
'//gerrit-war:webapp_assets',
|
'//gerrit-war:webapp_assets',
|
||||||
] + (['//gerrit-gwtui:' + ui] if ui else []) +
|
],
|
||||||
context,
|
|
||||||
docs = docs,
|
docs = docs,
|
||||||
visibility = visibility,
|
visibility = visibility,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user