Coder Social home page Coder Social logo

rules_appengine's Introduction

๐Ÿšจ rules_appengine is no longer maintained.

Build status

App Engine Rules for Bazel

Overview

These build rules are used for building Java App Engine application or Python App Engine application with Bazel. It does not aim at general web application support but can be easily modified to handle a standard web application.

Setup

To be able to use the rules, you must make the App Engine SDK available to Bazel. The easiest way to do so is by adding the following to your WORKSPACE file:

Note: The ${LANG}_appengine_repository() lines are only needed for the languages you plan to use.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "bazel_skylib",
    urls = [
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
    ],
    sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()

git_repository(
    name = "io_bazel_rules_appengine",
    remote = "https://github.com/bazelbuild/rules_appengine.git",
    # Check https://github.com/bazelbuild/rules_appengine/releases for the latest version.
    tag = "0.0.8",
)
# Java
load(
    "@io_bazel_rules_appengine//appengine:java_appengine.bzl",
    "java_appengine_repositories",
)

java_appengine_repositories()

# Python
load(
    "@io_bazel_rules_appengine//appengine:sdk.bzl",
    "appengine_repositories",
)

appengine_repositories()

load(
    "@io_bazel_rules_appengine//appengine:py_appengine.bzl",
    "py_appengine_repositories",
)

py_appengine_repositories()

The App Engine rules download the App Engine SDK, which is a few hundred megabytes in size. To avoid downloading this multiple times for multiple projects or inadvertently re-downloading it, you might want to add the following lines to your $HOME/.bazelrc file:

build --experimental_repository_cache=/home/user/.bazel/cache
fetch --experimental_repository_cache=/home/user/.bazel/cache

Requesting a specific App Engine SDK

All ${LANG}_appengine_repository macros accept optional arguments version and sha256.

py_appengine_repositories(
    version = '1.9.67',
    sha256 = 'f9f45150643424cb164185d9134b86511c2bec3001499247ef9027f1605ef8a3',
)

Using a predownloaded SDK version

You can, optionally, specify the environment variable ${LANG}_APPENGINE_SDK_PATH to use an SDK that is unzipped on your filesystem (instead of downloading a new one).

PY_APPENGINE_SDK_PATH=/path/to/google_appengine bazel build //whatever
JAVA_APPENGINE_SDK_PATH=/path/to/appengine-java-sdk-1.9.50 bazel build //whatever

Basic Java Example

Suppose you have the following directory structure for a simple App Engine application:

[workspace]/
    WORKSPACE
    hello_app/
        BUILD
        java/my/webapp/
            TestServlet.java
        webapp/
            index.html
        webapp/WEB-INF
            web.xml
            appengine-web.xml

BUILD definition

Then, to build your webapp, your hello_app/BUILD can look like:

load("@io_bazel_rules_appengine//appengine:java_appengine.bzl", "appengine_war")

java_library(
    name = "mylib",
    srcs = ["java/my/webapp/TestServlet.java"],
    deps = [
        "//external:appengine/java/api",
        "@io_bazel_rules_appengine//appengine:javax.servlet.api",
    ],
)

appengine_war(
    name = "myapp",
    jars = [":mylib"],
    data = glob(["webapp/**"]),
    data_path = "/webapp",
)

For simplicity, you can use the java_war rule to build an app from source. Your hello_app/BUILD file would then look like:

load("@io_bazel_rules_appengine//appengine:java_appengine.bzl", "java_war")

java_war(
    name = "myapp",
    srcs = ["java/my/webapp/TestServlet.java"],
    data = glob(["webapp/**"]),
    data_path = "/webapp",
    deps = [
        "//external:appengine/java/api",
        "@io_bazel_rules_appengine//appengine:javax.servlet.api",
    ],
)

You can then build the application with bazel build //hello_app:myapp.

Run on a local server

You can run it in a development server with bazel run //hello_app:myapp. This will bind a test server on port 8080. If you wish to select another port, use the --port option:

bazel run //hello_app:myapp -- --port=12345

You can see other options with -- --help (the -- tells Bazel to pass the rest of the arguments to the executable).

Deploy to Google App Engine

Another target //hello_app:myapp.deploy allows you to deploy your application to App Engine. It takes an optional argument: the APP_ID. If not specified, it uses the default APP_ID provided in the application. This target needs to open a browser to authenticate with App Engine, then have you copy-paste a "key" from the browser in the terminal. Since Bazel closes standard input, you can only input this by building the target and then running:

$ bazel-bin/hello_app/myapp.deploy APP_ID

After the first launch, subsequent launch will be registered to App Engine so you can just do a normal bazel run //hello_app:myapp.deploy -- APP_ID to deploy next versions of your application.

Java specific details

Note: App Engine uses Java 8 (or Java 7, but this runtime is deprecated). If you are using a more recent version of Java, you will get the following error message when you try to deploy:

java.lang.IllegalArgumentException: Class file is Java 9 but max supported is Java 8

To build with Java 8, use the toolchain bundled with these App Engine rules:

$ bazel build --extra_toolchains=@io_bazel_rules_appengine//appengine/jdk:jdk8_definition //my-project

To avoid having to specify this toolchain during every build, you can add this to your project's .bazelrc. Create a .bazelrc file in the root directory of your project and add the line:

build --extra_toolchains=@io_bazel_rules_appengine//appengine/jdk:jdk8_definition

In case you don't want to install JDK 8 on the machine running Bazel, you can import remote JDK8 repositories by adding the following lines to your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_java",
    sha256 = "7c4bbe11e41c61212a5cf16d9aafaddade3f5b1b6c8bf94270d78215fafd4007",
    strip_prefix = "rules_java-c13e3ead84afb95f81fbddfade2749d8ba7cb77f",
    url = "https://github.com/bazelbuild/rules_java/archive/c13e3ead84afb95f81fbddfade2749d8ba7cb77f.tar.gz",  # 2021-01-25
)

load("@rules_java//java:repositories.bzl", "remote_jdk8_repos")

remote_jdk8_repos()

appengine_war

appengine_war(name, jars, data, data_path)
Attributes
name Name, required

A unique name for this rule.

jars List of labels, required

List of JAR files that will be uncompressed as the code for the Web Application.

If it is a `java_library` or a `java_import`, the JAR from the runtime classpath will be added in the `lib` directory of the Web Application.

data List of files, optional

List of files used by the Web Application at runtime.

This attribute can be used to specify the list of resources to be included into the WAR file.

data_path String, optional

Root path of the data.

The directory structure from the data is preserved inside the WebApplication but a prefix path determined by `data_path` is removed from the the directory structure. This path can be absolute from the workspace root if starting with a `/` or relative to the rule's directory. It is set to `.` by default.

java_war

java_war(name, data, data_path, **kwargs)
Attributes
name Name, required

A unique name for this rule.

data List of labels, optional

List of files used by the Web Application at runtime.

Passed to the appengine_war rule.

data_path String, optional

Root path of the data.

Passed to the appengine_war rule.

**kwargs see java_library

The other arguments of this rule will be passed to build a `java_library` that will be passed in the `jar` arguments of a appengine_war rule.

Python specific details

py_appengine_binary

py_appengine_binary(name, srcs, configs, deps=[], data=[], overwrite_appengine_config=True)
Attributes
name Name, required

A unique name for this rule.

configs List of labels, required

the path to your app.yaml/index.yaml/cron.yaml files

srcs List of labels, optional

The list of source files that are processed to create the target.

deps List of labels, optional

The list of libraries to link into this library.

data List of labels, optional

List of files used by the Web Application at runtime.

overwrite_appengine_config Boolean, optional

If true, patch the user's appengine_config into the base one. If false, use the user specified config directly. Set to False to behave pre 0.0.8.

py_appengine_test

py_appengine_test(name, srcs, deps=[], data=[], libraries={})
Attributes
name Name, required

A unique name for this rule.

srcs List of labels, required

The list of source files that are processed to create the target.

deps List of labels, optional

The list of libraries to link into this library.

data List of labels, optional

List of files used by the Web Application at runtime.

libraries dict, optional

dictionary of name and the corresponding version for third-party libraries required from sdk.

rules_appengine's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rules_appengine's Issues

How does "data" attribute work in java_war and appengine_war

In an exploratory project I'm trying to run an Java application that serves some static resource. I tried to add static resources to the war file using the data attribute.
https://github.com/jiaqi/angular-on-java/blob/seattle/java/org/cyclopsgroup/aoj/server/BUILD

It seems the setting is effective and after some work files do end up in the war file as expected.

$ bazel build java/org/cyclopsgroup/aoj/server
INFO: Analyzed target //java/org/cyclopsgroup/aoj/server:server (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //java/org/cyclopsgroup/aoj/server:server up-to-date:
  bazel-bin/java/org/cyclopsgroup/aoj/server/server.war
  bazel-bin/java/org/cyclopsgroup/aoj/server/server_deploy.sh
  bazel-bin/java/org/cyclopsgroup/aoj/server/server
  ...
$ jar -tvf bazel-bin/java/org/cyclopsgroup/aoj/server/server.war
    94 Fri Jan 01 00:00:00 PST 2010 ./webapp/aoj/styles.css
5628103 Fri Jan 01 00:00:00 PST 2010 ./webapp/aoj/js_bundle.js
   141 Fri Jan 01 00:00:00 PST 2010 ./webapp/aoj/styles.css.map
 11413 Fri Jan 01 00:00:00 PST 2010 ./favicon.png
 ...

Then I ran the war target with bazel run and found that only favicon.png is served and none of the others is.

After reading appengine_runner.sh.template I realized the root directory of web application at runtime has nothing to do with the files in the war file.

bazel-out/darwin-fastbuild/bin/java/org/cyclopsgroup/aoj/server/server.runfiles/angular_on_java/java/org/cyclopsgroup/aoj/server
โ”œโ”€โ”€ WEB-INF
โ”‚ย ย  โ”œโ”€โ”€ appengine-generated
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ local_db.bin
โ”‚ย ย  โ”œโ”€โ”€ appengine-web.xml -> /Users/jguo/github/jiaqi/angular-on-java/java/org/cyclopsgroup/aoj/server/WEB-INF/appengine-web.xml
โ”‚ย ย  โ”œโ”€โ”€ jsp
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ index.jsp -> /Users/jguo/github/jiaqi/angular-on-java/java/org/cyclopsgroup/aoj/server/WEB-INF/jsp/index.jsp
โ”‚ย ย  โ””โ”€โ”€ lib
โ”‚ย ย      โ”œโ”€โ”€ appengine-api.jar -> /private/var/tmp/_bazel_jguo/239a5101fa986e10f8c504b3e6b8e624/execroot/angular_on_java/bazel-out/darwin-fastbuild/bin/java/org/cyclopsgroup/aoj/server/server.runfiles/angular_on_java/../com_google_appengine_java/lib/impl/appengine-api.jar
...
โ”œโ”€โ”€ server -> /private/var/tmp/_bazel_jguo/239a5101fa986e10f8c504b3e6b8e624/execroot/angular_on_java/bazel-out/darwin-fastbuild/bin/java/org/cyclopsgroup/aoj/server/server
โ””โ”€โ”€ server.war -> /private/var/tmp/_bazel_jguo/239a5101fa986e10f8c504b3e6b8e624/execroot/angular_on_java/bazel-out/darwin-fastbuild/bin/java/org/cyclopsgroup/aoj/server/server.war

4 directories, 31 files

None of the webapp/aoj/* files we saw in the war file exists under runfiles. With file structure like this in runfiles, the running application actually serves server.war by mistake.

Unless I miss anything, this doesn't make sense to me at all. What the data attribute specifies is correctly honored when creating a war file, but completely ignored when running it. Is it by design? What's the right way to specify data attribute so it matters at runtime?

rules_appengine is failing on ci.bazel.io

http://ci.bazel.io/job/rules_appengine/BAZEL_VERSION=HEAD,PLATFORM_NAME=linux-x86_64/303/console

==================== Test output for //test:check_war:
Contents of /home/ci/.cache/bazel/_bazel_ci/c750b964429e227e39aa79a8541a1a88/bazel-sandbox/82344825-2998-4893-bb74-03d7753caf81-0/execroot/linux-x86_64/bazel-out/local-fastbuild/bin/test/check_war.runfiles/io_bazel_rules_appengine/test/test-war.war:
./
./data/
./data/BUILD
./data/welcome.jsp
./data/gen-data.out
./WEB-INF/
./WEB-INF/web.xml
./WEB-INF/lib/
./WEB-INF/lib/appengine-tools-api.jar
./WEB-INF/lib/appengine-agent.jar
./WEB-INF/lib/app_deploy.jar
./WEB-INF/logging.properties
./WEB-INF/appengine-web.xml
Expected './WEB-INF/lib/appengine-api.jar' in /home/ci/.cache/bazel/_bazel_ci/c750b964429e227e39aa79a8541a1a88/bazel-sandbox/82344825-2998-4893-bb74-03d7753caf81-0/execroot/linux-x86_64/bazel-out/local-fastbuild/bin/test/check_war.runfiles/io_bazel_rules_appengine/test/test-war.war
================================================================================
Target //test:check_war up-to-date:
  bazel-bin/test/check_war
____Elapsed time: 1.511s, Critical Path: 0.85s
//test:check_war                                                         FAILED in 0.7s
  /home/ci/.cache/bazel/_bazel_ci/c750b964429e227e39aa79a8541a1a88/execroot/linux-x86_64/bazel-out/local-fastbuild/testlogs/test/check_war/test.log

Executed 1 out of 1 test: 1 fails locally.

Looks like 68b0fa6 is breaking rules_appengine on ci.bazel.io
//cc @kchodorow

java: unable to build examples app on OSX from master

Build label: 3.7.0-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Oct 21 04:06:38 2020 (1603253198)
Build timestamp: 1603253198
Build timestamp as int: 1603253198
โ˜  rules_appengine [master] bazel build --extra_toolchains=@io_bazel_rules_appengine//appengine/jdk:jdk8 //examples/java:examples
INFO: Build option --extra_toolchains has changed, discarding analysis cache.
ERROR: /private/var/tmp/_bazel_mgenov/dd7cf166a2897e6d4ee8f8f48271a52e/external/remote_jdk8_windows_toolchain_config_repo/BUILD.bazel:20:10: @remote_jdk8_windows_toolchain_config_repo//:toolchain: no such attribute 'target_settings' in 'toolchain' rule
ERROR: Analysis of target '//examples/java:examples' failed; build aborted: error loading package '@remote_jdk8_windows_toolchain_config_repo//': Package '' contains errors
INFO: Elapsed time: 0.372s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (8 packages loaded, 16 targets configured)
    Fetching @local_jdk; fetching
โ˜  rules_appengine [master]

rules_appengine is failing on Bazel CI

https://buildkite.com/bazel/rules-appengine-appengine/builds/89#_

ERROR: /var/lib/buildkite-agent/builds/buildkite-worker-ubuntu1404-java8-g0s7-1/bazel/rules-appengine-appengine/examples/py/hello_world/BUILD:8:1: every rule of type py_appengine_binary_base implicitly depends upon the target '@com_google_cloud_sdk//:gcloud', but this target could not be found because of: no such package '@com_google_cloud_sdk//': The repository could not be resolved
--
ย  | ERROR: /var/lib/buildkite-agent/builds/buildkite-worker-ubuntu1404-java8-g0s7-1/bazel/rules-appengine-appengine/examples/py/hello_world/BUILD:8:1: no such package '@com_google_cloud_sdk//': The repository could not be resolved and referenced by '//examples/py/hello_world:main.deploy'
ย  | WARNING: errors encountered while analyzing target '//examples/py/hello_world:main': it will not be built
ย  | WARNING: errors encountered while analyzing target '//examples/py/hello_world:main.deploy': it will not be built

The culprit should be 8122a70

Latest release (0.0.7) does not include java_appengine.bzl

Hello,

The tag specified in the README file (0.0.7) does not include the java_appengine.bzl file, please generate a new release that includes the required files.

Workaround (specify the commit instead of the tag):
git_repository( name = "io_bazel_rules_appengine", remote = "https://github.com/bazelbuild/rules_appengine.git", # Check https://github.com/bazelbuild/rules_appengine/releases for the latest version. #tag = "0.0.7", commit = "44caf2de649bb37a41408a821d04833450fa89a3", )

Flag --incompatible_load_java_rules_from_bzl will break rules_appengine in Bazel 1.2.1

Incompatible flag --incompatible_load_java_rules_from_bzl will break rules_appengine once Bazel 1.2.1 is released.

Please see the following CI builds for more information:

Questions? Please file an issue in https://github.com/bazelbuild/continuous-integration

Important: Please do NOT modify the issue title since that might break our tools.

Use gcloud for deployment of java apps

As application deployments with appcfg are no longer supported it is valuable gcloud to be used and for java apps to ensure that Java apps could be deployed on GAE.

Addresses the following issue with appcfg:

Application deployment failed. Message: Deployments using appcfg are no longer supported.

ClassLoader is jdk.internal.loader.ClassLoaders$AppClassLoader@4b85612c, not a URLClassLoader

I followed all the instructions in the README.

My BUILD conf is:

load("@io_bazel_rules_appengine//appengine:java_appengine.bzl", "appengine_war")

java_library(
    name = "mylib",
    srcs = ["java/my/webapp/ServletConfig.java", "java/my/webapp/MyServlet.java"],
    deps = [
        "@maven//:com_google_inject_extensions_guice_servlet",
        "@maven//:com_google_inject_guice",
        "@maven//:javax_inject_javax_inject",
        "@maven//:javax_servlet_javax_servlet_api"
    ],
)

appengine_war(
    name = "myapp",
    jars = [":mylib"],
    data = glob(["java/**"]),
    data_path = "/",
)

The command bazelbuild build works perfectly but when I run bazel run //app_engine:myapp I get the following error:

INFO: Analyzed target //app_engine:myapp (1 packages loaded, 4 targets configured).
INFO: Found 1 target...
Target //app_engine:myapp up-to-date:
  bazel-bin/app_engine/myapp.war
  bazel-bin/app_engine/myapp_deploy.sh
  bazel-bin/app_engine/myapp
INFO: Elapsed time: 0.250s, Critical Path: 0.02s
INFO: 3 processes: 3 internal.
INFO: Build completed successfully, 3 total actions
INFO: Build completed successfully, 3 total actions
java.lang.RuntimeException: Unable to create a DevAppServer
	at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:401)
	at com.google.appengine.tools.development.DevAppServerFactory.access$000(DevAppServerFactory.java:31)
	at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:318)
	at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:315)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:314)
	at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:374)
	at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:45)
	at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:247)
	at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:238)
Caused by: java.lang.ClassCastException: ClassLoader is jdk.internal.loader.ClassLoaders$AppClassLoader@4b85612c, not a URLClassLoader.
	at com.google.apphosting.utils.security.SecurityManagerInstaller.generatePolicyFile(SecurityManagerInstaller.java:139)
	at com.google.apphosting.utils.security.SecurityManagerInstaller.install(SecurityManagerInstaller.java:94)
	at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:377)
	... 9 more

For Java rules, files from multiple Labels of data attribute are flattened in war file

In https://github.com/bazelbuild/rules_appengine/blob/master/appengine/java_appengine.bzl#L82

    if path and in_file.short_path.startswith(path):
        output_path += in_file.short_path[len(path):]

when in_file.short_path does not start with path, what happens is output_path will remain output, the root directory of war file. And eventually ln -s $(pwd)/%s %s creates in_file symlink at the root directory, and ignores the directory structure of in_file.

If multiple files from different directories have the same name, one will overwrite the other.

I believe the desired behavior is to preserve the original directory structure of in_file and create symlink at output_path/in_file.path instead of output_path. I've got it working in a fork, it looks roughly like this

https://github.com/jiaqi/rules_appengine/pull/1/files#diff-3b8b4a89deffca2ab1dabfb178ff7012

If it make sense I can create a PR.

Support homebrew bazel 4.0.0

Homebrew upgraded me to bazel 4.0.0 and now I'm getting this failure:
@io_bazel_rules_appengine//appengine:jdk8: no such attribute 'extclasspath' in 'java_toolchain' rule

$ bazel --version
bazel 4.0.0-homebrew

`appengine-web.xml` not being put in WEB-INF

This to me looks more or less identical to the README example. Am I missing something simple?

Bazel version:

$ bazel version
Build label: 0.8.0-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Nov 27 20:38:09 2017 (1511815089)
Build timestamp: 1511815089
Build timestamp as int: 1511815089

.bazelrc:

build --experimental_repository_cache=/Users/dclemen/.bazel/cache

Structure of project:

foo/
    BUILD
    WORKSPACE
    src/main/java/<various>/
        - VariousFiles.java
    src/test/java/<various>
        - VariousFilesTest.java
    webapp/
        WEB-INF/
            appengine-web.xml
            logging.properties
            web.xml

WORKSPACE:

git_repository(
    name = "io_bazel_rules_appengine",
    remote = "https://github.com/bazelbuild/rules_appengine.git",
    tag = "0.0.7",
)

load("@io_bazel_rules_appengine//appengine:appengine.bzl", "appengine_repositories")
appengine_repositories()

<various maven_jar definitions>

BUILD:

load("@io_bazel_rules_appengine//appengine:appengine.bzl", "appengine_war")

package(default_visibility = ["//visibility:public"])

java_library(
    name = "java-maven-lib",
    resources = glob(["src/main/resources/**"]),
    srcs = glob(["src/main/java/**/*.java"]),
    deps = [
      "//external:appengine/java/api",
      "@io_bazel_rules_appengine//appengine:javax.servlet.api",
      <additional jars>
    ]
)

appengine_war(
    name = "foo-gae",
    jars = [":java-maven-lib"],
    data = glob(["webapp/**"]),
    data_path = "webapp",
)

<test definition, which if removed renders the exact same result>

I build it and then run it (with bazel run //:foo-gae -- --port=12345), and it generates the following exception:

SEVERE: Received exception processing /private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml
com.google.apphosting.utils.config.AppEngineConfigException: Could not locate /private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml
	at com.google.apphosting.utils.config.AppEngineWebXmlReader.getInputStream(AppEngineWebXmlReader.java:141)
	at com.google.apphosting.utils.config.AppEngineWebXmlReader.readAppEngineWebXml(AppEngineWebXmlReader.java:75)
	at com.google.apphosting.utils.config.EarHelper.readWebModule(EarHelper.java:178)
	at com.google.appengine.tools.development.ApplicationConfigurationManager$WarModuleConfigurationHandle.readConfiguration(ApplicationConfigurationManager.java:414)
	at com.google.appengine.tools.development.ApplicationConfigurationManager.<init>(ApplicationConfigurationManager.java:159)
	at com.google.appengine.tools.development.ApplicationConfigurationManager.newWarConfigurationManager(ApplicationConfigurationManager.java:101)
	at com.google.appengine.tools.development.ApplicationConfigurationManager.newWarConfigurationManager(ApplicationConfigurationManager.java:87)
	at com.google.appengine.tools.development.DevAppServerImpl.<init>(DevAppServerImpl.java:142)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:271)
	at com.google.appengine.tools.development.DevAppServerFactory.access$000(DevAppServerFactory.java:33)
	at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:233)
	at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:231)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:231)
	at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:101)
	at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:347)
	at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:47)
	at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:223)
	at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:214)
Caused by: java.io.FileNotFoundException: /private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml (No such file or directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at java.io.FileInputStream.<init>(FileInputStream.java:93)
	at com.google.apphosting.utils.config.AppEngineWebXmlReader.getInputStream(AppEngineWebXmlReader.java:137)
	... 22 more

com.google.apphosting.utils.config.AppEngineConfigException: Invalid configuration
	at com.google.appengine.tools.development.DevAppServerImpl.reportDeferredConfigurationException(DevAppServerImpl.java:432)
	at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:232)
	at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
	at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:219)
	at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:217)
	at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:359)
	at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:47)
	at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:223)
	at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:214)
Caused by: com.google.apphosting.utils.config.AppEngineConfigException: Invalid appengine-web.xml(/private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml) - Could not locate /private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml

When I open up bazel-bin/foo-gae.war: I see the following structure:

/
    appengine-web.xml
    logging.properties
    web.xml
    WEB-INF/
        lib/
            - various.jar

Support for python 3 google sdk

Failing to run py_appengine_binary due to assertion in google cloud SDK to validate if it is version 2 of python or not.
Please help on how to make it work for python 3? or is there any issue with the version I am using?
I am using the following version

git_repository(
    name = "io_bazel_rules_appengine",
    remote = "https://github.com/bazelbuild/rules_appengine.git",
    # Check https://github.com/bazelbuild/rules_appengine/releases for the latest version.
    tag = "0.0.9",
)

load(
    "@io_bazel_rules_appengine//appengine:sdk.bzl",
    "appengine_repositories",
)

appengine_repositories()

load(
    "@io_bazel_rules_appengine//appengine:py_appengine.bzl",
    "py_appengine_repositories",
)

py_appengine_repositories(
    version = '1.9.78',
)

INFO: Build completed successfully, 1 total action
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_harsh/377f44f7fb0eb350b3e1b9a606fda7bf/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/projects/app-config/main.runfiles/com_google_appengine_py/dev_appserver.py", line 95, in <module>
    assert sys.version_info[0] == 2
AssertionError

py_appengine_binary only works for targets at the top-level of the workspace

While working on #10, I found that py_appengine_binary only works if the build target is at the top-level of the workspace. Part of what's happening is the wrapper appengine_config.py file created by py_appengine.bzl is created under a different directory in sandbox than the other files from the target. Something like this:

...runfiles/
appengine_config.py
examples/
py/
hello_world/
main.py

sys.path is configured to include the ...runfiles, directory but not examples/py/hello_world, so when devappserver does an 'import main', it fails. I'm not sure the fix is to just update sys.path to include that path. I believe that appcfg and gcloud expect all of the files to be together. Eg.

/
appengine_config.py
main.py

Is it supported in bazel to construct a sandbox with a specific layout? I think this will help with adding gcloud support and third party modules.
For example, the setup instruction recommends pip install GoogleAppEngineCloudStorageClient -t <your_app_directory/lib> to use GCS. It's expected to be under the lib directory and to be uploaded with the rest of the app.

CI fails with Bazel@HEAD due to missing java_runtime

CI for rules_appengine is failing with Bazel@HEAD
https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1838#d8060cf3-3da6-491f-8598-92312e044b19

(02:09:50) ERROR: /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/78942d9c203732b140720053b958a9bd/external/rules_appengine_toolchain/BUILD.bazel:9:23: @rules_appengine_toolchain//:jdk8: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
--
ย  | (02:09:50) ERROR: /var/lib/buildkite-agent/builds/bk-docker-p58c/bazel-downstream-projects/rules_appengine/appengine/BUILD:15:6: Target '@rules_appengine_toolchain//:jdk8' contains an error and its package is in error and referenced by '//appengine:jdk8'

This originates from a change introduced in bazelbuild/bazel@c8e179f

This made java_runtime a mandatory attribute of java_toolchain.

Flag --incompatible_no_implicit_file_export will break rules_appengine in Bazel 1.2.1

Incompatible flag --incompatible_no_implicit_file_export will break rules_appengine once Bazel 1.2.1 is released.

Please see the following CI builds for more information:

Questions? Please file an issue in https://github.com/bazelbuild/continuous-integration

Important: Please do NOT modify the issue title since that might break our tools.

broken again by bazel's paths

Similar to: bazelbuild/bazel#1233

At HEAD of both bazel and rules_appengine
bazel run :myapp

.../bazel-out/local-fastbuild/bin/myapp: line 32: .../bazel-out/local-fastbuild/bin/myapp.runfiles/../bazel_tools/tools/zip/zipper/zipper: No such file or directory
Error: Could not find or load main class com.google.appengine.tools.development.DevAppServerMain

and also
bazel build :myapp && bazel-bin/myapp.deploy $myproject
bazel-bin/myapp.deploy: line 33: .../bazel-bin/refapp.runfiles/../bazel_tools/tools/zip/zipper/zipper: No such file or directory
bazel-bin/myapp.deploy: line 38: .../bazel-bin/myapp.runfiles/external/com_google_appengine_java/appengine-java-sdk-1.9.34//bin/appcfg.sh: No such file or directory

Argument for --skip_sdk_update_check is not being passed to dev_appserver.py

When running the command bazel run my_appengine_binary the command fails with the following message:

INFO: Analysed target //appname:appname (0 packages loaded).
INFO: Found 1 target...
Target //appname:appname up-to-date:
  bazel-bin/appname/appname_deploy.sh
  bazel-bin/appname/appname
INFO: Elapsed time: 0.290s, Critical Path: 0.00s
INFO: Build completed successfully, 1 total action

INFO: Running command line: bazel-bin/appname/appname
Allow dev_appserver to check for updates on startup? (Y/n): Traceback (most recent call last):
  File "/private/var/tmp/_bazel_user/81bad90251c078816a6123377b969ba0/execroot/__main__/bazel-out/darwin-fastbuild/bin/appname/appname.runfiles/__main__/../com_google_appengine_python/dev_appserver.py", line 101, in <module>
    _run_file(__file__, globals())
  File "/private/var/tmp/_bazel_user/81bad90251c078816a6123377b969ba0/execroot/__main__/bazel-out/darwin-fastbuild/bin/appname/appname.runfiles/__main__/../com_google_appengine_python/dev_appserver.py", line 97, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/private/var/tmp/_bazel_user/81bad90251c078816a6123377b969ba0/external/com_google_appengine_python/google/appengine/tools/devappserver2/devappserver2.py", line 1041, in <module>
    main()
  File "/private/var/tmp/_bazel_user/81bad90251c078816a6123377b969ba0/external/com_google_appengine_python/google/appengine/tools/devappserver2/devappserver2.py", line 1029, in main
    dev_server.start(options)
  File "/private/var/tmp/_bazel_user/81bad90251c078816a6123377b969ba0/external/com_google_appengine_python/google/appengine/tools/devappserver2/devappserver2.py", line 766, in start
    update_checker.check_for_updates(configuration)
  File "/private/var/tmp/_bazel_user/81bad90251c078816a6123377b969ba0/external/com_google_appengine_python/google/appengine/tools/devappserver2/update_checker.py", line 91, in check_for_updates
    if update_check.AllowedToCheckForUpdates():
  File "/private/var/tmp/_bazel_user/81bad90251c078816a6123377b969ba0/external/com_google_appengine_python/google/appengine/tools/sdk_update_checker.py", line 410, in AllowedToCheckForUpdates
    answer = input_fn('Allow dev_appserver to check for updates on startup? '
EOFError: EOF when reading a line
ERROR: Non-zero return code '1' from command: Process exited with status 1

My WORKSPACE file contains the following:

git_repository(
    name = "io_bazel_rules_appengine",
    remote = "https://github.com/bazelbuild/rules_appengine.git",
    # Check https://github.com/bazelbuild/rules_appengine/releases for the latest version.
    tag = "0.0.7",
)
#Load Python Rules
load("@io_bazel_rules_appengine//appengine:py_appengine.bzl", "py_appengine_repositories")
py_appengine_repositories()

py_appengine_test doesn't allow python_version

In Bazel 0.27 the default Python runtime behavior changed and as a side effect of that it seems that tests are trying to execute in Python 3 unless you explicitly specify Python 2. However py_appengine_test doesn't allow for the python_version flag. Is there any plans to add this functionality to the appengine rules or a workaround that I'm missing?

py_appengine_binary doesn't work properly

There multiple issues with that rule:

  1. It doesn't maintain creating of init.py files throughout paths.
  2. External modules don't get imported if they import their submodules inside.
    Actually py_binary() rule does all of that but it's not aware of .yaml configs.

target 'appengine/java/api' not declared in package 'external'

Hello,

I'm trying to make the bookshelf example app in the google documentation work with Bazel.

I can't build though. I run into this:

$ bazel build :myapp
INFO: $TEST_TMPDIR defined: output root default is '/spare/local/bazel/'.
.........................
ERROR: /spare/local/code/appengine/BUILD:17:1: no such target '//external:appengine/java/api': target 'appengine/java/api' not declared in package 'external' defined by /spare/local/code/appengine/WORKSPACE and referenced by '//:mylib'.
ERROR: Analysis of target '//:myapp' failed; build aborted.
INFO: Elapsed time: 2.065s

I attached my BUILD and WORKSPACE files.

Thanks

Mirko

configuration.zip

Flag --incompatible_no_implicit_file_export will break rules_appengine in a future Bazel release

Incompatible flag --incompatible_no_implicit_file_export will be enabled by default in a future Bazel release [1], thus breaking rules_appengine.

The flag is documented here: bazelbuild/bazel#10225

Please check the following CI builds for build and test results:

Never heard of incompatible flags before? We have documentation that explains everything.

If you don't want to receive any future issues for rules_appengine or if you have any questions,
please file an issue in https://github.com/bazelbuild/continuous-integration

Important: Please do NOT modify the issue title since that might break our tools.

[1] The target release hasn't been determined yet. Our tool will update the issue title once the flag flip has been scheduled.

appengine_war cannot complete due to incorrect zipper parameters

As of Bazel 0.4.1 on Windows 10+JDK8.111, the rule appengine_war cannot complete its run due to an apparently incorrect parameter for the Zipper. Attached is the command.log.

Truth be told, I'm not entirely sure if this is specific to the appengine ruleset (the java_library goal runs just fine) or if it's a more general Bazel-issue and should be reported there...

Are these rules still being maintained?

Hi,
Are these rules still being maintained?
It seems there's a tiny bit of activity so it's not completely dead but there are open issues which sound important (like #63 ) and it's unclear if there's an owner.

cc @davidstanke @helenalt @dslomov who might have some answers

(We obviously need them which is why I'm asking)

Support standard Python3 environment

While bazel itself works perfectly with Flask, it seems currently it's impossible to deploy app like Python3 quickstart.

The first issue is requirements.txt is not symlinked into bazel-build/path/to/app/app.deploy.runfiles/project (where app.yaml is located). Probably, the issue could be overcome if flask is bundled into external dependency, but gunicorn (or other wsgi server) should be declared somehow.

I manually added symlink to /path/to/app/requirements.txt into bazel-build/path/to/app/app.deploy.runfiles/project and after bazel run //path/to/app:app.deploy it worked, gunicorn dependency was resolved.

The second issue is related to loading main module.

Tried several ways to specify entrypoint in app.yaml:

entrypoint: gunicorn -b :$PORT main:app

This caused the following stacktrace:

Traceback (most recent call last):
  File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
    mod = importlib.import_module(module)
  File "/opt/python3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'main'

And

entrypoint: gunicorn -b :$PORT --chdir /path/to/app main:app
entrypoint: gunicorn -b :$PORT path.to.app.main:app

produced:

Traceback (most recent call last):
  File "/opt/python3.8/lib/python3.8/pkgutil.py", line 493, in find_loader
    spec = importlib.util.find_spec(fullname)
  File "/opt/python3.8/lib/python3.8/importlib/util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named '/workspace/path/to/app/main'

Any plans on supporting flask in python appengine standard environment?

Thanks.

Cannot run Dev server on Mac with java 1.8.0_91

Once #17 is pulled, you can run the Dev-server fine on linux, but on Mac OSX with the latest java 8 "1.8.0_91" going to any jsp page leads to:

"Unable to compile class for JSP:

An error occurred at line: 1 in the generated java file
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files
"

Which looks like
http://stackoverflow.com/questions/36963248/the-type-java-io-objectinputstream-cannot-be-resolved-it-is-indirectly-referenc

deploy rule fails: __main__/../bazel_tools/tools/zip/zipper/zipper: No such file or directory

If gae is my appengine project, I cannot deploy with

bazel clean
bazel run //foo/bar/gae:gae.deploy

The deploy target fails with

/private/var/tmp/_bazel_regis/7227e5e4290f12bab77822f13216ec6d/execroot/workspace/bazel-out/local-fastbuild/bin/foo/bar/gae/gae.deploy: line 33: /Users/regis/Documents/workspace/__main__/../bazel_tools/tools/zip/zipper/zipper: No such file or directory

unable to upgrade to 1.9.36, can't run DevServer

Attempting to update to 1.9.36 causes crashes.

diff --git a/appengine/appengine.bzl b/appengine/appengine.bzl
index 9931317..1d7706b 100644
--- a/appengine/appengine.bzl
+++ b/appengine/appengine.bzl
@@ -243,24 +243,24 @@ java_import(

 java_import(
     name = "api",
-    jars = ["appengine-java-sdk-1.9.34/lib/impl/appengine-api.jar"],
+    jars = ["appengine-java-sdk-1.9.36/lib/impl/appengine-api.jar"],
     visibility = ["//visibility:public"],
     neverlink = 1,
 )

 filegroup(
     name = "sdk",
-    srcs = glob(["appengine-java-sdk-1.9.34/**"]),
+    srcs = glob(["appengine-java-sdk-1.9.36/**"]),
     visibility = ["//visibility:public"],
-    path = "appengine-java-sdk-1.9.34",
+    path = "appengine-java-sdk-1.9.36",
 )
 """

 def appengine_repositories():
   native.new_http_archive(
       name = "com_google_appengine_java",
-      url = "http://central.maven.org/maven2/com/google/appengine/appengine-java-sdk/1.9.34/appengine-java-sdk-1.9.34.zip",
-      sha256 = "34e828bf64b48c7dc212b6cb82d67c32d42b75c988d793b97bae5fda849ce486",
+      url = "http://central.maven.org/maven2/com/google/appengine/appengine-java-sdk/1.9.36/appengine-java-sdk-1.9.36.zip",
+      sha256 = "a4694a48c3ecc7c8dc9952cfc8f94b76739ddb0d954a7a14007dcc901a38df9b",
       build_file_content = APPENGINE_BUILD_FILE,
   )

leads to
java.lang.RuntimeException: Unable to create a DevAppServer
at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:282)
at com.google.appengine.tools.development.DevAppServerFactory.access$000(DevAppServerFactory.java:36)
at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:236)
at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:234)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:234)
at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:104)
at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:265)
at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:225)
at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:216)
Caused by: java.lang.NoSuchMethodError: com.google.apphosting.utils.config.XmlUtils.getChildren(Lorg/w3c/dom/Element;)Ljava/util/List;
at com.google.apphosting.utils.config.WebXmlReader.parseWebXml(WebXmlReader.java:96)
at com.google.apphosting.utils.config.WebXmlReader.processXml(WebXmlReader.java:79)
at com.google.apphosting.utils.config.WebXmlReader.processXml(WebXmlReader.java:20)
at com.google.apphosting.utils.config.AbstractConfigXmlReader.readConfigXml(AbstractConfigXmlReader.java:91)
at com.google.apphosting.utils.config.WebXmlReader.readWebXml(WebXmlReader.java:72)
at com.google.apphosting.utils.config.EarHelper.readWebModule(EarHelper.java:175)
at com.google.appengine.tools.development.ApplicationConfigurationManager$WarModuleConfigurationHandle.readConfiguration(ApplicationConfigurationManager.java:414)
at com.google.appengine.tools.development.ApplicationConfigurationManager.(ApplicationConfigurationManager.java:159)
at com.google.appengine.tools.development.ApplicationConfigurationManager.newWarConfigurationManager(ApplicationConfigurationManager.java:101)
at com.google.appengine.tools.development.ApplicationConfigurationManager.newWarConfigurationManager(ApplicationConfigurationManager.java:87)
at com.google.appengine.tools.development.DevAppServerImpl.(DevAppServerImpl.java:139)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:274)
... 10 more

WAR packaging will fail if there are dependencies with the same name

WAR packaging will fail if there are different dependencies with the same name

Here you can find an example for a repo that has 2 packages with the same name - services.

Running bazel build on the above repo will fail with:

ln: bazel-out/darwin-fastbuild/bin/src/main/app.war.build_output/WEB-INF/lib/libservices.jar: File exists

App Engine deployment should use "gcloud" cli rather than "appcfg.py" (or have a way to use "gcloud")

Steps to reproduce:

  1. Create a py_appengine_binary target
  2. Build the .deploy target
  3. Run the .deploy script

Observed:

This command runs appcfg.py

Expected

This should run gcloud app deploy

Rationale

The gcloud cli is the more modern approach to deploying to App Engine. Additionally, gcloud app deploy can pick up the project from a prior invocation of gcloud config set project without having to specific it in the invocation explicitly (as is the case with appcfg.py). Likewise, gcloud app deploy is capable of auto-assigning a version number (based on the date), whereas appcfg.py requires an explicit -V parameter with the version specification.

appengine_war doesn't work with a java_library

The doc reads:

appengine_war(name, jars, data, data_path)

and

jars List of labels, required
List of JAR files that will be uncompressed as the code for the Web Application.
If it is a java_library or a java_import, the JAR from the runtime classpath will be added in the lib directory of the Web Application.

In my experience, the jars from the targets are not added.

In fact, even examples is adding the jar explicitely:

jars = ["//examples/src:src_deploy.jar"],

This would also work:

jars = ["//examples/src:srr.jar"],

But this doesn't:

jars = ["//examples/src:src"],

If I understand correctly, it should (and the syntax would be nicer and follow the convention of listing targets, not build artifacts).

missing com_google_cloud_sdk

I tried updating google/upvote to use 0.0.8 but then ran into:
/monolith_binary.deploy: line 26: ${{TMPDIR:-/tmp}}/war.XXXXXXXX: bad substitution
presumably due to double curly braces that seems to be fixed in the latest release.

Using head I get:
upvote/gae/BUILD:15:1: no such package '@com_google_cloud_sdk//': The repository could not be resolved and referenced by '//upvote/gae:monolith_binary.deploy'

Flag --incompatible_load_python_rules_from_bzl will break rules_appengine in Bazel 1.2.1

Incompatible flag --incompatible_load_python_rules_from_bzl will break rules_appengine once Bazel 1.2.1 is released.

Please see the following CI builds for more information:

Questions? Please file an issue in https://github.com/bazelbuild/continuous-integration

Important: Please do NOT modify the issue title since that might break our tools.

Deploy fails

I am following the Bazel backend tutorial

When I run $WORKSPACE/bazel-bin/backend/backend.deploy <project-id>

I get:

steren-macbookpro:tutorial steren$ $WORKSPACE/bazel-bin/backend/backend.deploy test-gae-bazel
Cannot stat file /private/var/folders/3v/vr09tqmx6t3bkzc046mzdb84007nxl/T/war.9u3YywA3/./WEB-INF: No such file or directory
Cannot stat file /private/var/folders/3v/vr09tqmx6t3bkzc046mzdb84007nxl/T/war.9u3YywA3/./WEB-INF/lib: No such file or directory
/Users/steren/work/test-bazel-gae/examples/tutorial//bazel-bin/backend/backend.deploy: line 38: /Users/steren/work/test-bazel-gae/examples/tutorial//bazel-bin/backend/backend.runfiles/__main__/../com_google_appengine_java/appengine-java-sdk-1.9.38//bin/appcfg.sh: No such file or directory

@kchodorow said in this PR:

it looks like it's using AppEngine 1.9.38, not 1.9.48 (which is what rule_appengine 0.0.5 specifies). > Is it possible you're using an older version of rules_appengine (maybe overriding the version in your WORKSPACE file)?

My answer is: I am just following the tutorial and have no real idea of what I am doing. I did not specify myself an sdk version.
However, I note the presence of an appengine.BUILD next to my WORKSPACE file in the sample code I download for the tutorial: https://github.com/bazelbuild/examples/blob/source-only/tutorial/appengine.BUILD
Is this normal ? Could this be the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.