summaryrefslogtreecommitdiff
path: root/ant/ivy-common.xml
blob: b91bacfdff44bfceadb10edd76c4fec3218ba830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<project name="ivy-common"
    xmlns:ivy="antlib:org.apache.ivy.ant"
    xmlns:artifact="antlib:org.apache.maven.artifact.ant">

    <property name="ivy.jar.version" value="2.3.0"/>
    <property name="ivy.jar.name" value="ivy-${ivy.jar.version}.jar"/>
    <property name="ivy.home" value="${user.home}/.ivy2"/>
    <available property="ivy.installed" file="${ivy.home}/${ivy.jar.name}"/>

    <!-- Install ivy jar files in ~/.ivy2 -->
    <target name="ivy-install" unless="ivy.installed">
        <mkdir dir="${ivy.home}"/>
        <get
            src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.jar.version}/${ivy.jar.name}"
            dest="${ivy.home}/${ivy.jar.name}" />
    </target>

    <target name="ivy-init" depends="ivy-install">
        <taskdef resource="org/apache/ivy/ant/antlib.xml"
                 uri="antlib:org.apache.ivy.ant"
                 classpath="${ivy.home}/${ivy.jar.name}" />
        <ivy:resolve/>
    </target>

    <target name="clean-cache" depends="ivy-init" description="Clean the Ivy Cache">
        <ivy:cleancache />
    </target>

    <target name="resolve" depends="ivy-init" if="ivy.deps.changed"
        description="Download project dependencies">
        <ivy:retrieve sync="true" symlink="true" />
    </target>

    <target name="dep-report" depends="resolve" description="Generate dependency report">
        <ivy:report todir="${build.dir}" />
    </target>

    <target name="gen-pom" depends="prepare,ivy-init"
        description="Make a pom file for the project">
        <ivy:makepom ivyfile="ivy.xml" pomfile="${build.dir}/poms/${ant.project.name}.pom">
            <!--
              Mapping confs to scopes is important, otherwise
              unmapped confs are included as optional. If you
              have private confs, the best option seems to
              be marking them as provided or system. See
              IVY-1201 for an ehancement request.
            -->
            <mapping conf="default" scope="compile"/>
        </ivy:makepom>
    </target>

    <target name="publish-local" depends="jar,ivy-init,gen-pom"
        description="Publish to local maven repo for building other projects">

        <ivy:publish resolver="local-m2-publish" forcedeliver="true"
            overwrite="true" publishivy="false">

            <artifacts pattern="${build.dir}/[type]s/[artifact].[ext]"/>
        </ivy:publish>
    </target>

</project>