0

I have a special project structure:

root project
    + sub project 1
    + sub project 2

The subprojects are represent "plugins": part of the application built into separated jar and scanned dynamicly by root project at run time when deployed. (There may be additional subprojects added to the deployment, developed separately.) An other twist is that the subprojects depends (compile, or more precisely edit time) on the root project (the root project contains a DSL and the subprojects defines scripts on this DSL, so dependency is required only for syntax and cotext help).

In the gradle build I have a release and deploy task which includes all three projects build result (jars) into one zip to be deployed. So as standalone app, it works fine.

However, when I try to run the root project, it can't access the jars of the subprojects, because to avoid circular references I can't make root to depend on the subprojects.

What is the best practice to make the app to build, run and detect plugins while running in IDEA, while keeping the loose coupling on gradle level?

Some ideas I thought:

1) Somehow extend or configure the build task of the gradle script of the root project to depend on and include subprojects. (Could I without establishing a circular reference?)

2) Somehow add additional project configuration to the IDEA project. Could it be done without being removed with each gradle script reparse?

3) Make IDEA to include the build results of the subprojects in runtime environment.

Is there a best practice?

Balage1551
  • 1,037
  • 1
  • 10
  • 28

1 Answers1

0

Well, I figured out a solution.

First, I created a new, core subproject and moved all the source of the root project into it. (To be completely accurate, I kept the main function in the root.)

root project
    + core
    + sub project 1 (plugin)
    + sub project 2 (plugin)

The root project depends on both the core and the additional plugin project, so both when I run it from IDEA, or building the release it will be complete.

On the other hand, the plugins now may depend on core, there will be no circular dependency.

One more issue I ran into: although my plugin project had only resources source directory, to enable DSL from core as context help in scripts I had to create an empty kotlin source directory as well. (It could be something with configuration by convention.)

Balage1551
  • 1,037
  • 1
  • 10
  • 28