Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Get a working 'bazel run test:test-war'. Use workspace_name where nee…
Browse files Browse the repository at this point in the history
…ded to fix deploy template.
  • Loading branch information
pmbethe09 authored and kchodorow committed Jun 3, 2016
1 parent 0103053 commit 8f35721
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 26 deletions.
23 changes: 4 additions & 19 deletions appengine/appengine.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def _war_impl(ctxt):
appengine_sdk = None
for f in ctxt.files._appengine_sdk:
if not appengine_sdk:
appengine_sdk = f.path
appengine_sdk = f.short_path
elif not f.path.startswith(appengine_sdk):
appengine_sdk = _common_substring(appengine_sdk, f.path)
appengine_sdk = _common_substring(appengine_sdk, f.short_path)

classpath = [
"${JAVA_RUNFILES}/%s" % jar.short_path
Expand Down Expand Up @@ -205,10 +205,10 @@ appengine_war = rule(
single_file = True,
),
"_appengine_sdk": attr.label(
default = Label("//external:appengine/java/sdk"),
default = Label("@com_google_appengine_java//:sdk"),
),
"_appengine_jars": attr.label(
default = Label("//external:appengine/java/jars"),
default = Label("@com_google_appengine_java//:jars"),
),
"_appengine_deps": attr.label_list(
default = [Label("@com_google_appengine_java//:api")],
Expand Down Expand Up @@ -265,21 +265,6 @@ def appengine_repositories():
build_file_content = APPENGINE_BUILD_FILE,
)

native.bind(
name = "appengine/java/sdk",
actual = "@com_google_appengine_java//:sdk",
)

native.bind(
name = "appengine/java/api",
actual = "@com_google_appengine_java//:api",
)

native.bind(
name = "appengine/java/jars",
actual = "@com_google_appengine_java//:jars",
)

native.maven_jar(
name = "javax_servlet_api",
artifact = "javax.servlet:servlet-api:2.5",
Expand Down
4 changes: 2 additions & 2 deletions appengine/appengine_deploy.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ root_path=$(pwd)
tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/war.XXXXXXXX)
trap "{ cd ${root_path}; rm -rf ${tmp_dir}; }" EXIT
cd ${tmp_dir}
${JAVA_RUNFILES}/%{zipper} x ${JAVA_RUNFILES}/%{war}
${JAVA_RUNFILES}/%{workspace_name}/%{zipper} x ${JAVA_RUNFILES}/%{workspace_name}/%{war}
cd ${root_dir}

APP_ENGINE_ROOT=${JAVA_RUNFILES}/%{appengine_sdk}
APP_ENGINE_ROOT=${JAVA_RUNFILES}/%{workspace_name}/%{appengine_sdk}
if [ -n "${1-}" ]; then
${APP_ENGINE_ROOT}/bin/appcfg.sh -A "$1" update ${tmp_dir}
retCode=$?
Expand Down
11 changes: 8 additions & 3 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ load("//appengine:appengine.bzl", "appengine_war")
appengine_war(
name = "test-war",
data = [":test-data"],
data_path = "/test",
jars = ["libtest.jar"],
data_path = "/test/data",
jars = [":app_deploy.jar"],
)

java_binary(
name = "app",
main_class = "dummy",
)

filegroup(
Expand All @@ -16,8 +21,8 @@ sh_test(
name = "check_war",
srcs = ["check_war.sh"],
data = [
":test-war",
"@local_jdk//:jar",
"@local_jdk//:jdk-default",
":test-war",
],
)
6 changes: 4 additions & 2 deletions test/check_war.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function assert_war_contains() {
return 1
}

assert_war_contains "./WEB-INF/lib/libtest.jar"
assert_war_contains "./WEB-INF/lib/app_deploy.jar"
assert_war_contains "./WEB-INF/lib/appengine-api.jar"
assert_war_contains "./data/thing1"
assert_war_contains "./WEB-INF/appengine-web.xml"
assert_war_contains "./WEB-INF/web.xml"
assert_war_contains "./welcome.jsp"
9 changes: 9 additions & 0 deletions test/data/WEB-INF/appengine-web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>test-war</application>
<version>1</version>
<threadsafe>true</threadsafe>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
</appengine-web-app>
13 changes: 13 additions & 0 deletions test/data/WEB-INF/logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
#
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:
#
# <system-properties>
# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# </system-properties>
#

# Set the default logging level for all loggers to WARNING
.level = WARNING
11 changes: 11 additions & 0 deletions test/data/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>

</web-app>
Empty file removed test/data/thing1
Empty file.
1 change: 1 addition & 0 deletions test/data/welcome.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
Empty file removed test/libtest.jar
Empty file.

0 comments on commit 8f35721

Please sign in to comment.