开发者

Manage duplicate jar files using ant and ivy

开发者 https://www.devze.com 2023-02-10 00:28 出处:网络
HI, I am using ant build script to build my java app and utilizing Iv开发者_运维问答y to manage itsdependency.

HI,

I am using ant build script to build my java app and utilizing Iv开发者_运维问答y to manage its dependency.

As my application is dependent/subset of other application(Main App), when running it, I set the classpath to point to lib jars of the Main App.

As I tried to build the kit using ant and ivy, it includes/retrieve all the jars that is required as specified in ivy.xml

The problem is, some of the jar files are duplicated with with jars file in the main app folders.

Is there a way to set the classpath in build.xml to ignore retrieving jar files that already exist in the main app's lib folder.

Thanks


There is a way to exclude file items explicitly within a tag, but you will have to manually call them out:

<fileset dir="yourdir">
     <exclude name="apps/**/*Test*"/>
</fileset>

You might consider another approach, though. It sounds like you are mixing dependency management methods. This is why you are having a conflict... You are manually setting dependencies in MainApp's lib, and specifying other dependencies in Ivy. I urge you to consider picking one of these, and doing all of your dependency management in it.

You could publish MainApp's artifacts through Ivy, and consume that artifact in your sub-project. Ivy will manage the duplicates for you.

Alternatively, you could remove MainApp from your classpath altogether, and grab the dependencies afresh every time (Ivy caches those dependencies locally, so you won't have to re-download them, it just manages them on disk for you).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号