I have application building using third party apis, j2me apis,application code distributed in vari开发者_开发技巧ous java packages.
in user interface class device specific code is not to be imported, but it is required.
while building the application using tools like ant, building separate package as jar is not possible now because various packages are importing code from other packages etc.
i am trying to separate each package with interfaces but not always possible. still at few places code from user interface layer is required in ui specific code. also third party application source code is modified to develop the application. so in future next release of third party jar can not be used as it is, need to get source code , modify it and then include.
is there better way to develop application with minimizing package interactions?
I assume you want to provide one or more API jars containing interfaces as well as one or more implementation jars. To achieve that, you might create one project or subproject per jar and set the visibility accordingly (that's one reason Maven has the one-artifact-per-project rule).
Alternatively, you could manage visibility based on package names, for which some convention comes in handy, e.g. all *.impl.*
packages should not be visible to *.api.*
packages etc.
As for the third party dependencies: if you modify them, then you shouldn't automatically update to a new version. This will almost always result in problems. If you really have to modify third party code, then put it into your own source folders and repositories and don't link the binary jars they provide.
Alternatively, you could manage dependency versions using dependency managers like Maven or Apache Ivy.
精彩评论