netbeans does not compile changed code in other modules before running a test in another module
Apache NetBeans version
Apache NetBeans 21
What happened
I have multiple maven modules:
Module A Module B
Module B depends on Module A.
If I make a change in module A, not in test code, and then select the test file in module B, right click and 'Test File' or Ctrl +F6 then changes in A are not picked up and recompiled.
Language / Project Type / NetBeans Component
Java Maven multimodule project
How to reproduce
This is the scenario.
I make a change in the dependent module a class A method.
The original method
public void printMessage(String message){ System.out.println(message); }
New change and then I save ( I have compile when save selected for project).
This is my new change.
public void printMessage(String message){ System.out.println("Test"); System.out.println(message); }
Then I run the test B and I get the following output in the console:
` [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running com.my.commonlibrary.b.BTest SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. My message # 0 My message # 1 My message # 2 My message # 3 My message # 4 My message # 5 My message # 6 My message # 7 My message # 8 My message # 9 [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.467 s -- in com.my.commonlibrary.b.BTest [INFO] [INFO] Results: [INFO] [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.587 s [INFO] Finished at: 2024-04-03T09:27:42+02:00 [INFO] ------------------------------------------------------------------------
`
Since I update the class A with a new message and saved. This should make us compile the dependency also when running the test case in B since B depends on A. So I assume the printout should have a 'Test' added to printMessage() but that is not the case.
Did this work correctly in an earlier version?
No / Don't know
Operating System
windows
JDK
17
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
This problem is consistent and happens all the time working with maven multi-module projects. I have added a sample project to test on. mavenproject1.zip
Are you willing to submit a pull request?
No