@@ -25,4 +25,106 @@ information on using pull requests.
25
25
## Community Guidelines
26
26
27
27
This project follows
28
- [ Google's Open Source Community Guidelines] ( https://opensource.google.com/conduct/ ) .
28
+ [ Google's Open Source Community Guidelines] ( https://opensource.google.com/conduct/ ) .
29
+
30
+ ## Building the project
31
+
32
+ To build, package, and run all unit tests run the command
33
+
34
+ ```
35
+ mvn clean verify
36
+ ```
37
+
38
+ ### Running Integration tests
39
+
40
+ To include integration tests when building the project, you need access to
41
+ a GCP Project with a valid service account.
42
+
43
+ For instructions on how to generate a service account and corresponding
44
+ credentials JSON see: [ Creating a Service Account] [ 1 ] .
45
+
46
+ Then run the following to build, package, run all unit tests and run all
47
+ integration tests.
48
+
49
+ ``` bash
50
+ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
51
+ mvn -Penable-integration-tests clean verify
52
+ ```
53
+
54
+ ## Code Samples
55
+
56
+ Code Samples must be bundled in separate Maven modules, and guarded by a
57
+ Maven profile with the name ` enable-samples ` .
58
+
59
+ The samples must be separate from the primary project for a few reasons:
60
+ 1 . Primary projects have a minimum Java version of Java 7 whereas samples have
61
+ a minimum Java version of Java 8. Due to this we need the ability to
62
+ selectively exclude samples from a build run.
63
+ 2 . Many code samples depend on external GCP services and need
64
+ credentials to access the service.
65
+ 3 . Code samples are not released as Maven artifacts and must be excluded from
66
+ release builds.
67
+
68
+ ### Building
69
+
70
+ ``` bash
71
+ mvn -Penable-samples clean verify
72
+ ```
73
+
74
+ Some samples require access to GCP services and require a service account:
75
+
76
+ ``` bash
77
+ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
78
+ mvn -Penable-samples clean verify
79
+ ```
80
+
81
+ ### Profile Config
82
+
83
+ 1 . To add samples in a profile to your Maven project, add the following to your
84
+ ` pom.xml `
85
+
86
+ ```xml
87
+ <project>
88
+ [...]
89
+ <profiles>
90
+ <profile>
91
+ <id>enable-samples</id>
92
+ <modules>
93
+ <module>sample</module>
94
+ </modules>
95
+ </profile>
96
+ </profiles>
97
+ [...]
98
+ </project>
99
+ ```
100
+
101
+ 2 . [ Activate] ( #profile-activation ) the profile.
102
+ 3 . Define your samples in a normal Maven project in the ` samples/ ` directory
103
+
104
+ ### Profile Activation
105
+
106
+ To include code samples when building and testing the project, enable the
107
+ ` enable-samples ` Maven profile.
108
+
109
+ #### Command line
110
+
111
+ To activate the Maven profile on the command line add ` -Penable-samples ` to your
112
+ Maven command.
113
+
114
+ #### Maven ` settings.xml `
115
+
116
+ To activate the Maven profile in your ` ~/.m2/settings.xml ` add an entry of
117
+ ` enable-samples ` following the instructions in [ Active Profiles] [ 2 ] .
118
+
119
+ This method has the benefit of applying to all projects you build (and is
120
+ respected by IntelliJ IDEA) and is recommended if you are going to be
121
+ contributing samples to several projects.
122
+
123
+ #### IntelliJ IDEA
124
+
125
+ To activate the Maven Profile inside IntelliJ IDEA, follow the instructions in
126
+ [ Activate Maven profiles] [ 3 ] to activate ` enable-samples ` .
127
+
128
+ [ 1 ] : https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account
129
+ [ 2 ] : https://maven.apache.org/settings.html#Active_Profiles
130
+ [ 3 ] : https://www.jetbrains.com/help/idea/work-with-maven-profiles.html#activate_maven_profiles
0 commit comments