1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16- # TODO: remove java-core once we figure out how setup_cloud understands Maven's
17- # "--also-make-dependents" option. https://github.com/googleapis/google-cloud-java/issues/9088
18- excluded_modules=(' gapic-libraries-bom' ' google-cloud-jar-parent' ' google-cloud-pom-parent' ' java-core' )
16+ excluded_modules=(' gapic-libraries-bom' ' google-cloud-jar-parent' ' google-cloud-pom-parent' )
1917
2018function retry_with_backoff {
2119 attempts_left=$1
@@ -128,46 +126,48 @@ function generate_modified_modules_list() {
128126function run_integration_tests() {
129127 printf " Running Integration Tests for:\n%s\n" " $1 "
130128 # --also-make-dependents to run other modules that use the affected module
131- mvn -B ${INTEGRATION_TEST_ARGS} \
132- -pl " $1 " \
133- --also-make-dependents \
134- -ntp \
135- -Penable-integration-tests \
129+ mvn verify -Penable-integration-tests --projects " $1 " \
130+ ${INTEGRATION_TEST_ARGS} \
131+ -B -ntp -fae \
136132 -DtrimStackTrace=false \
137133 -Dclirr.skip=true \
138134 -Denforcer.skip=true \
139- -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
135+ -Dorg.slf4j.simpleLogger.showDateTime=true \
136+ -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
140137 -Dcheckstyle.skip=true \
141138 -Dflatten.skip=true \
142139 -Danimal.sniffer.skip=true \
143140 -Djacoco.skip=true \
144141 -DskipUnitTests=true \
145142 -Dmaven.wagon.http.retryHandler.count=5 \
146- -fae \
147- -T 1C \
148- verify
143+ -T 1C
149144
150145 RETURN_CODE=$?
151146 printf " Finished Integration Tests for:\n%s\n" " $1 "
152147}
153148
154149function run_graalvm_tests() {
155- printf " Running GraalVM ITs on:\n%s\n" " $1 "
150+ IFS=, read -ra individual_modules <<< " $1"
151+ projects_to_install=()
152+ for module in " ${individual_modules[@]} " ; do
153+ p=$( echo " $module " | cut -d ' -' -f2-) # Convert from 'java-x-y-z' to 'x-y-z'
154+ projects_to_install+=(" java-$p /google-cloud-$p " ); # Create reference to GAPIC project
155+ done
156+ IFS=, gapic_projects=" ${projects_to_install[*]} " # Convert to comma-separated string
157+
158+ printf " Running GraalVM ITs on:\n%s\n" " $gapic_projects "
156159
157- mvn -B ${INTEGRATION_TEST_ARGS} \
158- -pl " $1 " \
159- --also-make-dependents \
160- -ntp \
160+ mvn test -Pnative --projects " $gapic_projects " \
161+ ${INTEGRATION_TEST_ARGS} \
162+ -B -ntp -fae \
161163 -DtrimStackTrace=false \
162164 -Dclirr.skip=true \
163165 -Denforcer.skip=true \
164- -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
166+ -Dorg.slf4j.simpleLogger.showDateTime=true \
167+ -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
165168 -Dcheckstyle.skip=true \
166169 -Dflatten.skip=true \
167- -Danimal.sniffer.skip=true \
168- -Pnative \
169- -fae \
170- test
170+ -Danimal.sniffer.skip=true
171171
172172 RETURN_CODE=$?
173173 printf " Finished Unit and Integration Tests for GraalVM:\n%s\n" " $1 "
@@ -176,7 +176,7 @@ function run_graalvm_tests() {
176176function generate_graalvm_presubmit_modules_list() {
177177 modules_assigned_list=()
178178 generate_modified_modules_list
179- if [[ ${# modified_module_list[@]} -gt 0 && ${# modified_module_list[@]} -lt 10 ]]; then
179+ if [[ ${# modified_module_list[@]} -gt 0 && ${# modified_module_list[@]} -lt 5 ]]; then
180180 # If only a few modules have been modified, focus presubmit testing only on them.
181181 module_list=$(
182182 IFS=,
@@ -229,18 +229,56 @@ function generate_graalvm_modules_list() {
229229}
230230
231231function install_modules() {
232- retry_with_backoff 3 10 \
233- mvn -B \
234- -ntp \
235- -DtrimStackTrace=false \
236- -Dclirr.skip=true \
237- -Denforcer.skip=true \
238- -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
239- -Dcheckstyle.skip=true \
240- -Dflatten.skip=true \
241- -Danimal.sniffer.skip=true \
242- -DskipTests=true \
243- -Djacoco.skip=true \
244- -T 1C \
245- install
232+ if [ -z " $1 " ]; then
233+ mvn install \
234+ -B -ntp \
235+ -DtrimStackTrace=false \
236+ -Dclirr.skip=true \
237+ -Denforcer.skip=true \
238+ -Dorg.slf4j.simpleLogger.showDateTime=true \
239+ -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
240+ -Dcheckstyle.skip=true \
241+ -Dflatten.skip=true \
242+ -Danimal.sniffer.skip=true \
243+ -DskipTests=true \
244+ -Djacoco.skip=true \
245+ -T 1C
246+ else
247+ IFS=, read -ra individual_modules <<< " $1"
248+ projects_to_install=()
249+ for module in " ${individual_modules[@]} " ; do
250+ p=$( echo " $module " | cut -d ' -' -f2-) # Convert from 'java-x-y-z' to 'x-y-z'
251+ projects_to_install+=(" java-$p /google-cloud-$p " ); # Create reference to GAPIC project
252+ done
253+ IFS=, gapic_projects=" ${projects_to_install[*]} " # Convert to comma-separated string
254+
255+ # When working with a maven multi-module project containing other multi-module projects,
256+ # to build a module with its dependencies and without building its dependents:
257+ # Perform the install command on a grandchild module with the --also-make flag.
258+ #
259+ # Examples:
260+ #
261+ # mvn install --projects java-asset --also-make
262+ # ! Does not work. Maven reactor will not build java-asset's child modules, such as the
263+ # gapic, proto, and grpc modules.
264+ #
265+ # mvn install --projects java-kms --also-make-dependents
266+ # ! Does not work. Maven reactor will include java-kmsinventory in its build.
267+ #
268+ # mvn install --projects java-kms/google-cloud-kms --also-make
269+ # Correctly builds dependencies without building dependents.
270+ mvn install --projects " $gapic_projects " --also-make \
271+ -B -ntp \
272+ -DtrimStackTrace=false \
273+ -Dclirr.skip=true \
274+ -Denforcer.skip=true \
275+ -Dorg.slf4j.simpleLogger.showDateTime=true \
276+ -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \
277+ -Dcheckstyle.skip=true \
278+ -Dflatten.skip=true \
279+ -Danimal.sniffer.skip=true \
280+ -DskipTests=true \
281+ -Djacoco.skip=true \
282+ -T 1C
283+ fi
246284}
0 commit comments