Skip to content

Conversation

@tim-littlefair
Copy link

@tim-littlefair tim-littlefair commented Feb 19, 2025

This PR provides a shell script run_example.sh in the base directory of the repo which can be used to run any of the example files directly with the platform's default 'java' binary. This enables the tests to be run without incurring the delayed and ungraceful shutdown described in #161.

To do this it builds a classpath including the directories within the repository where the mvn-compiled .class files for the library, and its test and example classes are, also the .so files for the amd64 platform (I don't know whether #161 affects other platforms so I haven't attempted to support them).

The line which runs java is qualified with sudo so that the operator doesn't have to worry about udev rules on Linux. I realize that this may not be a good default policy, but it suits me as I am working on a hid4java-dependent project with a couple of devices which will require udev rules and I don't want to put these in place until I am ready to develop the packaging for my project. A consequence of running with sudo is that builds using mvn will also need to be run under sudo so that they can delete runtime files created by test runs. If maintainers want to remove the sudo from the java command and the recommended mvn build command displayed if the .class file for the example test is not found they are welcome to do so.

Finally thanks to @gary-rowe and the other maintainers for their excellent work on hid4java.

The purpose of this script is to enable examples to be run without
using Maven, as (on Ubuntu 24.04.2) examples run via Maven do not shut down cleanly.

Ref:
gary-rowe#161
…get test class is not found

Use of sudo for the build is required if and only if the test class has been run using sudo,
as sudo runs of the test class will create files which mvn will be unable to delete or overwrite.
@tim-littlefair tim-littlefair changed the title Wraopper script to work around issue 161 Wrapper script to work around issue 161 Feb 19, 2025
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.

1 participant