Ant: Split Source Directory into Two Jars

不羁的心 提交于 2019-12-11 10:52:05

问题


How does one go about creating two Jars from one project source folder? Is that possible, or must I create another project? My project uses Ant right now to generate one Jar. For example, say I want to split up the class files like this:

Jar 1:
    com.myproject.Foo
    com.myproject.Bar
Jar 2:
    com.myproject.FooBar
    com.myproject.BarFoo
    com.myproject.FooBarFoo
    ...

回答1:


See http://ant.apache.org/manual/Tasks/jar.html. You just have to use filesets or includes/excludes inside your jar task to include only the files you want in each jar:

<target name="makeJars">
    <jar destfile="jar1.jar" 
         basedir="classes" 
         includes="com/myproject/Foo.class, com/myproject/Bar.class"/>

    <jar destfile="jar2.jar" 
         basedir="classes" 
         includes="com/myproject/FooBar.class, com/myproject/BarFoo.class, com/myproject/FooBarFoo.class" />
</target>


来源:https://stackoverflow.com/questions/5822274/ant-split-source-directory-into-two-jars

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!