Skip to content

Commit 71816b9

Browse files
authored
Add initial version of Gradle build files (#403)
* Add initial version of Gradle build files * Bump minimum Auto Service version to rc2 to fix a Windows build issue * Fix quotes in examples build file * Removed explicit gax dependency for annotation processor * Enable Gradle parallel build by default * Set explicit target compatability to Java 1.8 * Reformatted google-ads-examples/build.gradle * Restructure task code, add runMigrationExample task * Remove extraneous comments * Added build artifacts to .gitignore, fixed extraneous whitespace
1 parent 5b704f3 commit 71816b9

13 files changed

Lines changed: 655 additions & 0 deletions

File tree

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,12 @@ google-ads/*/dependency-reduced-pom.xml
4444
## buildnumber-maven-plugin output
4545
buildNumber.properties
4646
google-ads/*/buildNumber.properties
47+
48+
# Gradle build output
49+
.gradle/
50+
buildSrc/.gradle/
51+
buildSrc/build/
52+
google-ads-annotation-processing/build/
53+
google-ads-examples/build/
54+
google-ads-migration-examples/build/
55+
google-ads/build/

buildSrc/build.gradle

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* This configuration specifies gradle plugins for all Google Ads Java library
17+
* subprojects.
18+
*/
19+
20+
plugins {
21+
id 'groovy-gradle-plugin'
22+
}
23+
24+
repositories {
25+
gradlePluginPortal()
26+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* These are shared settings common to all Google Ads Java library subprojects.
17+
*/
18+
19+
plugins {
20+
id 'java-library'
21+
id 'maven-publish'
22+
}
23+
24+
repositories {
25+
mavenLocal()
26+
mavenCentral()
27+
}
28+
29+
group = 'com.google.api-ads'
30+
version = '11.0.1-SNAPSHOT'
31+
java.sourceCompatibility = JavaVersion.VERSION_1_8
32+
java.targetCompatibility = JavaVersion.VERSION_1_8
33+
34+
java {
35+
withSourcesJar()
36+
}
37+
38+
publishing {
39+
publications {
40+
maven(MavenPublication) {
41+
from(components.java)
42+
}
43+
}
44+
}
45+
46+
tasks.withType(JavaCompile) {
47+
options.encoding = 'UTF-8'
48+
}
49+
50+
dependencies {
51+
implementation 'com.google.guava:guava:26.0-android'
52+
implementation 'com.google.auto.service:auto-service:1.0-rc2'
53+
implementation 'com.google.api:gax:1.60.1'
54+
implementation 'com.google.api:gax-grpc:1.60.1'
55+
implementation 'com.google.protobuf:protobuf-java:3.14.0'
56+
annotationProcessor 'com.google.auto.service:auto-service:1.0-rc2'
57+
testImplementation 'junit:junit:4.13.1'
58+
}
59+
60+
public class ExampleRunnerTask extends JavaExec {
61+
62+
@Input
63+
public String basePackage = 'com.google.ads.googleads.examples.'
64+
65+
@Optional
66+
@Input
67+
private String exampleArguments
68+
69+
public ExampleRunnerTask() {
70+
group = 'Execution'
71+
description = 'Run a Google Ads API example.'
72+
errorOutput = System.err
73+
}
74+
75+
@Option(option = 'example', description = 'Sets the example to launch and' +
76+
' any arguments. Required for execution. E.g. ' +
77+
'"basicoperations.GetCampaigns --customerId 1234567890"')
78+
public void setExampleArguments(String exampleArguments) {
79+
this.exampleArguments = exampleArguments.trim()
80+
int firstSpaceIndex = this.exampleArguments.indexOf(' ')
81+
82+
// No additional arguments were passed, just the example name.
83+
if (firstSpaceIndex == -1) {
84+
main = basePackage + this.exampleArguments
85+
}
86+
// Otherwise, separate the input and set the arguments to pass to the
87+
// main class.
88+
else {
89+
main = basePackage + this.exampleArguments[0..firstSpaceIndex - 1]
90+
argsString(exampleArguments[(firstSpaceIndex + 1)..-1])
91+
}
92+
}
93+
94+
@TaskAction
95+
@Override
96+
public void exec() {
97+
if (!(exampleArguments?.trim())) {
98+
throw new GradleException('\033[0;31mMissing example!\033[0m ' +
99+
'Please rerun with one provided, e.g. ' +
100+
'\033[0;35m--example="basicoperations.GetCampaigns"\033[0m')
101+
}
102+
logQuietMessage('Running example: ' + main + ', args: ' +
103+
args.toString())
104+
try {
105+
super.exec()
106+
}
107+
catch (Exception e) {
108+
logQuietMessage('\n\033[0;31mrunExample exception!\033[0m Did ' +
109+
'you provide a valid example identifier? E.g. ' +
110+
'\033[0;35m--example="basicoperations.GetCampaigns"\033[0m\n\n' +
111+
e.message)
112+
}
113+
}
114+
115+
public String getExampleArguments() {
116+
return exampleArguments
117+
}
118+
119+
private void logQuietMessage(String message) {
120+
logger.quiet(message)
121+
}
122+
123+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* This is the build configuration for the google-ads-annotation-processing
17+
* subproject.
18+
*/
19+
20+
plugins {
21+
id 'com.google.api-ads.java-conventions'
22+
}
23+
24+
dependencies {
25+
implementation 'com.squareup:javapoet:1.11.1'
26+
implementation 'javax.annotation:javax.annotation-api:1.3.2'
27+
testImplementation 'org.mockito:mockito-all:1.9.5'
28+
}
29+
30+
description = 'Google Ads API client library for Java annotation processor'
31+

google-ads-examples/build.gradle

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* This is the build file for the google-ads-examples subproject. It depends on
17+
* the google-ads subproject.
18+
*
19+
* This project contains examples for using the Google Ads API. You can launch
20+
* examples by navigating to the google-ads-examples folder and running the
21+
* provided runExample gradle task. Note that we recommend running with the
22+
* quiet flag (-q) to reduce screen clutter:
23+
* -- Mac/Linux --
24+
* ./gradlew -q runExample --example='basicoperations.GetCampaigns --customerId 1234567890'
25+
*
26+
* -- Windows --
27+
* gradlew -q runExample --example='basicoperations.GetCampaigns --customerId 1234567890'
28+
*/
29+
30+
plugins {
31+
id 'com.google.api-ads.java-conventions'
32+
}
33+
34+
dependencies {
35+
implementation project(':google-ads')
36+
implementation 'org.apache.commons:commons-lang3:3.11'
37+
implementation 'com.beust:jcommander:1.72'
38+
implementation 'joda-time:joda-time:2.8.2'
39+
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.1'
40+
testImplementation 'org.mockito:mockito-core:2.27.0'
41+
}
42+
43+
description = 'Google Ads API client library for Java examples'
44+
45+
task runExample(type: ExampleRunnerTask) {
46+
classpath = sourceSets.main.runtimeClasspath
47+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* This is the build configuration for the google-ads-migration-examples
17+
* subproject. It depends on the google-ads subproject.
18+
*/
19+
20+
plugins {
21+
id 'com.google.api-ads.java-conventions'
22+
}
23+
24+
dependencies {
25+
implementation project(':google-ads')
26+
implementation 'com.google.api-ads:ads-lib:4.4.0'
27+
implementation 'com.google.api-ads:adwords-axis:4.4.0'
28+
implementation 'com.beust:jcommander:1.72'
29+
implementation 'joda-time:joda-time:2.8.2'
30+
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.1'
31+
testImplementation 'org.mockito:mockito-core:2.27.0'
32+
}
33+
34+
description = 'Google Ads API client library for Java migration examples'
35+
36+
task runMigrationExample(type: ExampleRunnerTask) {
37+
classpath = sourceSets.main.runtimeClasspath
38+
basePackage = 'com.google.ads.googleads.migration.'
39+
}

google-ads/build.gradle

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* This is the build configuration for the google-ads-java subproject. It depends
17+
* on the google-ads-annotation-processing subproject.
18+
*/
19+
20+
plugins {
21+
id 'com.google.api-ads.java-conventions'
22+
id 'com.google.protobuf' version "0.8.15"
23+
}
24+
25+
sourceSets {
26+
test {
27+
proto {
28+
srcDir 'src/test/resources/protos/'
29+
}
30+
}
31+
}
32+
33+
protobuf {
34+
protoc {
35+
artifact = 'com.google.protobuf:protoc:3.15.0-rc-1'
36+
}
37+
}
38+
39+
dependencies {
40+
implementation 'io.netty:netty-tcnative-boringssl-static:2.0.26.Final'
41+
implementation 'org.slf4j:slf4j-api:1.7.25'
42+
implementation project(':google-ads-annotation-processing')
43+
annotationProcessor project(':google-ads-annotation-processing')
44+
annotationProcessor "com.google.auto.value:auto-value:1.7.3"
45+
testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0'
46+
testImplementation 'org.mockito:mockito-all:1.9.5'
47+
testImplementation 'com.google.api:gax-grpc:1.60.1:testlib'
48+
testImplementation 'io.grpc:grpc-context:1.30.0'
49+
testImplementation 'com.google.truth:truth:0.27'
50+
testImplementation 'com.google.auto.value:auto-value-annotations:1.7.3'
51+
}
52+
53+
description = 'Google Ads API client library for Java'
54+

gradle.properties

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# These are global settings for the gradle build process.
17+
18+
org.gradle.jvmargs=-Xmx5g -XX:MaxMetaspaceSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
19+
org.gradle.caching=true
20+
org.gradle.console=rich
21+
org.gradle.parallel=true
22+

gradle/wrapper/gradle-wrapper.jar

57.8 KB
Binary file not shown.
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.7.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)