diff --git a/distributions/openhab/merge-addon-info.groovy b/distributions/openhab/merge-addon-info.groovy new file mode 100755 index 0000000000..a7b546ea1b --- /dev/null +++ b/distributions/openhab/merge-addon-info.groovy @@ -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) diff --git a/distributions/openhab/pom.xml b/distributions/openhab/pom.xml index 3b2f7dc264..bdb8695b08 100644 --- a/distributions/openhab/pom.xml +++ b/distributions/openhab/pom.xml @@ -109,32 +109,83 @@ copy + + + + org.openhab.core.tools + upgradetool + ${project.version} + jar + jar-with-dependencies + true + ${project.build.directory}/assembly/bin + upgradetool.jar + + + org.openhab.addons.features.karaf + org.openhab.addons.features.karaf.openhab-addons-external + ${project.version} + xml + addons + true + ${project.build.directory}/addon-xml + addons.xml + + + + + + unpack + process-resources + + unpack + + + + + org.openhab.addons.bundles + org.openhab.binding.zigbee + ${project.version} + jar + **/addon.xml + ${project.build.directory}/addon-xml/org.openhab.binding.zigbee + + + org.openhab.addons.bundles + org.openhab.binding.zwave + ${project.version} + jar + **/addon.xml + ${project.build.directory}/addon-xml/org.openhab.binding.zwave + + + + + + + + org.codehaus.gmaven + groovy-maven-plugin + 2.1.1 + + + org.apache.groovy + groovy-all + 4.0.13 + pom + + + + + + execute + + process-resources + + ${project.basedir}/merge-addon-info.groovy + - - - - org.openhab.core.tools - upgradetool - ${project.version} - jar - jar-with-dependencies - true - ${project.build.directory}/assembly/bin - upgradetool.jar - - - org.openhab.addons.features.karaf - org.openhab.addons.features.karaf.openhab-addons-external - ${project.version} - xml - addons - true - ${project.build.directory}/assembly/runtime/etc - addons.xml - - - org.apache.maven.plugins