Separate compilation of interfaces and implementations?

D

Dan Stromberg

I'm doing some work on a large software project that has mutual
dependencies - EG, the build of jar A depends on jar B's interface, and
the build of jar B depends on jar A's interface.

It seems these dependencies could be resolved nicely if we were to build
the interface of A, then the interface of B, then the implementation of
A, then the implementation of B - just for example. Or more generally,
just go through and build all the interfaces first, then go back and
build all the implementations.

Does java support this sort of thing? I'm not expecting java to invoke
the compiler for me, but I am hoping that java will allow taking a bunch
of .java's, and produce two jars for them - one for public interfaces and
one for the private interfaces and implemtations.

Thanks!
 
E

External Concepts Guild

I'm doing some work on a large software project that has mutual
dependencies - EG, the build of jar A depends on jar B's interface, and
the build of jar B depends on jar A's interface.

It seems these dependencies could be resolved nicely if we were to build
the interface of A, then the interface of B, then the implementation of
A, then the implementation of B - just for example. Or more generally,
just go through and build all the interfaces first, then go back and
build all the implementations.

Does java support this sort of thing? I'm not expecting java to invoke
the compiler for me, but I am hoping that java will allow taking a bunch
of .java's, and produce two jars for them - one for public interfaces and
one for the private interfaces and implemtations.

Thanks!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It is not good practice to have such mutual dependencies.
A simple solution would be to simply place the public
interfaces in a separate directory from the private
interfaces and implementations. Remember to compile and jar
the public interfaces first. After you have compiled and
jarred the public interfaces, then you can (with appropriate
classpath additions) compile and jar the private interfaces
and implementations.

Emory Merryman
External Concepts Guild
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHfOiBVQdj5Q2e9q0RAkI+AJ4vJfXAd+ZnvWvDl+v0gnGo9JB1+gCfbbg4
jxxv36h5VWeaVjusm/YXsIc=
=7gx5
-----END PGP SIGNATURE-----
 
M

Mike Schilling

External said:
It is not good practice to have such mutual dependencies.
A simple solution would be to simply place the public
interfaces in a separate directory from the private
interfaces and implementations. Remember to compile and jar
the public interfaces first. After you have compiled and
jarred the public interfaces, then you can (with appropriate
classpath additions) compile and jar the private interfaces
and implementations.

Even better, place the public interfaces (and anything else you want
to go into the lower-level jar) in a separate source tree. That makes
it much harder for wrong-way dependencies to creep into the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top