Hi JB, I see your point. I suppose I was trying to avoid having to write a feature input file with either <configfile> or <config>, I wanted to keep all the configuration parameters as a separate file. I understand that 'features' are a Karaf specific thing and therefore didn't want to place OSGi compatible configuration data inside an implementation-specific file, if that makes sense. This is not a major issue for me, just wondered if it could be done.
Kerry On 26/02/17 17:21, Jean-Baptiste Onofré wrote:
Not sure I fully understand your point: 1. Instead of <configfile/>, you can use <config/> in a feature. Then, the cfg file will be created based on the <config/> content. 2. What you describe is basically a KAR that embed the cfg file with the features repo. Regards JB On 02/26/2017 05:15 PM, JT wrote:Hi Achim, Let me try and explain myself. Currently I create a 'feature' XML file for my bundle using the karaf-maven-plugin. By default this will create a features.xml file without the need for me to create an input features.xml file to the plugin i.e. everything is done for me automatically. The relevant part of the POM is: <id>generate</id> <phase>generate-resources</phase> <goals> <goal>features-generate-descriptor</goal> </goals> <configuration> <outputFile>target/features.xml</outputFile> <includeProjectArtifact>true</includeProjectArtifact> </configuration> Now I want to include a <configfile> entry in the feature.xml. As far as I can tell, I have to create an input feature file which contains the <configfile> entry: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="grid-layout"> <feature name="${project.artifactId}" version="${pom.version}"> <configfile finalname="etc/com.example.gridlayout.cfg"mvn:${project.groupId}/${project.artifactId}/${pom.version}/cfg/config</configfile></feature> </features> And then modify the plugin configuration to use this file as its feature file input to which it will append all other entries: <configuration> <inputFile>src/main/resources/feature.xml</inputFile> <outputFile>target/features.xml</outputFile> <includeProjectArtifact>true</includeProjectArtifact> </configuration> If it's not currently possible, I was thinking it might be better if the karaf tooling plugin could be modified to accept configuration properties to allow a <configfile> property to be included in the features file but without having to create an input feature XML e.g. <configuration> <includeConfigFile>true</includeConfigFile> <configFileMavenCoordinates>mvn:${project.groupId}/${project.artifactId}/${pom.version}/cfg/config</configFileMavenCoordinates> <configfilefinalName>etc/com.example.gridlayout.cfg</configFinalName> </configuration> I started to take a look the the GenerateDescriptorMojo and realised it might not be as straight-forward as the above as multiple config files can potentially be specified in a feature XML file. Do you think this is feasible? I'd be willing to try and get this to work and submit a PR. Kerry On 26/02/17 15:41, Achim Nierbeck wrote:Hi Kerry, I'm not sure I follow the "template" logic here. with the <configfile> property you can add any kind of configuration file. One Use-Case for example is to place the needed jetty.xml file along the installation of the pax-web feature. So I'm not sure I see something missing at this point, so please could you elaborate a bit more on this point, about what you are missing here :-) regards, Achim 2017-02-26 10:08 GMT+01:00 JT <[email protected] <mailto:[email protected]>>: Hi JB, Thanks for the update. Good to know you are adding that functionality. One other thing I wondered about. If there is a need to add a configuration file as part of a feature, currently the only way to do this is to make a 'template' feature file including the <configfile> property. It would be nice if rather than creating a template, the config file to be included could be specified in the karaf tooling plugin. Would that be feasible? I don't require that myself right now but would be willing to take a look and submit a pull-request if I come up with a solution. Kerry On 26/02/17 08:47, Jean-Baptiste Onofré wrote: Hi Kerry, you can install a cfg file dropping in the etc folder. For a command, I created a Jira some weeks ago about a config:install command. It's already possible using tac| "command" but not obvious. config:install command (and MBean) will be available in 4.0.9 and 4.1.1. You will be able to do: config:install mvn:groupId/artifactId/version/cfg Regards JB On 02/26/2017 08:56 AM, JT wrote: Hi All, I've seen how I can deploy a config file as part of a Karaf 'feature' using Christian's tutorial (http://www.liquid-reality.de/display/liquid/2011/09/23/Karaf+Tutorial+Part+2+-+Using+the+Configuration+Admin+Service?src=contextnav <http://www.liquid-reality.de/display/liquid/2011/09/23/Karaf+Tutorial+Part+2+-+Using+the+Configuration+Admin+Service?src=contextnav>). Is it possible to deploy a config file without the need to include in a features file? i.e. I would like to install it standalone with an install command such as 'install mvn:<maven-coordinates>/cfg/config' many thanks Kerry -- Apache Member Apache Karaf <http://karaf.apache.org/> Committer & PMC OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead blog <http://notizblog.nierbeck.de/> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS> Software Architect / Project Manager / Scrum Master
