khalilou88/jnxplus

mavenRootDirectories Or maven multi root projects workspace

jbadeau opened this issue · 6 comments

Very cool that you are using the new plugin options. Things are working nicely! I do have a suggestion for an improvment.

Could we change this:

{
"plugins": [
    {
      "plugin": "@jnxplus/nx-maven",
      "options": {
        "mavenRootDirectory": "ignite/root"
      }
    }
  ]
}

To the following:

{
"plugins": [
    {
      "plugin": "@jnxplus/nx-maven",
      "options": {
        "mavenRootDirectories": ["app1", "app2"]
      }
    }
  ]
}

I have seen that many monorepos seperate by apps or domain so a single maven root is problematic. Could the options be changed like this?

Hi @jbadeau I don't think the plugin is better for that architecture because it will be too sequential. try first folder then second.
The graph also will do the same and try to connect projects from different root folders (a lot of change to do).

I feel what you want is what nx-spring-boot provide : more freedom to build the projects as you want and the graph is done with other manner.

But i see good ideas in your demand

  • Try nx-maven and nx gradle in the same workspace
  • Try the same architecture you want but without mavenRootDirectories, for that we can use the directory option from create app, lib and parent-project generators. Also parentProject and aggregatorProject options will be useful here.
    We can, for example, make app1 root project with java 17, app2 with java 21...

I will keep the issue open for more ideas

@jbadeau instead of changing option mavenRootDirectory to mavenRootDirectories, the solution should be to remove mavenRootDirectory option.

When collecting xml files, this will help to construct the graph:

  • A maven root project is a pom project without aggregator project.
  • Every project should have a property that we will be filled dynamically mavenRootDirectory. So when we call nx targetName on that project, we will know where to execute the command.

At the moment, i don't know if nx allow extending project data?

  • We will have two types of workspaces : unique root project with . as projectRoot and multi root projects.
  • local Repo should be set per workspace to use libs in all workspace.
  • NX_SKIP_MAVEN_WRAPPER should be set per workspace and per root project.

First step to implements this feature is to remove mavenRootDirectory option and refactor the graph algorithm. And parentProject and aggregatorProject options will not accept empty string anymore except if dir option is provided.

Second step is to adapt init generator for two situation:

  • unique root project.
  • multi root projects.

Add a new generator rootProject this will throw an exception if the workspace is unique root project. Or adapt parentProject generator for this new usecase