So I finally had time to look for a solution. I tried several thing and faced 
both a Karaf bug and a Maven bug which are not yet fixed. I finally found an 
easy solution using the Google replacer plugin to populate a cfg file and used 
the config admin to load it.

I created a simple "assembly.cfg" file under the filtered-resources/etc of my 
assembly containing:
        version=%VERSION%
        timestamp=%TIMESTAMP%

With the corresponding Maven conf:
                        <plugin>
                                
<groupId>com.google.code.maven-replacer-plugin</groupId>
                                <artifactId>replacer</artifactId>
                                <version>1.5.3</version>
                                <executions>
                                        <execution>
                                                <phase>compile</phase>
                                                <goals>
                                                        <goal>replace</goal>
                                                </goals>
                                        </execution>
                                </executions>
                                <configuration>
                                        
<file>${basedir}/src/main/filtered-resources/etc/assembly.cfg</file>
                                        
<outputFile>${basedir}/target/assembly/etc/assembly.cfg</outputFile>
                                        <replacements>
                                                <replacement>
                                                        <token>%VERSION%</token>
                                                        
<value>${project.version}</value>
                                                </replacement>
                                                <replacement>
                                                        
<token>%TIMESTAMP%</token>
                                                        
<value>${maven.build.timestamp}</value>
                                                </replacement>
                                        </replacements>
                                </configuration>
                        </plugin>

JP

[@@ OPEN @@]


-----Message d'origine-----
De : CLEMENT Jean-Philippe [mailto:[email protected]] 
Envoyé : mardi 6 octobre 2015 09:05
À : [email protected]
Objet : RE: Karaf assembly version

Great, I will investigate in that direction(s).

I also thought about another solution which might be simpler. In the assembly 
we have a kind of main feature which does have a version. Is there a way to 
retrieve it programmatically?

Regards,
JP

[@@ OPEN @@]

-----Message d'origine-----
De : Jean-Baptiste Onofré [mailto:[email protected]] Envoyé : lundi 5 octobre 
2015 17:15 À : [email protected] Objet : Re: Karaf assembly version

You can do that with resources-plugin and Maven directly (and also the artifact 
build helper).

Regards
JB

On 10/05/2015 05:11 PM, CLEMENT Jean-Philippe wrote:
> ...and during the assembly, is there a way to write it to a file?
>
> JP
>
> [@@ OPEN @@]
>
>
> -----Message d'origine-----
> De : Jean-Baptiste Onofré [mailto:[email protected]] Envoyé : lundi 5 
> octobre 2015 16:52 À : [email protected] Objet : Re: Karaf 
> assembly version
>
> So basically the project.version.
>
> I don't see anything already there for that. Sorry.
>
> Regards
> JB
>
> On 10/05/2015 04:48 PM, CLEMENT Jean-Philippe wrote:
>> Hi JB,
>>
>> The info shows the Karaf version (for instance 3.0.2), but I would like the 
>> assembly one, i.e. the one used to name the assembly archives (both .tar.gz 
>> and .zip).
>>
>> I would need this information at runtime. Is there a way to retrieve it?
>>
>> JP
>>
>> [@@ OPEN @@]
>>
>>
>> -----Message d'origine-----
>> De : Jean-Baptiste Onofré [mailto:[email protected]] Envoyé : lundi 5 
>> octobre 2015 16:06 À : [email protected] Objet : Re: Karaf 
>> assembly version
>>
>> Hi JP,
>>
>> you mean the version that you have in shell:info for instance ?
>>
>> You have a System property at runtime about that. I guess you need at build 
>> time ?
>>
>> Regards
>> JB
>>
>> On 10/05/2015 03:46 PM, CLEMENT Jean-Philippe wrote:
>>> Dear Karaf,
>>>
>>> I would like to retrieve the version used by the karaf-maven-plugin during 
>>> the assembly (for instance sample-assembly-1.0.0-SNAPSHOT.tar.gz => 
>>> 1.0.0-SNAPSHOT). The goal is to show it inside the application (something 
>>> like the "about" box).
>>>
>>> Is there a simple way to do so?
>>>
>>> Kind regards,
>>> JP
>>>
>>> [@@ OPEN @@]
>>>
>>
>> --
>> Jean-Baptiste Onofré
>> [email protected]
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>
> --
> Jean-Baptiste Onofré
> [email protected]
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to