|
| 1 | +// Copyright 2017 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +// [START gae_java21_bigtable_gradle_file] |
| 15 | +buildscript { // Configuration for building |
| 16 | + repositories { |
| 17 | + jcenter() // Bintray's repository - a fast Maven Central mirror & more |
| 18 | + mavenCentral() |
| 19 | + } |
| 20 | + dependencies { |
| 21 | + classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.5.0' |
| 22 | + classpath 'org.akhikhl.gretty:gretty:+' |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +apply plugin: 'java' |
| 27 | +apply plugin: 'war' |
| 28 | +apply plugin: 'org.akhikhl.gretty' // To get webappcopy |
| 29 | +apply plugin: 'com.google.cloud.tools.appengine' |
| 30 | + |
| 31 | +group = 'com.example.google.cloud.bigtable' |
| 32 | +version = '0.1-SNAPSHOT' |
| 33 | + |
| 34 | +sourceCompatibility = 21 |
| 35 | +targetCompatibility = 21 |
| 36 | + |
| 37 | +tasks.withType(JavaCompile) { |
| 38 | + options.encoding = 'UTF-8' |
| 39 | +} |
| 40 | + |
| 41 | +repositories { |
| 42 | + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| 43 | + jcenter() |
| 44 | + mavenCentral() |
| 45 | +} |
| 46 | + |
| 47 | +dependencies { |
| 48 | + compile group: 'com.google.cloud.bigtable', name: 'bigtable-hbase-1.2', version:'1.0.0-pre3' |
| 49 | + compile group: 'org.apache.hbase', name: 'hbase-client', version:'2.5.6' |
| 50 | + compile group: 'io.netty', name: 'netty-tcnative-boringssl-static', version:'2.0.62.Final' |
| 51 | + compile group: 'jakarta.servlet.jsp.jstl', name: 'jakarta.servlet.jsp.jstl-api', version:'1.2.7' |
| 52 | + |
| 53 | + providedCompile group: 'jakarta.servlet', name: 'jakarta.servlet-api', version:'4.0.4' |
| 54 | + |
| 55 | + testCompile group: 'com.google.truth', name: 'truth', version:'1.4.4' |
| 56 | + testCompile group: 'junit', name: 'junit', version:'4.13.2' |
| 57 | + testCompile group: 'org.mockito', name: 'mockito-core', version:'4.11.0' |
| 58 | +} |
| 59 | + |
| 60 | +import org.apache.tools.ant.filters.ReplaceTokens |
| 61 | +gretty { |
| 62 | + contextPath = '/' |
| 63 | + servletContainer = 'jetty9' |
| 64 | + |
| 65 | + jvmArgs = [ '-DBIGTABLE_PROJECT=' + System.getProperty("bigtable.projectID"), |
| 66 | + '-DBIGTABLE_INSTANCE=' + System.getProperty("bigtable.instanceID")] |
| 67 | + |
| 68 | + webappCopy { |
| 69 | + // Enable filtering on all xml files in WEB-INF |
| 70 | + filesMatching "**/WEB-INF/*.xml", { FileCopyDetails fileDetails -> |
| 71 | + logger.lifecycle 'File filtered: {}', fileDetails.path |
| 72 | + filter (ReplaceTokens, tokens: [ |
| 73 | + 'bigtable.projectID' : System.getProperty("bigtable.projectID"), |
| 74 | + 'bigtable.instanceID': System.getProperty("bigtable.instanceID") |
| 75 | + ]) |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +// Always run unit tests |
| 81 | +appengineDeploy.dependsOn test |
| 82 | + |
| 83 | +// [START gae_java21_bigtable_gradle_model] |
| 84 | +appengine { |
| 85 | + run { |
| 86 | + |
| 87 | + } |
| 88 | + deploy { // deploy configuration |
| 89 | + stopPreviousVersion = true // default - stop the current version |
| 90 | + promote = true // default - & make this the current version |
| 91 | + } |
| 92 | +} |
| 93 | + |
| 94 | +test { |
| 95 | + useJUnit() |
| 96 | + testLogging.showStandardStreams = true |
| 97 | + |
| 98 | + systemProperty 'BIGTABLE_PROJECT', System.getProperty("bigtable.projectID") |
| 99 | + systemProperty 'BIGTABLE_INSTANCE',System.getProperty("bigtable.instanceID") |
| 100 | + |
| 101 | + beforeTest { descriptor -> |
| 102 | + logger.lifecycle("test: " + descriptor + " Running") |
| 103 | + } |
| 104 | + |
| 105 | + onOutput { descriptor, event -> |
| 106 | + logger.lifecycle("test: " + descriptor + ": " + event.message ) |
| 107 | + } |
| 108 | + afterTest { descriptor, result -> |
| 109 | + logger.lifecycle("test: " + descriptor + ": " + result ) |
| 110 | + } |
| 111 | +} |
| 112 | +// [END gae_java21_bigtable_gradle_model] |
| 113 | +// [END gae_java21_bigtable_gradle_file] |
0 commit comments