/*
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * This is the build file for the google-ads-examples subproject. It depends on
 * the google-ads subproject.
 *
 * This project contains examples for using the Google Ads API. You can interact
 * with the examples by running the provided listExamples and runExample gradle
 * tasks. Note that we recommend running with the quiet flag (-q) to reduce
 * screen clutter:
 *   -- Mac/Linux --
 *   ./gradlew -q runExample --example='basicoperations.GetCampaigns --customerId 1234567890'
 *   ./gradlew -q listExamples
 *   ./gradlew -q listExamples --subdirectory="basicoperations"
 *
 *   -- Windows --
 *   gradlew -q runExample --example='basicoperations.GetCampaigns --customerId 1234567890'
 *   gradlew -q listExamples
 *   gradlew -q listExamples --subdirectory="basicoperations"
 *
 * The listExamples task can also search for a specific term in example names
 * and descriptions using the --search argument. Note that these search terms
 * are case-sensitive:
 *  ./gradlew -q listExamples --subdirectory="basicoperations" --searchTerm="REMOVE"
 */

plugins {
  id 'com.google.api-ads.java-conventions'
  id 'org.jreleaser'
}

// This configuration block is needed to override the configuration in
// java-conventions so we do not publish the examples to maven.
jreleaser {
  project {
    gitRootSearch = true // Allow JReleaser to search upwards for .git
  }
  signing {
    active = 'ALWAYS'
    armored = true
  }
  deploy {
    maven {
      mavenCentral {
        sonatype {
          /** Warning: In your JReleaser config file set
           * JRELEASER_MAVENCENTRAL_STAGE to 'UPLOAD' in order to
           * prevent the deployment from automatically publishing
           * without any UI intervention. */
          active = 'NEVER'
          url = 'https://central.sonatype.com/api/v1/publisher'
          stagingRepository(layout.buildDirectory.dir("staging-deploy").get().toString())
          stage = 'UPLOAD'
        }
      }
      release {
        github {
          skipRelease = true
          skipTag = true
        }
      }
    }
  }
}

dependencies {
  implementation project(':google-ads')
  implementation 'com.beust:jcommander:1.72'
  implementation 'joda-time:joda-time:2.8.2'
  runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.16.0'
  testImplementation 'org.mockito:mockito-core:4.11.0'
  testImplementation 'org.hamcrest:hamcrest:2.2'
}

description = 'Google Ads API client library for Java examples'

task runExample(type: ExampleRunnerTask) {
  classpath = sourceSets.main.runtimeClasspath
}

task listExamples(type: ListExamplesTask)
