Skip to content

Commit 6293149

Browse files
authored
Helloworld with Gradle (GoogleCloudPlatform#3418)
* Helloworld with Gradle * removed unnecessary bits
1 parent eab1715 commit 6293149

7 files changed

Lines changed: 449 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ dependency-reduced-pom.xml
2929
buildNumber.properties
3030
.checkstyle
3131

32+
# gradle
33+
build/
34+
3235
# Secrets
3336
service-account.json
3437
secrets.env
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2020 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+
15+
// [START functions_example_pom_dependencies]
16+
// [START functions_build_gradle]
17+
apply plugin: 'java'
18+
19+
repositories {
20+
jcenter()
21+
mavenCentral()
22+
}
23+
configurations {
24+
invoker
25+
}
26+
27+
dependencies {
28+
// Every function needs this dependency to get the Functions Framework API.
29+
compileOnly 'com.google.cloud.functions:functions-framework-api:1.0.1'
30+
31+
// To run function locally using Functions Framework's local invoker
32+
invoker 'com.google.cloud.functions.invoker:java-function-invoker:1.0.0-alpha-2-rc5'
33+
// [END functions_example_pom_dependencies]
34+
35+
// These dependencies are only used by the tests.
36+
testImplementation 'com.google.cloud.functions:functions-framework-api:1.0.1'
37+
testImplementation 'junit:junit:4.12'
38+
testImplementation 'com.google.truth:truth:1.0.1'
39+
testImplementation 'org.mockito:mockito-core:3.4.0'
40+
41+
// [START functions_example_pom_dependencies]
42+
}
43+
44+
// Register a "runFunction" task to run the function locally
45+
tasks.register("runFunction", JavaExec) {
46+
main = 'com.google.cloud.functions.invoker.runner.Invoker'
47+
classpath(configurations.invoker)
48+
inputs.files(configurations.runtimeClasspath, sourceSets.main.output)
49+
args(
50+
'--target', project.findProperty('runFunction.target'),
51+
'--port', project.findProperty('runFunction.port') ?: 8080
52+
)
53+
doFirst {
54+
args('--classpath', files(configurations.runtimeClasspath, sourceSets.main.output).asPath)
55+
}
56+
}
57+
// [END functions_build_gradle]
58+
// [END functions_example_pom_dependencies]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

functions/helloworld/helloworld-gradle/gradlew

Lines changed: 185 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

functions/helloworld/helloworld-gradle/gradlew.bat

Lines changed: 104 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)