I have a project in Eclipse which, after assembly has a package structure of the following
launcher.tar.gz
|-- launcher.jar
|-- lib/
|-- resources/
|-- plugins/
Which is achieved using the maven-assembly-plugin
.
For the application to properly start, some of resources
are required, but not available outside of the final assembly, additionally, I would like to have the ability to install plugins as I currently do.
My current workflow is
$ mvn [clean] package
$ cd target/launcher/
$ java -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -jar launcher.jar
Once the application has launched in a suspended state, I can attach the debugger and resume my normal workflow.
How can I streamline this process from Eclipse?
I can launch this from my Launcher.java class, but when debugging in Eclipse, I do not have the ability to install plugins via this method.
The following is one way to perhaps do what you want, with examples for Windows. Part of the idea is from here.
I believe there are two ways to perform the external commands with a button in eclipse. One is a custom external tool configuration, the other can possibly be accomplished with a run configuration for maven in eclipse. I'll show the external tool config first:
The idea is to create a batch file in the root of your project directory and run it from eclipse by creating a new External Tools program configuration.
So for example, you have launcher.bat in your project directory with the following script:
call mvn clean package
call cd target/
call "C:\Program Files\Java\{jdkfolder}\bin\cjava.bat" -{your debug options} -jar launcher.jar
Where cjava.bat is another batch file you need to create with the following script:
start /wait cmd.exe /c java %*
Then your external program launch config could look like this, although i'm sure you would rather set the working directory explicitly so you don't have to highlight the project when you click run.
Set the launch parameters in the common tab to your choosing
Add this external config to your favorites so its easy to access (the external tools button should be on the taskbar already).
The alternative to this, if you really want to be able to do this by using a Run Command instead, is to set up a maven exec configuration (exec-maven-plugin) and call the script file that way with something like this, though i haven't tried it.
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>Launcher Remote Debug</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${basedir}/launcher.bat</executable>
</configuration>
</plugin>
Then you'll just remove the call for mvn clean package
in the script file so you don't end up in an infinite loop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With