# Copyright (C) 2013 The Android Open Source Project
#
# 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.
#
# Fetch artifacts from Maven repository
#
# name: (required) The name of the rule.
# id: (required) Maven group id, artifact id and version in the form: g:a:v
# exclude: (defaults to []) Rules to exlude from resulting maven JAR
# exclude_java_sources: (default to False) should java source be included
# unsign: (default to False): should this archive be unsigned
# deps: (defaults to []) Rules (usually other java_library rules) that are
#        included as transitive dependency of this Maven JAR
# exported_deps: (defaults to []) Whether or not depending on this rule should
#        also transitively pull in all of its dependencies.
# sha1: SHA-1 of binary artifact
# bin_sha1: SHA-1 of binary artifact
# src_sha1: SHA-1 of src artifact
# repository: (default to MAVEN_CENTRAL) repository name
# attach_source: (default to True): should the sources be fetched
# visibility (defaults to ['PUBLIC']) List of build target patterns that
# identify the build rules that can include this rule in its deps.
#
# Example:
#
# maven_jar(
#   name = 'guava',
#   id = 'com.google.guava:guava:16.0',
#   sha1 = 'aca09d2e5e8416bf91550e72281958e35460be52',
# )
#
# @See: https://github.com/facebook/buck/issues/64
#

GERRIT = 'GERRIT:'
GERRIT_API = 'GERRIT_API:'
ECLIPSE = 'ECLIPSE:'
MAVEN_CENTRAL = 'MAVEN_CENTRAL:'
MAVEN_LOCAL = 'MAVEN_LOCAL:'

def maven_jar(
    name,
    id,
    license = '',
    exclude = [],
    exclude_java_sources = False,
    unsign = False,
    deps = [],
    exported_deps = [],
    sha1 = '', bin_sha1 = '', src_sha1 = '',
    repository = MAVEN_CENTRAL,
    attach_source = True,
    visibility = ['PUBLIC']):
  from os import path

  parts = id.split(':')
  if len(parts) != 3:
    raise NameError('expected id="groupId:artifactId:version"')
  group, artifact, version = parts

  if 'SNAPSHOT' in version and repository.startswith(GERRIT):
    file_version = version.replace('-SNAPSHOT', '')
    version = version.split('-SNAPSHOT')[0] + '-SNAPSHOT'
  else:
    file_version = version

  jar = path.join(name, artifact.lower() + '-' + file_version)
  url = '/'.join([
    repository,
    group.replace('.', '/'), artifact, version,
    artifact + '-' + file_version])

  binjar = jar + '.jar'
  binurl = url + '.jar'

  srcjar = jar + '-src.jar'
  srcurl = url + '-sources.jar'

  cmd = ['$(exe //bucklets/tools:download_file)', '-o', '$OUT', '-u', binurl]
  if sha1:
    cmd.extend(['-v', sha1])
  elif bin_sha1:
    cmd.extend(['-v', bin_sha1])
  for x in exclude:
    cmd.extend(['-x', x])
  if exclude_java_sources:
    cmd.append('--exclude_java_sources')
  if unsign:
    cmd.append('--unsign')

  genrule(
    name = name + '__download_bin',
    cmd = ' '.join(cmd),
    deps = ['//bucklets/tools:download_file'],
    out = binjar,
  )

  if src_sha1 or attach_source:
    cmd = ['$(exe //bucklets/tools:download_file)', '-o', '$OUT', '-u', srcurl]
    if src_sha1:
      cmd.extend(['-v', src_sha1])
    genrule(
      name = name + '__download_src',
      cmd = ' '.join(cmd),
      deps = ['//bucklets/tools:download_file'],
      out = srcjar,
    )
    prebuilt_jar(
      name = name + '_src',
      binary_jar = ':' + name + '__download_src',
      visibility = visibility,
    )
  else:
    srcjar = None
    genrule(
      name = name + '__download_src',
      cmd = ':>$OUT',
      out = '__' + name + '__no_src',
    )

  if exported_deps:
    prebuilt_jar(
      name = name + '__jar',
      deps = deps,
      binary_jar = ':' + name + '__download_bin',
      source_jar = ':' + name + '__download_src' if srcjar else None,
    )
    java_library(
      name = name,
      exported_deps = exported_deps + [':' + name + '__jar'],
      visibility = visibility,
    )
  else:
    prebuilt_jar(
      name = name,
      deps = deps,
      binary_jar = ':' + name + '__download_bin',
      source_jar = ':' + name + '__download_src' if srcjar else None,
      visibility = visibility,
    )
