ninja
ninja copied to clipboard
SuperDevMode not working for multi modules maven project
We are using Ninja framework for our project development and noticed the SuperDevMode is not working when we implement the multi modules maven project. The changes we made on different modules not picked up by SuperDevMode.
Hi shames, that's a known issue.
The very opinionated reason is: Maven is great, but it's greatness degrades quickly as soon as you use multi modules (for many many reasons). There are valid use cases (see the Ninja codebase), but often it does not make too much sense in terms of web projects.
There are 3 solutions to the "problem":
- Try to use jetty plugin which can be configured to support that use case.
- It is certainly possible to extend SuperDevMode to support that scenario. The "magic" is to put the compiled classes of the submodules on the classpath of Ninja's Jetty aka SuperDevMode. It's should not be too complex to make that happen (Hint: Check out buildOutputDirectory in NinjaRunMojo.java - that should be extended with the build output directories of your modules)
- Move to gradle and provide a gradle plugin with SuperDevMode. I know that a company in London did this - and they may open source their Ninja gradle plugin. But there is no ETA and it may never happen. But Ninja folks are talking about providing Gradle support.
If you want to hack some great code let us know :)
Thanks Raphael for your comments. We will try to follow your advice. :)
Looks like a pull request from a couple months ago helps solve this problem. I commented separately on that pull request, but was wondering if you had any thoughts on https://github.com/ninjaframework/ninja/pull/274
While I love the idea -- I tried merging this commit into my own fork and it doesn't seem to work. @shamex -- wondering what maven version you were using and how you ran it. Here's my test setup:
parent
core
web (ninja app)
The "web" module declares "parent" as its parent and has "core" as a dependency. I would expect your commit to essentially add core/target/classes and web/target/classes automatically to the ninja super dev daemon as watched directories. However, that didn't happen with your commit. I'm running maven 3.2.x.
I setup a profile in "web" called "ninja-run" to activate the ninja-maven-plugin during the test phase when I run the following command from "parent":
mvn -Pninja-run test
Ninja's super dev mode ran, but core's target/classes directory did not get added to be watched.
So I'm wondering what your test project structure looks like and where you're running your maven command. If you have multi-modules and don't "install" them (e.g. just run compile) -- I'm not sure what you're doing if not running mvn from only the parent dir.
That's fixed with https://github.com/ninjaframework/ninja/pull/335 - right? If that's the case please close the issue. Thanks!
Yes, https://github.com/ninjaframework/ninja/pull/335 addresses this.
I am sorry to up this again but i didn't understand. I have a parent pom containing 2 modules : 1 ninja web app module and 1 utils jar module. I manage to "mvn package" without any problem on the parent pom. The fat big jar of the ninja web app seems to include my utils jar file. So i have no problem while packaging.
The problem is that when i try to ninja:run on my ninja web app mvn throw an error saying :
Could not resolve dependencies for project com.test:test-web:jar:1.0-SNAPSHOT: Could not find artifact com.test:test-utils:jar:1.0-SNAPSHOT (mvn:package on this ninja web app submodule do the same).
I am new to maven but i read a tutorial and i think my maven configuration is good. Is there a way to solve this ?
I just understand that i have to manually install the utils.jar with mvn install. Then i saw the mvn ninja:run -Dninja.watchAllClassPathJars=true command line from #335 and i manage to automaticly restart ninja each time i mvn install the utils.jar.
So i was wondering if there is a way to automaticly install the utils.jar on source change ? I just want to not have to spam mvn install each time i modify the source code of utils.jar ...
Hi,
I don't know if this will address your issue but I tried something with ninja and Gretty (using Gradle) to address this issue. In this repo, you'll find a simple example of how to integrate then and configure them in order to reload automatically the updated source code
Fell free to provide some feedback.
I'm a little late to this thread, but the answer is pretty simple.
In multi-module maven projects, you have only two options when you want to run a sub-project:
- Run 'mvn install' so that all modules are in your local repo. Then your dependency will be found. Not a great option when you change code quickly.
- You run 'mvn' from the parent project directory. You use profiles to enable 'ninja:run' to only be active in your final module.
An example project is here: https://github.com/fizzed/ninja-rocker
mvn -Procker-demo-run
On Fri, Apr 8, 2016 at 5:29 AM, Hugo Ferreira [email protected] wrote:
Hi,
I don't know if this will address your issue but I tried something with ninja and Gretty (using Gradle) to address this issue. In this repo, you'll find a simple example of how to integrate then and configure them in order to reload automatically the updated source code
ninja-framework-with-gradle https://github.com/CrackPT/ninja-framework-with-gradle
Fell free to provide some feedback.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/ninjaframework/ninja/issues/258#issuecomment-207347701