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

[Feature] Run custom Maven commands by nx-spring-boot #206

Open
ToppScorer opened this issue Nov 27, 2023 · 2 comments
Open

[Feature] Run custom Maven commands by nx-spring-boot #206

ToppScorer opened this issue Nov 27, 2023 · 2 comments
Labels
🆕 enhancement New feature or request

Comments

@ToppScorer
Copy link

Is your feature request related to a problem? Please describe

Currently the nx-spring-boot plugin can run a certain set of executors that mirror dedicated Maven or Spring-Boot commands.

Describe the idea you'd like

It would be nice, if there would be an executor which runs custom Maven commands, maybe given as an additional parameter. E.g. in some cases it's necessary to just run the Maven test-compile phase. As the plugin already has the capability to use an embedded Maven wrapper or a globally installed, we could just use this plugin instead of creating a custom run command for nx and reimplementing the search for the Maven executable.

I know that this was not the primary goal of this plugin (because it is mainly focusing on Spring-Boot), but maybe it can be more than that and maybe it will then be used also by users who don't use Spring-Boot.

Describe alternatives you've considered

The alternative would be, to create a completely new plugin (maybe called nx-maven) that has the same capabilities as the nx-spring-boot plugin but focuses just on calling custom Maven commands.

Additional context

No response

@ToppScorer ToppScorer added the 🆕 enhancement New feature or request label Nov 27, 2023
@tinesoft
Copy link
Owner

tinesoft commented Dec 5, 2023

Hi @ToppScorer

Sorry for the late answer,

What you are asking is basically what you can already do using nx:run-commands, which is a generic Nx executor that allows you to run any command in a project in the workspace.

You just need to add a target in your project.json file(or simply create one if starting from scratch)

project.json

{
  // ...
  "targets": {
    //...
    "test-compile": {
      "executor": "nx:run-commands",
      "options": {
        "cwd": "apps/path/to/my/project",   // (optional) you can set the current working directory
        "command": "mvn test-compile " // you could also use Maven wrapper for eg, "./mvnw", 
      }
    }
  }
}

Then you can run it as such:

$npx nx test-compile <your-project> [--args=" -D.maven.arg1=<xxx>  -D.maven.arg2=<yyy> "]

Imho, the interest of a pure nx-maven plugin is limited, because I cannot provide the handy generators/executors out-of-the-box, given that the maven goals available, would highly vary, based on what maven plugins are actually used in that project. Unlike a dedicated Nx Springboot plugin, for which I know the basic setup/structure ahead of time, I can create those generators/executors to help users create such projects, or run related tasks.

Hope it helps

@jbadeau
Copy link

jbadeau commented May 3, 2024

https://github.com/khalilou88/jnxplus does exactly what your asking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants