// Copyright 2017 Google Inc.
//
//  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
//
//        http://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.
// [START gradle]
buildscript {    // Configuration for building
  repositories {
    jcenter()    // Bintray's repository - a fast Maven Central mirror & more
    mavenCentral()
  }
  dependencies {
    classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.5.0' // If a newer version is available, use it
  }
}

repositories {   // repositories for Jar's you access in your code
  maven {
    url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT repository (if needed)
  }
  mavenCentral()
  jcenter()
}

apply plugin: 'java'                              // standard Java tasks
apply plugin: 'war'                               // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine'  // App Engine tasks

dependencies {
  implementation 'com.google.appengine:appengine-api-1.0-sdk:+'  // Latest App Engine Api's
  providedCompile 'javax.servlet:javax.servlet-api:3.1.0'

  implementation 'jstl:jstl:1.2'

// Add your dependencies here.
//  implementation 'com.google.cloud:google-cloud:+'   // Latest Cloud API's http://googlecloudplatform.github.io/google-cloud-java

  testImplementation 'junit:junit:4.13.2'
  testImplementation 'com.google.truth:truth:1.1.5'
  testImplementation 'org.mockito:mockito-core:4.11.0'

  testImplementation 'com.google.appengine:appengine-testing:+'
  testImplementation 'com.google.appengine:appengine-api-stubs:+'
  testImplementation 'com.google.appengine:appengine-tools-sdk:+'
}

// Always run unit tests
appengineDeploy.dependsOn test
appengineStage.dependsOn test

appengine {  // App Engine tasks configuration
  deploy {   // deploy configuration
    projectId = System.getenv('GOOGLE_CLOUD_PROJECT')
    version = '1'
  }
}

test {
  useJUnit()
  testLogging.showStandardStreams = true
  beforeTest { descriptor ->
     logger.lifecycle("test: " + descriptor + "  Running")
  }

  onOutput { descriptor, event ->
     logger.lifecycle("test: " + descriptor + ": " + event.message )
  }
  afterTest { descriptor, result ->
    logger.lifecycle("test: " + descriptor + ": " + result )
  }
}

group   = "com.example.appenginej8"        // Generated output GroupId
version = "1.0-SNAPSHOT"       // Version in generated output

sourceCompatibility = 1.8     // App Engine Flexible uses Java 8
targetCompatibility = 1.8     // App Engine Flexible uses Java 8
// [END gradle]
