diff --git a/java/google/registry/BUILD b/java/google/registry/BUILD index 64c2468b1..df83639a5 100644 --- a/java/google/registry/BUILD +++ b/java/google/registry/BUILD @@ -45,6 +45,22 @@ registry_ear_file( }, ) +# We use the production "nocron" earfile only in the event of a datastore +# restore. +registry_ear_file( + name = "registry_nocron_ear", + out = "registry_nocron.ear", + configs = { + "env/common/META-INF/appengine-application.xml": "META-INF/appengine-application.xml", + "env/common/META-INF/application.xml": "META-INF/application.xml", + }, + wars = { + "registry_default_nocron.war": "default", + "registry_backend.war": "backend", + "registry_tools.war": "tools", + }, +) + zip_file( name = "registry_default_war", srcs = [ @@ -69,6 +85,13 @@ zip_file( ], ) +zip_file( + name = "registry_default_nocron_war", + out = "registry_default_nocron.war", + exclude = ["WEB-INF/cron.xml"], + deps = [":registry_default_war"], +) + zip_file( name = "registry_backend_war", srcs = [ @@ -185,6 +208,26 @@ registry_ear_file( }, ) +# The "nocron" files are, unsurprisingly, versions of the archives that have +# had cron.xml removed. We do this because it's necessary to deploy them in +# this way when restoring a backup. +# +# "nocron" archives are currently prepared for production and alpha. To +# prepare them for another environment, just do something similar. +registry_ear_file( + name = "registry_alpha_nocron_ear", + out = "registry_alpha_nocron.ear", + configs = { + "env/common/META-INF/appengine-application.xml": "META-INF/appengine-application.xml", + "env/common/META-INF/application.xml": "META-INF/application.xml", + }, + wars = { + "registry_default_alpha_nocron.war": "default", + "registry_backend_alpha.war": "backend", + "registry_tools_alpha.war": "tools", + }, +) + zip_file( name = "registry_default_alpha_war", srcs = [ @@ -198,6 +241,13 @@ zip_file( deps = [":registry_default_war"], ) +zip_file( + name = "registry_default_alpha_nocron_war", + out = "registry_default_alpha_nocron.war", + exclude = ["WEB-INF/cron.xml"], + deps = [":registry_default_alpha_war"], +) + zip_file( name = "registry_backend_alpha_war", srcs = [ diff --git a/java/google/registry/builddefs/zip_file.bzl b/java/google/registry/builddefs/zip_file.bzl index 5c67f963a..9ef5905ec 100644 --- a/java/google/registry/builddefs/zip_file.bzl +++ b/java/google/registry/builddefs/zip_file.bzl @@ -107,6 +107,18 @@ A zip file can be assembled across many rules. For example: mappings = {"webapp/html": ""}, ) +You can exclude files with the "exclude" attribute: + + # //webapp/BUILD + zip_file( + name = "war_without_tears", + deps = ["war"], + exclude = ["assets/js/tears.js"], + ) + +Note that "exclude" excludes based on the mapped path relative to the root of +the zipfile. If the file doesn't exist, you'll get an error. + """ load('//java/google/registry/builddefs:defs.bzl', @@ -136,6 +148,7 @@ def _zip_file(ctx): ] cmd += ['"${zipper}" x "${repo}/%s"' % dep.zip_file.path for dep in ctx.attr.deps] + cmd += ['rm %s' % filename for filename in ctx.attr.exclude] cmd += ['mkdir -p "${tmp}/%s"' % zip_path for zip_path in set( [zip_path[:zip_path.rindex('/')] @@ -217,6 +230,7 @@ zip_file = rule( 'srcs': attr.label_list(allow_files=True), 'data': attr.label_list(cfg='data', allow_files=True), 'deps': attr.label_list(providers=['zip_file']), + 'exclude': attr.string_list(), 'mappings': attr.string_dict(), '_zipper': attr.label(default=Label(ZIPPER), single_file=True), })