Background:
In a multi-project (say Alpha and Beta) Java/Spring4.x environment where Project Alpha needs to use a REST endpoint in Project Beta. Projects Alpha and Beta ARE very related and will always be released together. However, they also need to be separate as the code will be built into different pieces that will execute on different physical machines - hence the REST implementation in the first place!
Slight side-point: The UI code is in other projects and is usually the consumer of the various REST endpoints and thus does not need to consume Java implementations of a REST Client. The REST Clients are usually src/main/test so they are not even packaged, generally they are only created for Unit Tests.
Specifics:
The given API is defined in Project Beta via an Interface class:
// located in /src/main/java/com/mycompany/myservice/api
public interface MyServiceApi {
String getDataMethod();
}
The Java REST Client is also currently in Project Beta (needs the API above):
// currently located in /src/main/client/com/mycompany/myservice/client
public class MyServiceRestClient implements MyServiceApi {
. . .
}
The Question:
Sorry it has taken so long to get here! Both projects are defined in the same settings.gradle file - they are built together. Each project also has its own build.gradle file. The question is how to package only the client REST artifacts and then how to refer to them in Project Alpha? Ideally, the answer will work both from the gradle command line as well as within Eclipse. Clearly, using this in Project Alpha's build.gradle:
dependencies {
compile project('beta')
}
does not work as that brings in ALL of project Beta. By putting the client Java code into src/main/client, I have been assuming Project Beta will need to define a sourceSet to process this code. How do I take that, package it into a Jar (I know how to do this part), AND MOST IMPORTANTLY, reference that Jar from Project Alpha all in the same, single multi-project gradle build? Or is there a much better way to do that is a different approach entirely?