plugins {
  id 'net.researchgate.release'
  id 'maven-publish'
  id 'eclipse'
}

java {
  // Feature to handle base image layers compressed with zstd instead of gzip
  // Will need to re-assess the optional dependency when zstd becomes widely used
  registerFeature('zstdSupport') {
    usingSourceSet(sourceSets.main)
  }
}

dependencies {
  api dependencyStrings.BUILD_PLAN
  implementation dependencyStrings.GOOGLE_HTTP_CLIENT
  implementation dependencyStrings.GOOGLE_HTTP_CLIENT_APACHE_V2
  implementation dependencyStrings.GOOGLE_AUTH_LIBRARY_OAUTH2_HTTP

  implementation dependencyStrings.COMMONS_COMPRESS
  zstdSupportImplementation  dependencyStrings.ZSTD_JNI
  implementation dependencyStrings.GUAVA
  implementation(platform(dependencyStrings.JACKSON_BOM))
  implementation dependencyStrings.JACKSON_DATABIND
  implementation dependencyStrings.JACKSON_DATATYPE_JSR310
  implementation dependencyStrings.ASM

  testImplementation dependencyStrings.JUNIT
  testImplementation dependencyStrings.TRUTH
  testImplementation dependencyStrings.TRUTH8
  testImplementation dependencyStrings.MOCKITO_CORE
  testImplementation dependencyStrings.SLF4J_API
  testImplementation dependencyStrings.SYSTEM_RULES
  testImplementation dependencyStrings.ZSTD_JNI

  integrationTestImplementation dependencyStrings.JBCRYPT
}

jar {
  manifest {
    attributes 'Implementation-Version': archiveVersion
    attributes 'Automatic-Module-Name': 'com.google.cloud.tools.jib'

    // OSGi metadata
    attributes 'Bundle-SymbolicName': 'com.google.cloud.tools.jib'
    attributes 'Bundle-Name': 'Jib library for building Docker and OCI images'
    attributes 'Bundle-Vendor': 'Google LLC'
    attributes 'Bundle-DocURL': 'https://github.com/GoogleContainerTools/jib'
    attributes 'Bundle-License': 'https://www.apache.org/licenses/LICENSE-2.0'
    attributes 'Export-Package': 'com.google.cloud.tools.jib.*'
  }
}

/* RELEASE */
configureMavenRelease()

publishing {
  publications {
    mavenJava(MavenPublication) {
      pom {
        name = 'Jib Core'
        description = 'Build container images.'
      }
      from components.java
    }
  }
}

// Release plugin (git release commits and version updates)
release {
  tagTemplate = 'v$version-core'
  git {
    requireBranch = /^core-release-v\d+.*$/  //regex
  }
}
/* RELEASE */

/* ECLIPSE */
eclipse.classpath.plusConfigurations += [configurations.integrationTestImplementation]
/* ECLIPSE */
