You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com> on 2015/10/05 15:46:24 UTC

Karaf assembly version

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 @@]

RE: Karaf assembly version

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
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:jean-philippe.clement@fr.thalesgroup.com] 
Envoyé : mardi 6 octobre 2015 09:05
À : user@karaf.apache.org
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:jb@nanthrax.net] Envoyé : lundi 5 octobre 2015 17:15 À : user@karaf.apache.org 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:jb@nanthrax.net] Envoyé : lundi 5 
> octobre 2015 16:52 À : user@karaf.apache.org 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:jb@nanthrax.net] Envoyé : lundi 5 
>> octobre 2015 16:06 À : user@karaf.apache.org 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é
>> jbonofre@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

RE: Karaf assembly version

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
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:jb@nanthrax.net] 
Envoyé : lundi 5 octobre 2015 17:15
À : user@karaf.apache.org
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:jb@nanthrax.net] Envoyé : lundi 5 
> octobre 2015 16:52 À : user@karaf.apache.org 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:jb@nanthrax.net] Envoyé : lundi 5 
>> octobre 2015 16:06 À : user@karaf.apache.org 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é
>> jbonofre@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf assembly version

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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:jb@nanthrax.net]
> Envoyé : lundi 5 octobre 2015 16:52
> À : user@karaf.apache.org
> 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:jb@nanthrax.net] Envoyé : lundi 5
>> octobre 2015 16:06 À : user@karaf.apache.org 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é
>> jbonofre@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

RE: Karaf assembly version

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
...and during the assembly, is there a way to write it to a file?

JP

[@@ OPEN @@]


-----Message d'origine-----
De : Jean-Baptiste Onofré [mailto:jb@nanthrax.net] 
Envoyé : lundi 5 octobre 2015 16:52
À : user@karaf.apache.org
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:jb@nanthrax.net] Envoyé : lundi 5 
> octobre 2015 16:06 À : user@karaf.apache.org 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é
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf assembly version

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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:jb@nanthrax.net]
> Envoyé : lundi 5 octobre 2015 16:06
> À : user@karaf.apache.org
> 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é
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

RE: Karaf assembly version

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
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:jb@nanthrax.net] 
Envoyé : lundi 5 octobre 2015 16:06
À : user@karaf.apache.org
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é
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf assembly version

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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é
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com