1717 */
1818
1919plugins {
20- id ' java-library'
21- id ' maven-publish'
20+ id ' java-library'
21+ id ' maven-publish'
2222}
2323
2424repositories {
25- mavenLocal()
26- mavenCentral()
25+ mavenLocal()
26+ mavenCentral()
2727}
2828
2929group = ' com.google.api-ads'
@@ -32,92 +32,93 @@ java.sourceCompatibility = JavaVersion.VERSION_1_8
3232java. targetCompatibility = JavaVersion . VERSION_1_8
3333
3434java {
35- withSourcesJar()
35+ withSourcesJar()
36+ withJavadocJar()
3637}
3738
3839publishing {
39- publications {
40- maven(MavenPublication ) {
41- from(components. java)
42- }
40+ publications {
41+ maven(MavenPublication ) {
42+ from(components. java)
4343 }
44+ }
4445}
4546
4647tasks. withType(JavaCompile ) {
47- options. encoding = ' UTF-8'
48+ options. encoding = ' UTF-8'
4849}
4950
5051dependencies {
51- implementation ' com.google.guava:guava:30.0-android'
52- implementation ' com.google.auto.service:auto-service:1.0-rc2'
53- implementation ' com.google.api:gax:1.65.1'
54- implementation ' com.google.api:gax-grpc:1.65.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'
52+ implementation ' com.google.guava:guava:30.0-android'
53+ implementation ' com.google.auto.service:auto-service:1.0-rc2'
54+ implementation ' com.google.api:gax:1.65.1'
55+ implementation ' com.google.api:gax-grpc:1.65.1'
56+ implementation ' com.google.protobuf:protobuf-java:3.14.0'
57+ annotationProcessor ' com.google.auto.service:auto-service:1.0-rc2'
58+ testImplementation ' junit:junit:4.13.1'
5859}
5960
6061public class ExampleRunnerTask extends JavaExec {
6162
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
63+ @Input
64+ public String basePackage = ' com.google.ads.googleads.examples.'
65+
66+ @Optional
67+ @Input
68+ private String exampleArguments
69+
70+ public ExampleRunnerTask () {
71+ group = ' Execution'
72+ description = ' Run a Google Ads API example.'
73+ errorOutput = System . err
74+ }
75+
76+ @Option (option = ' example' , description = ' Sets the example to launch and' +
77+ ' any arguments. Required for execution. E.g. ' +
78+ ' "basicoperations.GetCampaigns --customerId 1234567890"' )
79+ public void setExampleArguments (String exampleArguments ) {
80+ this . exampleArguments = exampleArguments. trim()
81+ int firstSpaceIndex = this . exampleArguments. indexOf(' ' )
82+
83+ // No additional arguments were passed, just the example name.
84+ if (firstSpaceIndex == -1 ) {
85+ main = basePackage + this . exampleArguments
7386 }
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- }
87+ // Otherwise, separate the input and set the arguments to pass to the
88+ // main class.
89+ else {
90+ main = basePackage + this . exampleArguments[0 .. firstSpaceIndex - 1 ]
91+ argsString(exampleArguments[(firstSpaceIndex + 1 ).. -1 ])
9292 }
93-
94- @TaskAction
95- @Override
96- public void exec () {
97- if (! (exampleArguments?. trim())) {
98- throw new GradleException (' \0 33[0;31mMissing example!\0 33[0m ' +
99- ' Please rerun with one provided, e.g. ' +
100- ' \0 33[0;35m--example="basicoperations.GetCampaigns"\0 33[0m' )
101- }
102- logQuietMessage(' Running example: ' + main + ' , args: ' +
103- args. toString())
104- try {
105- super . exec()
106- }
107- catch (Exception e) {
108- logQuietMessage(' \n\0 33[0;31mrunExample exception!\0 33[0m Did ' +
109- ' you provide a valid example identifier? E.g. ' +
110- ' \0 33[0;35m--example="basicoperations.GetCampaigns"\0 33[0m\n\n ' +
111- e. message)
112- }
93+ }
94+
95+ @TaskAction
96+ @Override
97+ public void exec () {
98+ if (! (exampleArguments?. trim())) {
99+ throw new GradleException (' \0 33[0;31mMissing example!\0 33[0m ' +
100+ ' Please rerun with one provided, e.g. ' +
101+ ' \0 33[0;35m--example="basicoperations.GetCampaigns"\0 33[0m' )
113102 }
114-
115- public String getExampleArguments () {
116- return exampleArguments
103+ logQuietMessage(' Running example: ' + main + ' , args: ' +
104+ args. toString())
105+ try {
106+ super . exec()
117107 }
118-
119- private void logQuietMessage (String message ) {
120- logger. quiet(message)
108+ catch (Exception e) {
109+ logQuietMessage(' \n\0 33[0;31mrunExample exception!\0 33[0m Did ' +
110+ ' you provide a valid example identifier? E.g. ' +
111+ ' \0 33[0;35m--example="basicoperations.GetCampaigns"\0 33[0m\n\n ' +
112+ e. message)
121113 }
114+ }
115+
116+ public String getExampleArguments () {
117+ return exampleArguments
118+ }
119+
120+ private void logQuietMessage (String message ) {
121+ logger. quiet(message)
122+ }
122123
123124}
0 commit comments