-1

I have a Maven Project, Ant Project which are somehow coupled. If I have to make any change in maven project and test it I have to do following steps every time, which is very time consuming.

Steps

  • ant stopserver
  • mvn install
  • ant startserver
  • Access it on localhost:8080

And to debug anything I have to create a Remote Debug Configuration which connects to port 8000 and start ant server in debug mode.

All this is new to me as I have only worked on microservices based out of maven when there is a @SpringApplication class with main method which I could directly run/debug. In this project, there is no class with main method. It's a legacy spring mvc project.

I seriously want some way to do the same with current project. I tried going though the build.xml but ant steps are hardly taken less than a second.

Is there a way possible? Can it run like a normal maven project? Ant is probably building some db and ui parts (not very sure). But I only work on Java side.

Please help. Anything that could get rid of me having to run mvn install with every small change would also be helpful. To reduce the time taken by mvn install I used the script from this answer here and added that as well, as one of the before launch steps but the time taken is still the same.

I have tried following post but it did not work for me How to build maven project with ant script?

coretechie
  • 1,050
  • 16
  • 38
  • Can you explain why you don't start your application via your IDE? What kind of servers do you start...give more detailed information about the project... – khmarbaise Apr 22 '22 at 20:24
  • @khmarbaise `ant` + "legacy spring mvc project." sounds like something very dusty pulled out of the attic and given to the new guy. – Thorbjørn Ravn Andersen Apr 23 '22 at 12:18
  • @khmarbaise I know. I am a new joinee in this firm. Plus there is no main method so IntelliJ (my IDE) doesn't have any Run As option. – coretechie Apr 26 '22 at 06:31

2 Answers2

1

Open the lid and find out what exactly ant startserver does, and then create a launch configuration in your IDE that does the same thing. You might be able to cheat a bit and investigate the process in the operating system using its tools to get the invocation commandline.

Then run that launch configuration in the Debugger and tell your IDE to tell the JVM to hotswap newly compiled classes.

You should now have a much improved experience.

You may want to take the opportunity to teach Maven how to launch your server as that might enable the IDE to pick this up directly.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • Thanks, your comment helped me lead to the correct solution. – coretechie Apr 26 '22 at 10:58
  • @coretechie that’s not the correct solution. – Thorbjørn Ravn Andersen Apr 26 '22 at 14:57
  • I know but I could not get the latest changes reflect on the app without a maven install step. So I had to do this to at least make it perform in a single click. Do you have any other thing I can look at? Plus the ant steps DO NOT consume any time, but the maven install step is something which takes long time. – coretechie Apr 28 '22 at 06:50
0

I was able to achieve at least one click start by Adding ant targets as part of the "Before Launch" inside "Run/Debug Configurations". To reduce the time taken by mvn install I used the script from this answer here and added that as well, as one of the before launch steps.

By enabling Logs, this also became user friendly.

Here is how my config looks like now,

enter image description here

However, I still have to do maven install.

coretechie
  • 1,050
  • 16
  • 38