Take the 2-minute tour ×

I created a gradle project having common code among all the projects in the same workspace. For this,

  1. I set this new project in class path of all other projects. So it is available at compilation time.
  2. I mentioned package structure of new project in application-context (spring configuration) of all projects. So that the component of new project can be autowired.
  3. In build.gradle of every project, I have addedn an extra entry under dependencies task i.e. compile project(':newproject')

Everything is running fine. Only I need to figure out gradle task to generate jar of new project.

Is it the correct way? Or should I

  1. build jar of new project,
  2. define it as dependency in build.gradle of other projects,
  3. copy it libs folder of other project at the time of deployment.

In 2nd approach, I have no idea how Spring'll autowire the bean of newproject.

share|improve this question
add comment

1 Answer

Adding the dependencies manual via a build jar file would be strange. I would stay with the "correct" dependencies and try to figure out a way to build the jar of "new project".

share|improve this answer
add comment

Your Answer


