蚂蚁包括jar文件和.class文件在dest罐子 [英] Ant including both jar files and .class files in dest jar

查看:202
本文介绍了蚂蚁包括jar文件和.class文件在dest罐子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用蚂蚁的build.xml 定义的jar任务。我需要所有的依赖捆绑到我的罐子。我不understant为什么蚂蚁提取罐和包括的.jar 的.class 文件到我的罐子。它不必要地增加了我的jar文件的大小。这是我的jar任务。

 <罐子destfile =建立/主/ ERS2SupportingUtilities.jar>            <文件集DIR =目标/班>
                <排除NAME =* SH。/>
            < /文件集>            <&限制GT;
             <** / *类名称name = />
             <档案>
               <拉链>
                 <文件集DIR =./的src / main /资源/ lib目录包括=** / *罐子/>
               < /拉链>
             < /档案>
            < /限制>            <&舱单GT;
              <属性名=主类VALUE =com.cibc.ers2.invoker.JobTest/>
                <属性名=类路径VALUE =./的lib /的log4j-1.2.16.jar
                                                    ./lib/org.springframework.context-3.0.3RELEASE.jar
                                                    ./lib/org.springframework.asm-3.​​0.3.RELEASE.jar
                                                    ./lib/junit-4.7.jar
                                                    ./lib/org.springframework.orm-3.0.3.RELEASE.jar
                                                    ./lib/org.springframework.transaction-3.0.3.RELEASE.jar
                                                    ./lib/org.springframework.aspects-3.0.3.RELEASE.jar
                                                    ./lib/commons-pool-1.5.4.jar
                                                    ./lib/org.springframework.core-3.0.3.RELEASE.jar
                                                    ./lib/commons-logging-1.1.1.jar
                                                    ./lib/HashUtility.jar
                                                    ./lib/org.springframework.ex$p$pssion-3.0.3.RELEASE.jar
                                                    ./lib/commons-lang-2.6.jar
                                                    ./lib/org.springframework.instrument-3.0.3.RELEASE.jar
                                                    ./lib/mockito-all-1.9.5.jar
                                                    ./lib/com.springsource.org.aopalliance-1.0.0.jar
                                                    ./lib/ojdbc14.jar
                                                    ./lib/commons-io-2.4.jar
                                                    ./lib/commons-collections-3.1.jar
                                                    ./lib/org.springframework.jdbc-3.0.3.RELEASE.jar
                                                    ./lib/spring-batch-infrastructure-2.1.9.RELEASE.jar
                                                    ./lib/org.springframework.context.support-3.0.3.RELEASE.jar
                                                    ./lib/commons-dbcp-1.4.jar
                                                    ./lib/spring-batch-test-2.1.9.RELEASE.jar
                                                    ./lib/org.springframework.beans-3.0.3.RELEASE.jar
                                                    ./lib/org.springframework.oxm-3.0.3.RELEASE.jar
                                                    ./lib/org.springframework.aop-3.0.3.RELEASE.jar
                                                    ./lib/commons-beanutils.jar
                                                    ./lib/org.springframework.binding-2.1.1.RELEASE.jar
                                                    ./lib/spring-batch-core-2.1.9.RELEASE.jar
                                                    ./lib/org.springframework.test-3.0.3.RELEASE.jar
                                                    ./launch-context.xml
                                                    ./log4j.xml
                />
            < /清单>
        < /瓶>

我也试过 zipgroupfileset 但也正在给了同样的问题。

修改

没有给予什么,我想实现足够的信息道歉。我有这我compilint @ 目标/班的应用程序。我需要打包该应用程序,包括我的类文件和依赖条件成一个罐子。


解决方案

 <文件集DIR =目标/班>
     <排除NAME =* SH。/>
 < /文件集>

包括来自目标/类的所有文件,这些文件不是shell脚本。

 <&限制GT;
    <** / *类名称name = />
    <档案>
         <拉链>
             <文件集DIR =./的src / main /资源/ lib目录包括=** / *罐子/>
          < /拉链>
     < /档案>
< /限制>

好像你又包括类和罐子在这里。

如果您希望只罐子全部更改上面:

 < zipfileset DIR =./的src / main /资源/ lib目录包括=*罐子。/>

I have defined a jar task using ant build.xml. I need to bundle all the dependencies into my jar. I don't understant why ant extracts the jars and includes both .jars and .class files into my jar. It unnecessarily increases the size of my jar file. Here is my jar task.

<jar destfile="build/main/ERS2SupportingUtilities.jar">

            <fileset dir="target/classes">
                <exclude name="*.sh"/>
            </fileset>

            <restrict>
             <name name="**/*.class"/>
             <archives>
               <zips>
                 <fileset dir="./src/main/resources/lib" includes="**/*.jar"/> 
               </zips>
             </archives>
            </restrict>

            <manifest>
              <attribute name="Main-Class" value="com.cibc.ers2.invoker.JobTest"/>
                <attribute name="Class-Path" value="./lib/log4j-1.2.16.jar
                                                    ./lib/org.springframework.context-3.0.3RELEASE.jar
                                                    ./lib/org.springframework.asm-3.0.3.RELEASE.jar
                                                    ./lib/junit-4.7.jar
                                                    ./lib/org.springframework.orm-3.0.3.RELEASE.jar
                                                    ./lib/org.springframework.transaction-3.0.3.RELEASE.jar
                                                    ./lib/org.springframework.aspects-3.0.3.RELEASE.jar
                                                    ./lib/commons-pool-1.5.4.jar
                                                    ./lib/org.springframework.core-3.0.3.RELEASE.jar
                                                    ./lib/commons-logging-1.1.1.jar
                                                    ./lib/HashUtility.jar
                                                    ./lib/org.springframework.expression-3.0.3.RELEASE.jar
                                                    ./lib/commons-lang-2.6.jar
                                                    ./lib/org.springframework.instrument-3.0.3.RELEASE.jar
                                                    ./lib/mockito-all-1.9.5.jar
                                                    ./lib/com.springsource.org.aopalliance-1.0.0.jar
                                                    ./lib/ojdbc14.jar
                                                    ./lib/commons-io-2.4.jar
                                                    ./lib/commons-collections-3.1.jar
                                                    ./lib/org.springframework.jdbc-3.0.3.RELEASE.jar
                                                    ./lib/spring-batch-infrastructure-2.1.9.RELEASE.jar
                                                    ./lib/org.springframework.context.support-3.0.3.RELEASE.jar
                                                    ./lib/commons-dbcp-1.4.jar
                                                    ./lib/spring-batch-test-2.1.9.RELEASE.jar
                                                    ./lib/org.springframework.beans-3.0.3.RELEASE.jar
                                                    ./lib/org.springframework.oxm-3.0.3.RELEASE.jar
                                                    ./lib/org.springframework.aop-3.0.3.RELEASE.jar
                                                    ./lib/commons-beanutils.jar
                                                    ./lib/org.springframework.binding-2.1.1.RELEASE.jar
                                                    ./lib/spring-batch-core-2.1.9.RELEASE.jar
                                                    ./lib/org.springframework.test-3.0.3.RELEASE.jar
                                                    ./launch-context.xml
                                                    ./log4j.xml"
                />
            </manifest>
        </jar>

I have also tried zipgroupfileset but that also is giving the same problem.

EDIT

Apologies for not giving enough info about what I am trying to achieve. I have got an application which I am compilint @ target/classes. I need to package this application including my class files and dependecies into one jar.

解决方案

 <fileset dir="target/classes">
     <exclude name="*.sh"/>
 </fileset>

includes all files from target/classes which are not shell scripts.

<restrict>
    <name name="**/*.class"/>
    <archives>
         <zips>
             <fileset dir="./src/main/resources/lib" includes="**/*.jar"/> 
          </zips>
     </archives>
</restrict>

It seems like you again include classes and jars here.

If you want only jar change all above to :

<zipfileset dir="./src/main/resources/lib" includes="*.jar"/>

这篇关于蚂蚁包括jar文件和.class文件在dest罐子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆