-
-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge addon info of all repos into one addons.xml file #1626
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b0e5553
Merge addon info of all repos into one addons.xml file
wborn 741980f
Improve different line endings support and some cleanup
wborn 14518af
Use Unix line endings
wborn 1e1c9f7
Fix encoding issues
wborn f065c6e
Fix encoding issues
wborn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this license header needed, and if so, is there a configuration in this repository for automatically updating copyright year in license headers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it because we also have it on our other Groovy file.
There is no license-maven-plugin config currently but we can add it before 2025 when the header survives the pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created #1627 for this