# 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,
    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:
    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 = genfile(srcjar),
      deps = [':' + name + '__download_src'],
      visibility = visibility,
    )
  else:
    srcjar = None
    genrule(
      name = name + '__download_src',
      cmd = ':>$OUT',
      out = '__' + name + '__no_src',
    )

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