Skip to content

Commit

Permalink
Merge pull request #9 from voruti/clean-project-structure
Browse files Browse the repository at this point in the history
  • Loading branch information
voruti authored Aug 7, 2021
2 parents 0e6de9f + 71678d4 commit 01f4d73
Show file tree
Hide file tree
Showing 32 changed files with 2,042 additions and 1,197 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "tagged-release"

on:
push:
tags:
- "*.*"

jobs:
on-main-branch-check:
runs-on: ubuntu-latest
outputs:
on_main: ${{ steps.contains_tag.outputs.retval }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: rickstaa/action-contains-tag@fix_action_retval
id: contains_tag
with:
reference: "main"
tag: "${{ github.ref }}"
tagged-release:
name: "Tagged Release"
runs-on: "ubuntu-latest"
needs: on-main-branch-check
if: ${{ needs.on-main-branch-check.outputs.on_main == 'true' }}
steps:

# --- from gradle.yml ---
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
# --- from gradle.yml ---

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
build/libs/*all.jar
186 changes: 172 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ hs_err_pid*



# Created by https://www.gitignore.io/api/git,java,maven,windows,eclipse
# Edit at https://www.gitignore.io/?templates=git,java,maven,windows,eclipse
# Created by https://www.toptal.com/developers/gitignore/api/git,java,maven,eclipse,windows,intellij+all,gradle,linux,sonarqube,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=git,java,maven,eclipse,windows,intellij+all,gradle,linux,sonarqube,visualstudiocode

### Eclipse ###
.metadata
Expand Down Expand Up @@ -79,22 +79,19 @@ local.properties

# Annotation Processing
.apt_generated/
.apt_generated_test/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

### Eclipse Patch ###
# Eclipse Core
# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
.project

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Annotation Processing
.apt_generated

### Eclipse Patch ###
# Spring Boot Tooling
.sts4-cache/

### Git ###
Expand All @@ -112,6 +109,98 @@ local.properties
*_LOCAL_*.txt
*_REMOTE_*.txt

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

# Sonarlint plugin
.idea/sonarlint

### Java ###
# Compiled class file
*.class
Expand All @@ -137,6 +226,21 @@ local.properties
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### Maven ###
target/
pom.xml.tag
Expand All @@ -147,8 +251,44 @@ release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml

### Maven Patch ###
# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

### SonarQube ###
# SonarQube ignore files.
#
# https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
# Sonar Scanner working directories
.sonar/
.sonarqube/
.scannerwork/

# http://www.sonarlint.org/commandline/
# SonarLint working directories, configuration files (including credentials)
.sonarlint/

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

### Windows ###
# Windows thumbnail cache files
Expand Down Expand Up @@ -176,9 +316,27 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/git,java,maven,windows,eclipse
### Gradle ###
.gradle
build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

*.json
*.items
# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties

### Gradle Patch ###
**/build/

# Eclipse Gradle plugin generated files
# Eclipse Core
# JDT-specific (Eclipse Java Development Tools)

# End of https://www.toptal.com/developers/gitignore/api/git,java,maven,eclipse,windows,intellij+all,gradle,linux,sonarqube,visualstudiocode
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
# JSON2Config

A simple utility program which converts [openHAB Items](https://www.openhab.org/docs/configuration/items.html) from [JsonDB Storage](https://www.openhab.org/docs/administration/jsondb.html) files (e.g. org.eclipse.smarthome.core.items.Item.json, org.eclipse.smarthome.core.thing.link.ItemChannelLink.json) to textual configuration files (e.g. my.items).

A simple utility program which converts [openHAB Items](https://www.openhab.org/docs/configuration/items.html)
from [JsonDB Storage](https://www.openhab.org/docs/administration/jsondb.html) files (e.g.
org.eclipse.smarthome.core.items.Item.json, org.eclipse.smarthome.core.thing.link.ItemChannelLink.json) to textual
configuration files (e.g. my.items).

Tested on openHAB 2.X versions.

## Usage

You can run the tool with Java:

```bash
java -jar json2config-XXX.jar [arguments]
```
The program has two main features. By default only the first one will be executed.

The program has two main features. By default, only the first one will be executed.

### 1. Converting org.eclipse.smarthome.core.items.Item.json into a *.items file

To convert the JSON file, you can simply put this tool into the [JSON DB storage location](https://www.openhab.org/docs/administration/jsondb.html#storage-location) and run it. This will create a `json.items` file with all the items from the `org.eclipse.smarthome.core.items.Item.json` file.
To convert the JSON file, you can simply put this tool into
the [JSON DB storage location](https://www.openhab.org/docs/administration/jsondb.html#storage-location) and run it.
This will create a `json.items` file with all the items from the `org.eclipse.smarthome.core.items.Item.json` file.
Alternatively you can adjust the program arguments to specify the file locations:

- The `-i <path>`/`--in <path>`/`--json <path>` parameters allow you to specify the input .json file.
- The `-o <path>`/`--out <path>` parameters allow you to specify the output file.
- The `-n` parameter allows you to disable this (converting) feature completely; if you want to only append the channel links.
- The `-n` parameter allows you to disable this (converting) feature completely; if you want to only append the channel
links.

### 2. Appending channel links from org.eclipse.smarthome.core.thing.link.ItemChannelLink.json to *.items files

To append channel links to *already existing* .items files, you can use the second feature. If you already have some `*.items` files in your configuration, it's recommended to also including these files i.e. moving them into the same directory. By default (when the appending feature is enabled!!) the tool will use channel links from the `org.eclipse.smarthome.core.thing.link.ItemChannelLink.json` file and append them to all `*.items` files in the same directory.
Alternatively you can adjust the program arguments to specify the file locations:
- The `-c`/`--channel`/`--create-channel-links` parameters enable the appending feature. Without one of these, this feature won't run!
- The `--channel-file <path>`/`--channel-link-file <path>` parameters allow you to specify the .json file location containing the channel links.
- The `-d <path>`/`--dir <path>`/`--directory <path>` parameters allow you to specity the directory in which to search for *.items files.

:exclamation:Channel Link **Profiles** currently will be lost in this process:exclamation: (They can - of course - manually be added afterwards)


#### Other program parameters
To append channel links to *already existing* .items files, you can use the second feature. If you already have
some `*.items` files in your configuration, it's recommended to also including these files i.e. moving them into the
same directory. By default, (when the appending feature is enabled!!) the tool will use channel links from
the `org.eclipse.smarthome.core.thing.link.ItemChannelLink.json` file and append them to all `*.items` files in the same
directory. Alternatively you can adjust the program arguments to specify the file locations:

When enabling both features, the converting feature will run first, so the appending feature can then use the generated .items file to append the channel links.
- The `-c`/`--channel`/`--create-channel-links` parameters enable the appending feature. Without one of these, this
feature won't run!
- The `--channel-file <path>`/`--channel-link-file <path>` parameters allow you to specify the .json file location
containing the channel links.
- The `-d <path>`/`--dir <path>`/`--directory <path>` parameters allow you to specify the directory in which to search
for *.items files.

With the `-l`/`--log`/`--enable-logging` parameters logging can be enabled. This creates a `latest.log` file in the same directory.
:exclamation:Channel Link **Profiles** (value → configuration → properties → profile) currently will be lost in this
process:exclamation: (They can - of course - manually be added afterwards)

#### Other program features

When enabling both features, the converting feature will run first, so the appending feature can then use the generated
.items file to append the channel links.
Loading

0 comments on commit 01f4d73

Please sign in to comment.