Skip to content

networkupstools/jNut

Repository files navigation

jNut

A NUT Client for Java: library, sample command-line client, WAR suitable for deployment into web application servers to handle NUT via REST API.

For more details about the NUT ecosystem, please see https://networkupstools.org/ and https://github.com/networkupstools/nut/

Sources of this project can be found at https://github.com/networkupstools/jNut/

Java NUT Client files

This directory contains various NUT Client related Java source files, originally written by Emilien Kia in 2011, sponsored by Eaton, and released under GPL v2 as part of NUT code base (repository separated as a standalone project in 2013).

For consistency with other ecosystem projects, the current license is GPL-2.0-with-classpath-exception, see the LICENSE.md file for details.

Submodules are:

  • "jNut": this directory contains maven project and source files for jNut, which is a Java abstraction bundle to access NUT server(s). You can use it in Java programs to access NUT’s upsd data server in a simple way, without having to know the NUT protocol.

  • "jNutList": this directory contains maven project and source files for jNutList, a simple Java example program using jNut which connects to an upsd, and lists its devices and their variables and commands. Rough equivalent to upsc "example client" in NUT itself.

  • "jNutWebAPI": this directory contains maven project and source files for jNutWebAPI, a simple Java web archive which allows to provide access to NUT information via REST web services.

Testing against real NUT server

The test-NIT.sh script can be used to arrange a NUT driver+server setup using the NUT Integration Test suite script nit.sh. You can find it in the main NUT repository as part of a Git checkout, or specifically fetch https://raw.githubusercontent.com/networkupstools/nut/refs/heads/master/tests/NIT/nit.sh and place where your PATH resolves it (or use NUT_BUILDDIR for a custom build, as detailed below).

  • See .github/workflows/04-maven-nit.yml for an example of how CI does this.

By default the test-NIT.sh script can handle a packaged NUT installation on Debian or Ubuntu (as used by CI runners), and probably elsewhere that all needed programs are in PATH (you may customize yours for a similar effect on further systems).

To run against binaries from your custom build of NUT, you can specify the NUT_BUILDDIR location and the script should figure out the rest:

:; NUT_BUILDDIR="/tmp/nut/build-clion" ./test-NIT.sh

To iterate as a developer, you can spawn a sub-shell after the NUT drivers and data server are started, so they are indefinitely running (and the data server is logging at NUT_DEBUG_LEVEL_UPSD verbosity, by default 6) until you exit that shell:

:; NUT_BUILDDIR="/tmp/nut/build-clion" JNUT_TEST_NIT_SUBSHELL=true ./test-NIT.sh

This allows you to run the client from an IDE with a debugger against a persistently available test server listening at localhost:${NUT_PORT}.

To use the same server port across several re-runs of this script and ultimately of the nit.sh which actually sets up the environment, you can e.g. export NUT_PORT=34930 (be careful to not use port 12345 which the Java debug bridge seems to use by default, at least in IntelliJ IDEA).

Releasing

Follow the standard Maven release process:

mvn clean
mvn release:prepare

This should move the version from snapshot to exact, git tag the result, move the version to the next release line snapshot and git commit that result (note: these commits are not signed by default, unless your custom git config says to do so), build the artifacts and run tests, and git push the repository (be sure to have the SSH agent with imported keys active in your environment).

Note
There is currently no mvn release:perform to push the artifacts to some Internet repository.

To prepare tarballs (source, docs, binaries) for the NUT website or GitHub Releases attachment, git checkout the newly created tag commit with exact (not *-SNAPSHOT) version and use the make-tarballs.sh -f script to build all that is needed.

Finally, at https://github.com/networkupstools/jNut/releases/new draft a new release (choose tag, generate notes, attach tarballs and JAR/WAR files directly) and announce in nut-website::news.txt.

About

A NUT Client for Java

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors