Hello Guest

[SOLVED] how to use lwjglx/debug in a maven project ?

  • 4 Replies
  • 216 Views
*

Offline sc

  • *
  • 11
[SOLVED] how to use lwjglx/debug in a maven project ?
« on: September 19, 2019, 17:51:20 »
As the title says ...

I think the info on https://github.com/LWJGLX/debug is a bit minimalistic for novice programmers ...  :)

This is what I have done so far :
  • * create a new Maven project
  • * copy the pom.xml from the Github site into the project
  • * run the maven goal 'package'
This results in 3 jar files and a pom.

In my game project : add a new dependency with the path to the jar (from the other project).
Code: [Select]
<dependency>
<groupId>org.lwjglx</groupId>
<artifactId>lwjglx-debug</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>D:\nb\XDEBUG\lwjglx-debug-1.0.0.jar</systemPath>
</dependency>
This adds the debug.jar in my game project.

But I didn't manage to get any further ... :(
I modified the existing action 'debug project' a little bit (added the -javaagent bit to the 'properties') :
Code: [Select]
exec.args=-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -javaagent:"D:\nb\XDEBUG\lwjglx-debug-1.0.0.jar" -classpath %classpath be.gameproj.Main
exec.executable=java
jpda.listen=true

and left the 'execute goals' the way they were :
Code: [Select]
process-classes org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
The error I get :
Code: [Select]
--- exec-maven-plugin:1.5.0:exec (default-cli) @ Game_Proj ---
Exception in thread "main" java.lang.ClassNotFoundException: org.lwjglx.debug.Agent

I have no clue what to try next ...
This is NetBeans 10 on Window (bundled Maven)
« Last Edit: September 25, 2019, 10:54:02 by sc »

*

Offline KaiHH

  • ****
  • 207
Re: how to use lwjglx/debug in a maven project ?
« Reply #1 on: September 23, 2019, 22:24:28 »
Nothing of what you did was expressedly stated or implied anywhere in the documentation/README.md of the LWJGLX/debug project.
I have no clue why you decided to create a new Maven project where you then copy/pasted the pom.xml from LWJGLX/debug into and built that. Of course you would end up with an empty jar that does not contain any of LWJGLX/debug's classes and hence you would get the exception you got.
Please make sure to read and follow the _actual_ steps under the "How" section of https://github.com/LWJGLX/debug#how to the letter.
Step 1 means that you can either download an existing build of the lwjglx-debug-1.0.0.jar from the mentioned LWJGL HTTP link _OR_ you can build the LWJGLX/debug project manually by following the steps under the "Build" section https://github.com/LWJGLX/debug#build . And by building the project you would _of course_ clone or download the Git repository of LWJGLX/debug and execute the Maven build step inside of this checkedout directory. But I recommend you just download the pre-built jar and simply use that with a "-javaagent" JVM argument as mentioned in the "How" section.

*

Offline sc

  • *
  • 11
Re: how to use lwjglx/debug in a maven project ?
« Reply #2 on: September 24, 2019, 07:48:10 »
Thank you for responding.

As I have said : I am new to all of this.
I have obviously misunderstood the instructions.(which I read several times)
I was looking for info on how to use the debug.jar from -inside- a Maven proj (not from some outside location). My reasoning being that it would be more convenient not having to bother with classpaths on the command line (which I know how to do).

*

Offline KaiHH

  • ****
  • 207
Re: how to use lwjglx/debug in a maven project ?
« Reply #3 on: September 24, 2019, 08:34:14 »
Okay, I see. Actually, I wouldn't recommend running your project via the exec-maven-plugin during development, but use the launch/run configuration of your IDE for that. Every IDE has excellent comprehension/support for Maven. Using the exec-maven-plugin has the following drawbacks:
1. It complicates debugging your application during development: You would have to specify the debug agent arguments for the JVM start manually and would have to use a remote debug session in your IDE to connect to your started JVM
2. It requires to explicitly specify the class to run or the executable jar to run. So it cannot deal with multiple entry points / classes with a main() method if you happen to have a project with multiple such main classes
If you still want to run your application via Maven and not via the IDE, then I'd use the following exec-maven-plugin configuration:
Code: [Select]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-cp</argument>
<classpath />
<argument>-javaagent:./lwjglx-debug-1.0.0.jar</argument>
<argument>your.main.Class</argument>
</arguments>
</configuration>
</plugin>
with a downloaded copy of lwjglx-debug-1.0.0.jar in the root project directory.
Then you can execute: `mvn compile exec:exec`.
You don't need to configure anything else in your pom.xml, so no dependency to org.lwjglx:lwjglx-debug.

*

Offline sc

  • *
  • 11
Re: how to use lwjglx/debug in a maven project ?
« Reply #4 on: September 25, 2019, 08:11:52 »
Thanks. That was good info !.