Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating maven projects in a subfolder #519

Closed
khalilou88 opened this issue Oct 14, 2023 · 19 comments
Closed

Generating maven projects in a subfolder #519

khalilou88 opened this issue Oct 14, 2023 · 19 comments

Comments

@khalilou88
Copy link
Owner

khalilou88 commented Oct 14, 2023

To isolate maven root project from nx root project and have better affected experience we are planning to generate all maven project in a sub folder.

For that we will use a mavenRootDirectory variable.

during init we need to to choose this variable

we will try to put it inside nx.json as a first option, or inside a .env file (in root folder)

EDIT:
https://nx.dev/recipes/tips-n-tricks/define-environment-variables

NX_maven_Root_Directory inside .env file

EDIT: final solution use nx-maven subefloder without use of a en var

@jbadeau
Copy link

jbadeau commented Oct 14, 2023

Curious how tinesoft does it

tinesoft/nxrocks#179

@khalilou88
Copy link
Owner Author

@jbadeau I don't know about nx-spring-boot plugin and what i want to do is near what nx do with workspaceLayout.
Maybe we can try to find the first pom.xml to find mavenRootDirectory

@jbadeau
Copy link

jbadeau commented Oct 14, 2023

if you can support multiple roots like:
Then I think it will be fine. I guess you could scan for all poms in root folders

Screenshot 2023-10-14 at 13 42 01

@khalilou88
Copy link
Owner Author

That will make the plugin hard to use and understand. For me we should use one maven for all projects. And we should have one root pom.xml (or inside mavenRootDirectory) so every pom.xml can inherent from it.

@khalilou88
Copy link
Owner Author

khalilou88 commented Oct 14, 2023

another way to find mavenRootDirectory in my opinion is nx show projects withTag=nx-maven and choose the project based on projectRoot

Edit: Nx show don't have tag option so this option not possible

@khalilou88
Copy link
Owner Author

khalilou88 commented Oct 16, 2023

@jbadeau to make this feature simple I think about a fixed name for this subfolder. Let's say nx-maven.

If a root pom.xml is present, we use empty string for mavenRootDirectoty. If not we generate everything in nx-maven subfolder

For this, we just need to add a boolean to init generator

@jbadeau
Copy link

jbadeau commented Oct 17, 2023

It u have a prerelease I’ll be happy to try it

@khalilou88
Copy link
Owner Author

@jbadeau I am working on implementing it

@jbadeau
Copy link

jbadeau commented Oct 17, 2023 via email

@jbadeau
Copy link

jbadeau commented Oct 17, 2023

Cool, just trying to avoid rework for you.

@jbadeau
Copy link

jbadeau commented Oct 18, 2023

nrwl/nx#19589

looks like a standard way to add options to plugins

@khalilou88
Copy link
Owner Author

@jbadeau seems what we are looking for (if I understand well)
But I am happy with the nx-maven as a subfolder. Finishing the tests and will publish a new version

@jbadeau
Copy link

jbadeau commented Oct 18, 2023 via email

@khalilou88
Copy link
Owner Author

prerelease don't work good for me, so i will publish a new version.
This feature is not the default option so I don't think will create a problem (tests are working fine).
Also it's a good feature so it's will not change in the future except maybe giving the possibility to change the folder name.

@khalilou88
Copy link
Owner Author

I published version 0.12.0 with this feature. Please use useSubfolder option : nx generate @jnxplus/nx-maven:init --parentProjectName ${parentProjectName} --useSubfolder

@jbadeau
Copy link

jbadeau commented Oct 18, 2023

works! :)

Any change we can customize the subfolder name? I could make a pr.

@khalilou88
Copy link
Owner Author

khalilou88 commented Oct 18, 2023

For now it's not possible, but if you can find the rootproject based on a tag or variable, we can update this function:

export function getMavenRootDirectory() {
  const pomXmlPath = path.join(workspaceRoot, 'pom.xml');
  if (fs.existsSync(pomXmlPath)) {
    return '';
  }
  return 'nx-maven';
}

EDIT: MavenRootDirectory will be a variable inside nx.json

@khalilou88
Copy link
Owner Author

closing this issue. next changes will be here #535

@khalilou88
Copy link
Owner Author

This option is changed in version 0.13.0 to be mavenRootDirectory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants