Programming => Lightweight Java Gaming Library => Topic started by: sc on September 19, 2019, 17:51:20

Title: [SOLVED] how to use lwjglx/debug in a maven project ?
Post by: sc on September 19, 2019, 17:51:20
As the title says ...

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

This is what I have done so far :
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]
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

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)
Title: Re: how to use lwjglx/debug in a maven project ?
Post by: KaiHH 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.
Title: Re: how to use lwjglx/debug in a maven project ?
Post by: sc 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).
Title: Re: how to use lwjglx/debug in a maven project ?
Post by: KaiHH 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]
<classpath />
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.
Title: Re: how to use lwjglx/debug in a maven project ?
Post by: sc on September 25, 2019, 08:11:52
Thanks. That was good info !.