问题描述:

I have multiple projects in my Eclipse workspace: Version 1, Version 2, Version 3, etc

I would like to include the .class files from each of these directories into an output .jar file. I want the .class files placed into the root of the jar file.

Something like this:

<fileset dir="../Version*" includes="*.class" />

However, this doesn't work. This does:

<fileset dir=".." includes="Version*/*.class" />

But in the output jar file, the files are being included into directories. E.g. Version 1/Version1.class, Version 2/Version2.class

This is not what I want. I want Version1.class and Version2.class to be in the root of the jar file.

Hope I explained that well, let me know if clarification is needed - and thanks in advance.

网友答案:

It should be possible to equip your <jar task with a Mapper. With that mapper, cut away the first folder component. See https://ant.apache.org/manual/Types/mapper.html

网友答案:

Turns out I was only a few Google searches away from figuring this out.

Here's a solution that worked for me:

<pathconvert property="versions" pathsep=",">
    <dirset dir=".." includes="Versions*" />
</pathconvert>

And then in the jar task:

<multirootfileset basedirs="${versions}" type="file" includes="*.class" />

Requires Ant 1.9.4

相关阅读:
Top