代码之家  ›  专栏  ›  技术社区  ›  Jitesh Sojitra

通过IVY和ANT将静态jar文件复制到目标jar

  •  0
  • Jitesh Sojitra  · 技术社区  · 7 年前

    我正在使用ant和ivy创建jar文件,我有6个jar,我正在复制到${build.google.reports.jars.dir}目录。这些是静态文件,但我想通过常春藤。

    我尝试了常春藤安装和检索,但没有运气。我如何从常春藤缓存或任何其他更好的解决方案复制到${build.jar.file}jar文件?

    <?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>
    

    建筑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 回复  |  直到 6 年前
        1
  •  0
  •   Jitesh Sojitra    7 年前

    你必须使用常春藤:安装并复制*。jar到目标目录:

    <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}"/>