[archetype] Fixed generation of binding skeletons (#817)

* Fixed generation of binding skeletons
* [archetype] Include feature.xml in archetype-metadata.xml (#1)

Also-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2019-05-17 08:35:36 +02:00 committed by Markus Rathgeb
parent 0aaad726ff
commit 2ace118b92
3 changed files with 15 additions and 28 deletions

View File

@ -75,33 +75,6 @@ def addBundleToBom(bundleAfter, newBundle) {
println 'Added bundle to bom pom'
}
/**
* Add the new bundle to the feature.xml
*/
def addBundleToFeature(bundleAfter, newBundle, bundleName) {
def feature = '''
<feature name="##1" description="##2 Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/##3/${project.version}</bundle>
</feature>
'''.replace('##1', newBundle.replace('org.', '').replace('.', '-')).replace('##2', bundleName).replace('##3', newBundle)
def bomFile = new File(outputDirectory, '../features/openhab-addons/src/main/feature/feature.xml')
def newContent = ''
def insertIndex = 0;
def lines = bomFile.eachLine { line, index ->
newContent += line + nl
if (line.contains(bundleAfter) && line.contains('<bundle')) {
insertIndex = index + 1
}
if (insertIndex > 0 && index == insertIndex) {
newContent += feature
insertIndex = 0
}
}
bomFile.write(newContent)
println 'Added bundle to feature.xml'
}
//
/**
* Fix the bundle parent pom. The maven archytype adds the bundle, but add the end of the module list.
@ -139,7 +112,6 @@ if (codeownersFile.exists()) {
println 'Add new bundle after: ' + bundleAfter
addUserToCodewoners(githubUser, codeownersFile, bundleAfter, newBundle)
addBundleToBom(bundleAfter, newBundle)
addBundleToFeature(bundleAfter, newBundle, bundleName)
fixBundlePom(bundleAfter, newBundle)
println ''

View File

@ -34,6 +34,12 @@
<include>README.md</include>
</includes>
</fileSet>
<fileSet filtered="true" packaged="false" encoding="UTF-8">
<directory>src/main/feature</directory>
<includes>
<include>feature.xml</include>
</includes>
</fileSet>
<fileSet filtered="true" packaged="false" encoding="UTF-8">
<directory>src/main/resources/ESH-INF</directory>
<includes>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="${rootArtifactId}-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${project.version}/xml/features</repository>
<feature name="openhab-binding-${bindingId}" description="${bindingIdCamelCase} Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/${rootArtifactId}/${project.version}</bundle>
</feature>
</features>