apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'

esplugin {
  description = 'The Google Compute Engine (GCE) Discovery plugin allows to use GCE API for the unicast discovery mechanism.'
  classname ='org.elasticsearch.plugin.discovery.gce.GceDiscoveryPlugin'
}

versions << [
  'google'              : '1.41.1',
  'google_api_client'   : '1.33.1',
  'api_services_compute': 'v1-rev20220322-1.32.1'
]

dependencies {
  api "com.google.apis:google-api-services-compute:${versions.api_services_compute}"
  api "com.google.api-client:google-api-client:${versions.google_api_client}"
  api "com.google.oauth-client:google-oauth-client:${versions.google_oauth_client}"
  api "com.google.http-client:google-http-client:${versions.google}"
  api "com.google.http-client:google-http-client-jackson2:${versions.google}"
  api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
  api "com.google.http-client:google-http-client-gson:${versions.google}"
  api 'com.google.code.findbugs:jsr305:3.0.2'
  api "commons-logging:commons-logging:${versions.commonslogging}"
  api "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
  api "commons-codec:commons-codec:${versions.commonscodec}"

  runtimeOnly 'com.google.guava:guava:32.0.1-jre'
  runtimeOnly 'com.google.guava:failureaccess:1.0.1'
  api 'io.opencensus:opencensus-api:0.30.0'
  api 'io.opencensus:opencensus-contrib-http-util:0.30.0'
  api 'io.grpc:grpc-context:1.27.2'
}

restResources {
  restApi {
    include '_common', 'cluster', 'nodes'
  }
}

tasks.named("dependencyLicenses").configure {
  mapping from: /opencensus.*/, to: 'opencensus'
  mapping from: /google-.*/, to: 'google'
  mapping from: /jackson-.*/, to: 'jackson'
}

esplugin.bundleSpec.from('config/discovery-gce') {
  into 'config'
}

tasks.named("test").configure {
  // this is needed for insecure plugins, remove if possible!
  systemProperty 'tests.artifact', project.name
}

tasks.named("thirdPartyAudit").configure {
  ignoreMissingClasses(
          // classes are missing
          'javax.servlet.ServletContextEvent',
          'javax.servlet.ServletContextListener',
          'org.apache.avalon.framework.logger.Logger',
          'org.apache.log.Hierarchy',
          'org.apache.log.Logger',
          'org.apache.avalon.framework.logger.Logger',
          'javax.jms.Message',
          'org.apache.http.ConnectionReuseStrategy',
          'org.apache.http.Header',
          'org.apache.http.HttpEntity',
          'org.apache.http.HttpEntityEnclosingRequest',
          'org.apache.http.HttpHost',
          'org.apache.http.HttpRequest',
          'org.apache.http.HttpResponse',
          'org.apache.http.HttpVersion',
          'org.apache.http.RequestLine',
          'org.apache.http.StatusLine',
          'org.apache.http.client.AuthenticationHandler',
          'org.apache.http.client.HttpClient',
          'org.apache.http.client.HttpRequestRetryHandler',
          'org.apache.http.client.RedirectHandler',
          'org.apache.http.client.RequestDirector',
          'org.apache.http.client.UserTokenHandler',
          'org.apache.http.client.methods.HttpEntityEnclosingRequestBase',
          'org.apache.http.client.methods.HttpRequestBase',
          'org.apache.http.config.Registry',
          'org.apache.http.config.RegistryBuilder',
          'org.apache.http.config.SocketConfig',
          'org.apache.http.config.SocketConfig$Builder',
          'org.apache.http.conn.ClientConnectionManager',
          'org.apache.http.conn.ConnectionKeepAliveStrategy',
          'org.apache.http.conn.params.ConnManagerParams',
          'org.apache.http.conn.params.ConnRouteParams',
          'org.apache.http.conn.routing.HttpRoutePlanner',
          'org.apache.http.conn.scheme.PlainSocketFactory',
          'org.apache.http.conn.scheme.SchemeRegistry',
          'org.apache.http.conn.socket.PlainConnectionSocketFactory',
          'org.apache.http.conn.ssl.SSLSocketFactory',
          'org.apache.http.conn.ssl.X509HostnameVerifier',
          'org.apache.http.entity.AbstractHttpEntity',
          'org.apache.http.impl.client.DefaultHttpClient',
          'org.apache.http.impl.client.HttpClientBuilder',
          'org.apache.http.impl.conn.PoolingHttpClientConnectionManager',
          'org.apache.http.params.HttpConnectionParams',
          'org.apache.http.params.HttpParams',
          'org.apache.http.params.HttpProtocolParams',
          'org.apache.http.protocol.HttpContext',
          'org.apache.http.protocol.HttpProcessor',
          'org.apache.http.protocol.HttpRequestExecutor',
          'com.google.api.client.http.apache.v2.ApacheHttpTransport',
          'com.google.gson.stream.JsonReader',
          'com.google.gson.stream.JsonToken',
          'com.google.gson.stream.JsonWriter'
  )

  ignoreViolations(
          'com.google.common.cache.Striped64',
          'com.google.common.cache.Striped64$1',
          'com.google.common.cache.Striped64$Cell',
          'com.google.common.hash.LittleEndianByteArray$UnsafeByteArray',
          'com.google.common.hash.LittleEndianByteArray$UnsafeByteArray$1',
          'com.google.common.hash.LittleEndianByteArray$UnsafeByteArray$2',
          'com.google.common.hash.Striped64',
          'com.google.common.hash.Striped64$1',
          'com.google.common.hash.Striped64$Cell',
          'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator',
          'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1',
          'com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper',
          'com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper$1'
  )
}
