Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# EditorConfig is awesome: https://EditorConfig.org
# https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties

# top-most EditorConfig file
root = true

[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

max_line_length = 80

indent_style = tab
tab_width = 4
#indent_style = space
#indent_size = 4

# Platform-dependent, except for certain interpreters
# whose sources must use LF, see .gitattributes
###end_of_line = lf

#ij_formatter_enabled = false

[.editorconfig]
trim_trailing_whitespace = false

[*.{bat,cmd,ps1}]
end_of_line = crlf

[*.{am,hwdb,service,target,path}{,.in}]
end_of_line = lf
line_comment = #

[*.sh{,.in}]
end_of_line = lf
line_comment = #

# Borrowed from https://github.com/armbian/build/blob/master/.editorconfig
shell_variant = bash
binary_next_line = false
switch_case_indent = true
space_redirects = true
keep_padding = false
function_next_line = false

[*.{m4,ac}{,.in}]
end_of_line = lf
line_comment = dnl

[*.{conf,sample}{,.in}]
max_line_length = 76
line_comment = #

[*.txt{,.in},*.adoc{,.in},AUTHORS,COPYING,INSTALL.nut,MAINTAINERS,NEWS,README,TODO,UPGRADING]
max_line_length = 76
indent_style = space
indent_size = 4

# Assumes asciidoc comments:
block_comment_start = ////////
block_comment_end = ////////

[*.{java,groovy,yaml,yml,json}{,.in}]
indent_style = space
indent_size = 4

[pom.xml]
indent_style = space
indent_size = 2

################################################################
# Primary concern: C/C++ style
# See also docs/developers.txt => Code Style chapter

[*.{c,h,cpp}{,.in}]
spaces_around_operators = true
spaces_around_brackets = none

# Plus one TAB:
continuation_indent_size = 1

indent_brace_style = K&R

block_comment_start = /*
block_comment_end = */
25 changes: 25 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Windows script files should be CR+LF always:
*.bat text eol=crlf

# Unix/Linux script files should be LF always:
*.sh text eol=lf
*.m4 text eol=lf
*.ac text eol=lf
*.am text eol=lf
*.hwdb text eol=lf

# Aspell claims issues finding `utf-8\r` sometimes (from heading line of
# the dictionary file), with messages like this:
# .cset" could not be opened for reading or does not exist.lib/aspell/utf-8
# which tends to happen in mixed-OS development environments. Tracer shows it:
# read(3, "personal_ws-1.1 en 3225 utf-8\r\nA"..., 4096) = 4096
# access("/usr/lib/aspell/utf-8\r.cset", F_OK) = -1 ENOENT (No such file or directory)
/docs/nut.dict text eol=lf

# Some files are binary always:
*.png bin
*.ico bin

# The rest are assumed text sources with platform-dependent EOL being okay,
# or we let Git guess otherwise:
* text=auto
2 changes: 2 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
paths:
- .
72 changes: 72 additions & 0 deletions .github/workflows/04-maven-nit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
name: "GHA-04: Maven NIT"

on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '22 12 * * 0'
workflow_dispatch:
# Allow manually running the action, e.g. if disabled after some quietness in the source

jobs:
maven-NIT:
name: "Compile the project, test against NUT data server"
runs-on: ${{ matrix.os }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
compilerpkg: [ 'openjdk-21-jdk' ]
# TOTHINK: various JDK versions?
os: [ 'ubuntu-latest' ]
# TOTHINK: windows-latest, macos-latest?

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Using hints from https://askubuntu.com/questions/272248/processing-triggers-for-man-db
- if: matrix.os == 'ubuntu-latest'
name: NUT CI Prerequisite packages (Ubuntu)
run: |
echo "set man-db/auto-update false" | sudo debconf-communicate
sudo dpkg-reconfigure man-db
sudo apt update
sudo apt install ${{ matrix.compilerpkg }} maven nut
date > .timestamp-init

- name: Prepare maven cache
# Based on https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#example-using-the-cache-action example
id: cache-m2cache
uses: actions/cache@v4
env:
cache-name: cache-m2cache-
with:
path: |
~/.m2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.timestamp-init') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

- name: Maven build and test
run: mvn package

# TODO: Setup NUT, run client (add in-tree script for that and call it)
116 changes: 116 additions & 0 deletions .github/workflows/06-codeql-java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "GHA-06: CodeQL Java"

on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '32 12 * * 0'
workflow_dispatch:
# Allow manually running the action, e.g. if disabled after some quietness in the source

jobs:
analyze:
name: Analyze
runs-on: ${{ matrix.os }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
compilerpkg: [ 'openjdk-21-jdk' ]
# TOTHINK: various JDK versions?
os: [ 'ubuntu-latest' ]
# TOTHINK: windows-latest, macos-latest?
build-mode: [ 'autobuild' ]
# manual ?
# https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
# Abusing "manual" here to try building with ccache (and
# have codeql not intercept that build but parse C/C++
# files on its own), and "manual" to custom-build without;
# the "autobuild" mode is handled by codeql itself but
# would probably ignore our CC/CXX setting
# NOTE: We do not add ccache to PATH when actually compiling NUT code
# (we only speed up "configure" stages), so compilation always happens
# and is parsed by current CodeQL detectors of the day as they evolve!

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Using hints from https://askubuntu.com/questions/272248/processing-triggers-for-man-db
- if: matrix.language == 'java' && matrix.os == 'ubuntu-latest'
name: NUT CI Prerequisite packages (Ubuntu)
run: |
echo "set man-db/auto-update false" | sudo debconf-communicate
sudo dpkg-reconfigure man-db
sudo apt update
sudo apt install ${{ matrix.compilerpkg }} maven
date > .timestamp-init

- name: Prepare maven cache
# Based on https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#example-using-the-cache-action example
id: cache-m2cache
uses: actions/cache@v4
env:
cache-name: cache-m2cache-
with:
path: |
~/.m2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.timestamp-init') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the (whole) list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: +security-extended,security-and-quality
config-file: ./.github/codeql/codeql-config.yml

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
# https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
- if: matrix.build-mode == 'autobuild'
name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

- if: matrix.build-mode != 'autobuild' && matrix.language == 'java'
name: Maven build and test
run: mvn package

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
19 changes: 0 additions & 19 deletions README

This file was deleted.

29 changes: 29 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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.

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).

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 to access NUT information via REST
web services.
4 changes: 0 additions & 4 deletions README.md

This file was deleted.

Loading
Loading