8000 feat: Add Makefile for constistent sample interface (#8863) · aristide-n/java-docs-samples@ef36b96 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef36b96

Browse files
authored
feat: Add Makefile for constistent sample interface (GoogleCloudPlatform#8863)
* feat: Add Makefile for constistent sample interface * rename env var to match proposal, add maven flags from CI * use GOOGLE_CLOUD_PROJECT as backup for project id source * add a note about ADCs for usage
1 parent 4dae900 commit ef36b96

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Makefile for running typical developer workflow actions.
2+
# To run actions in a subdirectory of the repo:
3+
# make lint build dir=translate/snippets
4+
# Note: testing requires Application Default Credentials.
5+
# For details about ADC, see https://cloud.google.com/docs/authentication/application-default-credentials
6+
7+
INTERFACE_ACTIONS="build test lint"
8+
9+
.ONESHELL: #ease subdirectory work by using the same subshell for all commands
10+
.-PHONY: *
11+
12+
# Default to current dir if not specified.
13+
dir ?= $(shell pwd)
14+
15+
16+
# GOOGLE_SAMPLES_PROJECT takes precedence over GOOGLE_CLOUD_PROJECT
17+
PROJECT_ID = ${GOOGLE_SAMPLES_PROJECT}
18+
PROJECT_ID ?= ${GOOGLE_CLOUD_PROJECT}
19+
# export our project ID as GOOGLE_CLOUD_PROJECT in the action environment
20+
override GOOGLE_CLOUD_PROJECT := ${PROJECT_ID}
21+
export GOOGLE_CLOUD_PROJECT
22+
23+
build:
24+
cd ${dir}
25+
mvn compile
26+
27+
test: check-env build
28+
cd ${dir}
29+
mvn --quiet --batch-mode --fail-at-end clean verify \
30+
-Dfile.encoding="UTF-8" \
31+
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
32+
-Dmaven.test.redirectTestOutputToFile=true \
33+
-Dbigtable.projectID="${GOOGLE_CLOUD_PROJECT}" \
34+
-Dbigtable.instanceID=instance
35+
36+
lint:
37+
cd ${dir}
38+
mvn -P lint checkstyle:check
39+
40+
check-env:
41+
ifndef PROJECT_ID
42+
$(error At least one of the following env vars must be set: GOOGLE_SAMPLES_PROJECT, GOOGLE_CLOUD_PROJECT.)
43+
endif
44+
45+
list-actions:
46+
@ echo ${INTERFACE_ACTIONS}
47+

0 commit comments

Comments
 (0)
0