0
votes

I'm using ant and ivy to create jar file, I have 6 jars which I'm copying to ${build.google.reports.jars.dir} directory. These are static files but I would like to fetch through IVY.

I have tried ivy install and retrieve but no luck. How can I copy either from ivy cache or any other better solution to ${build.jar.file} jar file?

ivy.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
    <ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
        <info organisation="google" module="google-utils" status="integration"/>
        <dependencies>
            <dependency org="log4j" name="apache-log4j-extras" rev="1.0"/>
            <dependency org="commons-cli" name="commons-cli" rev="1.2"/>
            <dependency org="dom4j" name="dom4j" rev="1.5.2" />
            <dependency org="jaxen" name="jaxen" rev="1.1.3"/>
            <dependency org="log4j" name="log4j" rev="1.2.16" />
            <dependency org="net.sf.staf" name="jstaf" rev="3.4.4"/>
        </dependencies>
    </ivy-module>

Build.xml

<project name="google-utils" default="jar" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
    <import file="../google-global.xml"/>

    <property name="build.google.dir"                       location="${build.dir}/google"/>
    <property name="build.google.jars.dir"              location="${build.google.dir}/STAF-INF/jars"/>
    <property name="build.google.classes.dir"               location="${build.google.dir}/STAF-INF/classes"/>
    <property name="build.google.reports"               location="${build.google.dir}/reports" />
    <property name="build.google.reports.classes.dir"   location="${build.google.reports}/STAF-INF/classes"/>
    <property name="build.google.reports.jars.dir"      location="${build.google.reports}/STAF-INF/jars"/>
    <property name="build.jar.file"                     location="${dist.dir}/googleResults.jar"/>

    <target name="jar" depends="google-reports" description="Default target to create jar file"/>

    <target name="google-reports" depends="compile" description="Creates google jar file">
        <copy todir="${build.google.reports.jars.dir}">
            <fileset dir="jars">
                <include name="apache-log4j-extras-1.0.jar" />
                <include name="commons-cli-1.2.jar" />
                <include name="dom4j-1.5.2.jar" />
                <include name="jaxen-1.1.3.jar" />
                <include name="log4j-1.2.16.jar" />
                <include name="jstaf-3.4.4.jar" />
            </fileset>
        </copy>

        <copy todir="${build.google.reports.classes.dir}">
            <fileset dir="${build.classes.dir}" />
        </copy>

        <jar destfile="${build.jar.file}" basedir="${build.google.reports}">
            <manifest>
                <attribute name="Main-Class" value="google.Driver" />
                <section name="google/service/info">
                    <attribute name="Service-Class" value="com.google.reports.ResultsGoogle" />
                    <attribute name="Packaged-Jars" value="apache-log4j-extras-1.0 commons-cli-1.2 dom4j-1.5.2 jaxen-1.1.3 log4j-1.2.16 jstaf-3.4.4"/>
                </section>
            </manifest>
        </jar>
    </target>

</project>
1

1 Answers

0
votes

You have to use ivy:install and copy *.jar to destination directory:

<ivy:install organisation="log4j" module="apache-log4j-extras" revision="1.0" settingsRef="dev.settings" from="chain-resolver" to="build-tmp" overwrite="true" transitive="true" type="jar"/>
        <ivy:install organisation="commons-cli" module="commons-cli" revision="1.2" settingsRef="dev.settings" from="chain-resolver" to="build-tmp" overwrite="true" transitive="true" type="jar"/>
        <ivy:install organisation="dom4j" module="dom4j" revision="1.5.2" settingsRef="dev.settings" from="chain-resolver" to="build-tmp" overwrite="true" transitive="true" type="jar"/>
        <ivy:install organisation="jaxen" module="jaxen" revision="1.1.3" settingsRef="dev.settings" from="chain-resolver" to="build-tmp" overwrite="true" transitive="true" type="jar"/>
        <ivy:install organisation="log4j" module="log4j" revision="1.2.16" settingsRef="dev.settings" from="chain-resolver" to="build-tmp" overwrite="true" transitive="true" type="jar"/>
        <ivy:install organisation="net.sf.staf" module="jstaf" revision="3.4.4" settingsRef="dev.settings" from="chain-resolver" to="build-tmp" overwrite="true" transitive="true" type="jar"/>

        <copy todir="${build.staf.bugreports.jars.dir}">
            <fileset dir="${build.tmp.dir}">
                <include name="*.jar"/>
            </fileset>
        </copy>
        <delete dir="${build.tmp.dir}"/>