Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get run/debug working. #277

Closed
wants to merge 1 commit into from

Conversation

profOnno
Copy link

Changed working directory in run configuration.
Added tuxguitar-gm-settings-SNAPSHOT.jar and
tuxguitar-utils-SNAPSHOT.jar to classpath in run configuration.

Changed working directory in run configuration.
Added tuxguitar-gm-settings-SNAPSHOT.jar and
tuxguitar-utils-SNAPSHOT.jar to classpath in run configuration.
@guiv42 guiv42 self-requested a review March 12, 2024 18:20
Comment on lines +20 to +21
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/tuxguitar-gm-settings/target/tuxguitar-gm-settings-SNAPSHOT.jar&quot; path=&quot;5&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/tuxguitar-gm-utils/target/tuxguitar-gm-utils-SNAPSHOT.jar&quot; path=&quot;5&quot; type=&quot;2&quot;/&gt;&#10;"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comments in #276: it does not solve the issue (at least in my config)

@profOnno
Copy link
Author

I found a discussion about this:

https://stackoverflow.com/questions/7071470/maven-does-not-add-classpath-to-eclipse-project
But the solutions didn't seem to work.

add_external_jars

In the run configuration->Dependencies select the Classpath Entries, click Add External Jars....
Now go to tuxguitar/desktop/build-scripts/tuxguitar-linux-swt-x86_64/target/tuxguitar-SNAPSHOT-linux-swt-x86_64/lib, and add all of them. This works at on my PC. I don't know if you work on Windows of Linux, adjust the target accordingly.

If I add just the folder, Advanced...-> Add external folder it doesn't work, this only works for classes;

https://stackoverflow.com/questions/219585/including-all-the-jars-in-a-directory-within-the-java-classpath
There should be an option to do in eclipse but i can't find id.

So I'll stick to my solution Add External Jars..., maybe helge17 knows a better solution?

@guiv42
Copy link
Collaborator

guiv42 commented Mar 17, 2024

In the run configuration->Dependencies select the Classpath Entries, click Add External Jars....
Now go to tuxguitar/desktop/build-scripts/tuxguitar-linux-swt-x86_64/target/tuxguitar-SNAPSHOT-linux-swt-x86_64/lib, and add all of them. This works at on my PC

It does not work "as is" in my configuration, but I think you've found the correct path to a solution. The build directives in the pom file copy the jar files of the different plugins to a dedicated folder : see <outputDirectory> tag defined in pom file. So, in Run configuration -> Dependencies, select Classpath Entries, click Add External jars..., browse to tuxguitar/desktop/build-scripts/tuxguitar-linux-swt-x86_64/target/tuxguitar-SNAPSHOT-linux-swt-x86_64/share/plugins/ and add all (?) of them.
With this I get an error when debugging starts because in my configuration one plugin doesn't work properly (java sound api cannot be loaded). All the other plugins work properly. Removing tuxguitar-jsa solves the error.

I don't know what differs between our configurations, I'm working on Linux. I can understand why adding jar files from share/plugins can solve the issue, but I really don't understand why files from lib folder should change something.

@profOnno
Copy link
Author

Hmm interesting,

I only seem to need gervil from the lib folder, else it will start but the console is full of errors.
If i want to use musicxml export i need to have tuxguitar-gm-utils.jar from the lib folder. It is an import in MusicXML writer. I also import tuxguitar-lib files... like TGTrack.java but i don't have to add this to the dependencies.

I will try to make a new work space, and do a fresh install, trying to follow the install instructions exactly.

@guiv42
Copy link
Collaborator

guiv42 commented Mar 17, 2024

I'm starting to understand. In fact we had already identified the need to add some dependencies, see #175 (quite a long discussion, now closed): at least swt and ui-toolkit-swt were required, or else the ui did not even start. So we added these 2, delivered a debug configuration and stopped there. These 2 jars are copied to lib folder by the directives of the pom file. But we did not think that many other jars could be missing in the debug config (at that period we were already happy to have succeeded launching the debugger!).
So, in debug dependencies we should probably replace the 2 jars present in delivered config by all jars from both lib and share\plugins.
Edit: I just tested it, it's almost OK. Still one error at startup: delivered sound bank is not found (it does not search in the right folder). It looks like an issue we initially had: icons were not found. I need to re-read discussion #175, and see how this icon path issue was solved by its author (don't remember, part of the answer is probably here).
Another part of the answer might be in the start script
I think we're getting close to a solution :)

@guiv42
Copy link
Collaborator

guiv42 commented Mar 26, 2024

(edit: updated after 3ce7e5c)
@profOnno, could you please test the following procedure?
initial conditions:

  • clean, empty Eclipse configuration: nothing in Eclipse workspace
  • no folder ~/.config/tuxguitar
  • tuxguitar already built from a console: folder desktop/build-scripts/tuxguitar-linux-swt/target/tuxguitar-9.99-SNAPSHOT-linux-swt/ exists and contains an executable app.

Procedure in Eclipse:

  1. File/Import/Maven/Existing Maven project, then browse to desktop/build-scripts/tuxguitar-linux-swt
  2. in "debug" icon drop-down list, click "Debug configurations...", then select "Java Application" and right-click "new configuration"
  3. in "Main" tab, project: browse to tuxguitar, and Main Class: browse to org.herac.tuxguitar.app.TGMainSingleton
  4. In Arguments tab, "VM arguments" field, type: -Dtuxguitar.share.path="(absolute path to your tuxguitar folder)/desktop/build-scripts/tuxguitar-linux-swt/target/tuxguitar-9.99-SNAPSHOT-linux-swt/share/"
  5. In Dependencies tab, delete Classpath Entries: tuxguitar and Maven dependencies
  6. In Dependencies tab, Classpath Entries, Add External JARs..., browse to desktop/build-scripts/tuxguitar-linux-swt/target/tuxguitar-9.99-SNAPSHOT-linux-swt/lib and add everything

Then "Apply", and "Debug"
With this, it seems to work rather correctly in my configuration. I still get an unexplained exception when closing app, but this should be acceptable for most debugging use cases.

My understanding:

  • normal app: build directives in build-scripts/tuxguitar-linux-swt pom file copy the required dependencies (jars, translations, icons, soundfont, etc) at specific locations. These locations are provided to TuxGuitar via parameters of the command line (see tuxguitar.sh launch script): some are provided to the java environment (classpath), some are provided directly to TuxGuitar (e.g. "/share" folder, see step 4)
  • Eclipse tries to recreate classpath from pom file of tuxguitar project (where the "main" is located), so it's missing all dependencies of tuxguitar-linux-swt. You can see this just before step 5, in the window to create run configuration, there is a button "Show Command Line", it shows clearly the classpath parameter. And location of share folder defined in the run configuration we deliver in "development" folder is incorrect...

I could not find a way to configure Eclipse in such a way to recreate exactly the same command line parameters as tuxguitar.sh script, so the procedure above remains an approximation.

If it's OK for you then I suggest closing this PR, and I will update the run/debug config and associated doc.

@guiv42
Copy link
Collaborator

guiv42 commented Apr 23, 2024

PR closed, superseded by #359

@guiv42 guiv42 closed this Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants