-
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge addon info of all repos into one addons.xml file (#1626)
* Merge addon info of all repos into one addons.xml file Extracts the ZigBee and Z-Wave addon.xml files and merges them into the addons.xml file using Groovy. Signed-off-by: Wouter Born <github@maindrain.net>
- Loading branch information
Showing
2 changed files
with
120 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) 2010-2024 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
import groovy.xml.XmlNodePrinter | ||
import groovy.xml.XmlParser | ||
|
||
def baseDir = Paths.get(getClass().protectionDomain.codeSource.location.toURI()).toAbsolutePath() | ||
def xmlDir = baseDir.resolveSibling("target/addon-xml") | ||
|
||
// Read the addons.xml containing the addon info of openhab-addons | ||
def addonsXmlPath = xmlDir.resolve("addons.xml") | ||
println "Reading: ${addonsXmlPath}" | ||
def addonsXml = String.join("\n", Files.readAllLines(addonsXmlPath)) | ||
def header = addonsXml.substring(0, addonsXml.indexOf("-->") + 4) | ||
def addonInfoList = new XmlParser().parse(Files.newBufferedReader(addonsXmlPath)) | ||
|
||
// Read and append the addon info in addon.xml of other repositories | ||
Files.walk(xmlDir).forEach(path -> { | ||
if (Files.isRegularFile(path) && "addon.xml" == path.getFileName().toString()) { | ||
println "Reading: ${path}" | ||
def addonInfo = new XmlParser().parse(Files.newBufferedReader(path)) | ||
addonInfoList.children().get(0).append(addonInfo) | ||
} | ||
}) | ||
|
||
// Write the combined addon info to addons.xml | ||
def assemblyXmlPath = baseDir.resolveSibling("target/assembly/runtime/etc/addons.xml") | ||
println "Writing: ${assemblyXmlPath} (${addonInfoList.addons.'*'.size()} add-ons)" | ||
|
||
def pw = new PrintWriter(Files.newBufferedWriter(assemblyXmlPath)) | ||
pw.append(header) | ||
def np = new XmlNodePrinter(pw, "\t") | ||
np.setPreserveWhitespace(true) | ||
np.print(addonInfoList) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters