Skip to content

Instantly share code, notes, and snippets.

@mateor
Created April 10, 2015 08:21
Show Gist options
  • Save mateor/f6d8584c2845a67bb2a0 to your computer and use it in GitHub Desktop.
Save mateor/f6d8584c2845a67bb2a0 to your computer and use it in GitHub Desktop.
Ivysettings with google and android m2 repos from the Android SDK.
<?xml version="1.0"?>
<!--
Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
Licensed under the Apache License, Version 2.0 (see LICENSE).
-->
<ivysettings>
<property name="root.dir" value="${ivy.settings.dir}/../.." override="false"/>
<property name="ivy.cache.dir" value="${user.home}/.ivy2/pants" override="false"/>
<properties file="${root.dir}/build.properties" override="false"/>
<properties environment="env" />
<settings defaultResolver="chain-repos"/>
<macrodef name="_remote_resolvers">
<chain returnFirst="true">
<ibiblio name="maven2"
m2compatible="true"
usepoms="true"
root="https://repo1.maven.org/maven2/"/>
<!-- This is just for jvm tools used by Pants and not yet published to maven central.
Kill once they are published to maven central. -->
<ibiblio name="pantsbuild-maven-repo"
m2compatible="true"
usepoms="true"
root="https://dl.bintray.com/pantsbuild/maven/"/>
</chain>
</macrodef>
<property name="sbt.repo.relpath" value="[organization]/[module]/[revision]"/>
<property name="sbt.repo.artifact" value="${sbt.repo.relpath}/[type]s/[module].[ext]"/>
<property name="sbt.repo.pom" value="${sbt.repo.relpath}/poms/[module].pom"/>
<property name="m2.repo.relpath" value="[organisation]/[module]/[revision]"/>
<property name="m2.repo.pom" value="${m2.repo.relpath}/[module]-[revision].pom"/>
<property name="m2.repo.artifact"
value="${m2.repo.relpath}/[artifact]-[revision](-[classifier]).[ext]"/>
<property name="sbt.repo.dir" value="${user.home}/.ivy2/local" override="false"/>
<property name="m2.repo.dir" value="${user.home}/.m2/repository" override="false"/>
<property name="env.ANDROID_HOME" value="/please-export-your-ANDROID_HOME" override="false"/>
<property name="android.repo.dir" value="${env.ANDROID_HOME}/extras/android/m2repository"/>
<property name="google.repo.dir" value="${env.ANDROID_HOME}/extras/google/m2repository"/>
<resolvers>
<chain name="chain-repos" returnFirst="true">
<_remote_resolvers name="remote-repos"/>
<!-- Fall back to local repositories
The <filesystem> entries below are examples of how you can have ivy read from your
local maven or sbt repos, primarily for getting -SNAPSHOTs to work when working
with two different build systems. If you don't need this feature, you might be
better off leaving them commented out. They can cause problems when your local
repository diverges from remote repositories.
NB: there is deep ivy magic working here and many stars must align to get -SNAPSHOTs
picked up as they change:
1.) A filesystem resolver must be used (as opposed to an ibiblio resolver with a file
url).
2.) The filesystem resolver ivy pattern must be a pom pattern and [module] must be used
as the name (<artifactId>) component in the pom basename (as opposed to [artifact]).
Its this bit that correctly gets transitive resolution working.
3.) A custom cache with useOrigin="true" must be rigged - the default cache and the cache
create via the ivy CLI with -cache do not useOrigin. Its this bit combined with 1
that provides a direct link to the local repo pom and jar.
-->
<!-- sbt standard -->
<!--
<filesystem name="local.sbt" m2compatible="false" local="true" checkmodified="true">
<ivy pattern="${sbt.repo.dir}/${sbt.repo.pom}"/>
<artifact pattern="${sbt.repo.dir}/${sbt.repo.artifact}"/>
</filesystem>
-->
<!-- mvn standard -->
<!--
<filesystem name="local.m2" m2compatible="true" local="true" checkmodified="true">
<ivy pattern="${m2.repo.dir}/${m2.repo.pom}"/>
<artifact pattern="${m2.repo.dir}/${m2.repo.artifact}"/>
</filesystem>
-->
<!-- Local Android SDK, as pointed to by the ANDROID_HOME environmental variable. -->
<ibiblio name="local.android"
m2compatible="true"
usepoms="true"
root="file://${android.repo.dir}/"/>
<!-- Local Android SDK, as pointed to by the ANDROID_HOME environmental variable. -->
<ibiblio name="local.google"
m2compatible="true"
usepoms="true"
root="file://${google.repo.dir}/"/>
</chain>
</resolvers>
<caches default="default" lockStrategy="no-lock" useOrigin="true">
<cache name="default" basedir="${ivy.cache.dir}"/>
</caches>
</ivysettings>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment