You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Olivier Dehon <od...@gmail.com> on 2007/10/20 15:01:55 UTC

How to get Java source filtered the same way as resources?

Hi,

Is there a (simple) way to get the java source code in my project
filtered the same way resources are?
That is, in my java file, I could have:

{code}
private final static String MAVEN_VERSION = "${version}";
{code}

and get ${version} replaced at build time?

What I want to achieve here is a way of interrogating my app for its
maven version number at run time, without having to rely on an external
file or resource.

Thanks for any hints.

-Olivier

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to get Java source filtered the same way as resources?

Posted by Mick Knutson <mi...@gmail.com>.
the benefits Spring gives you above and beyond filtering is WAY worth the
effort IMHO.

On 10/20/07, Olivier Dehon <od...@gmail.com> wrote:
>
> Jörg Schaible wrote:
> > Olivier Dehon wrote:
> >
> >> Hi,
> >>
> >> Is there a (simple) way to get the java source code in my project
> >> filtered the same way resources are?
> >> That is, in my java file, I could have:
> >>
> >> {code}
> >> private final static String MAVEN_VERSION = "${version}";
> >> {code}
> >>
> >> and get ${version} replaced at build time?
> >>
> >> What I want to achieve here is a way of interrogating my app for its
> >> maven version number at run time, without having to rely on an external
> >> file or resource.
> >>
> >> Thanks for any hints.
> >>
> >
> > Why not use the manifest ?
> >
> >
> I do not want to pay the price of reading that information from an
> external
> resource, when it can be made available statically when the code is
> compiled.
>
> I guess I will have to write a plugin similar to the resources plugin
> and apply it at the "generate-sources" phase on the source files that need
> to be filtered.
>
> -Olivier
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 

Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/djmick_dot_com
http://www.myspace.com/sexybeotches
http://www.thumpradio.com
---

Re: How to get Java source filtered the same way as resources?

Posted by Olivier Dehon <od...@gmail.com>.
Jörg Schaible wrote:
> Olivier Dehon wrote:
>   
>> Hi,
>>
>> Is there a (simple) way to get the java source code in my project
>> filtered the same way resources are?
>> That is, in my java file, I could have:
>>
>> {code}
>> private final static String MAVEN_VERSION = "${version}";
>> {code}
>>
>> and get ${version} replaced at build time?
>>
>> What I want to achieve here is a way of interrogating my app for its
>> maven version number at run time, without having to rely on an external
>> file or resource.
>>
>> Thanks for any hints.
>>     
>
> Why not use the manifest ?
>
>   
I do not want to pay the price of reading that information from an external
resource, when it can be made available statically when the code is 
compiled.

I guess I will have to write a plugin similar to the resources plugin
and apply it at the "generate-sources" phase on the source files that need
to be filtered.

-Olivier

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to get Java source filtered the same way as resources?

Posted by Mick Knutson <mi...@gmail.com>.
Then you could filter the applicationContext, or the
application.propertiesfile. This is what I do in my project (filter
application.properties)

On 10/20/07, Mick Knutson <mi...@gmail.com> wrote:
>
> You could use Spring and inject that value from applicationContext.xml or
> and external properties file.
>
> On 10/20/07, Jörg Schaible < joerg.schaible@gmx.de> wrote:
> >
> > Olivier Dehon wrote:
> >
> > > Hi,
> > >
> > > Is there a (simple) way to get the java source code in my project
> > > filtered the same way resources are?
> > > That is, in my java file, I could have:
> > >
> > > {code}
> > > private final static String MAVEN_VERSION = "${version}";
> > >You could use {code}
> > >
> > > and get ${version} replaced at build time?
> > >
> > > What I want to achieve here is a way of interrogating my app for its
> > > maven version number at run time, without having to rely on an
> > external
> > > file or resource.
> > >
> > > Thanks for any hints.
> >
> > Why not use the manifest ?
> >
> > - Jörg
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
>
> Thanks,
> Mick Knutson
>
> http://www.baselogic.com
> http://www.blincmagazine.com
> http://www.djmick.com
> http://www.myspace.com/mickknutson
> http://www.myspace.com/djmick_dot_com
> http://www.myspace.com/sexybeotches
> http://www.thumpradio.com
> ---




-- 

Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/djmick_dot_com
http://www.myspace.com/sexybeotches
http://www.thumpradio.com
---

Re: How to get Java source filtered the same way as resources?

Posted by Mick Knutson <mi...@gmail.com>.
You could use Spring and inject that value from applicationContext.xml or
and external properties file.

On 10/20/07, Jörg Schaible <jo...@gmx.de> wrote:
>
> Olivier Dehon wrote:
>
> > Hi,
> >
> > Is there a (simple) way to get the java source code in my project
> > filtered the same way resources are?
> > That is, in my java file, I could have:
> >
> > {code}
> > private final static String MAVEN_VERSION = "${version}";
> >You could use {code}
> >
> > and get ${version} replaced at build time?
> >
> > What I want to achieve here is a way of interrogating my app for its
> > maven version number at run time, without having to rely on an external
> > file or resource.
> >
> > Thanks for any hints.
>
> Why not use the manifest ?
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 

Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/djmick_dot_com
http://www.myspace.com/sexybeotches
http://www.thumpradio.com
---

Re: How to get Java source filtered the same way as resources?

Posted by Jörg Schaible <jo...@gmx.de>.
Olivier Dehon wrote:

> Hi,
> 
> Is there a (simple) way to get the java source code in my project
> filtered the same way resources are?
> That is, in my java file, I could have:
> 
> {code}
> private final static String MAVEN_VERSION = "${version}";
> {code}
> 
> and get ${version} replaced at build time?
> 
> What I want to achieve here is a way of interrogating my app for its
> maven version number at run time, without having to rely on an external
> file or resource.
> 
> Thanks for any hints.

Why not use the manifest ?

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org