You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mirko Friedenhagen <mf...@gmail.com> on 2011/09/14 22:11:38 UTC

Accessing profiles via system properties etc.

Hello,

is there a possibility of accessing the activated Maven profile names during
test runs programmatically or in configuration files?

I want to activate logging to Lilith in a Maven profile. Adding the required
dependency is no problem, but for adding the appended conditionally seems
not to be possible. Are the activated profile names exposed?

Regards Mirko
-- 
Sent from my phone
http://illegalstateexception.blogspot.com
http://github.com/mfriedenhagen/

Re: Accessing profiles via system properties etc.

Posted by Mirko Friedenhagen <mf...@gmail.com>.
I just implemented the solution with the system property for the
location of the logfile
(https://github.com/mfriedenhagen/sardine/commit/74f2736bce4bb7d599ab9cf003135b1212c77ea6).
Still interested in better solutions, though :-).

Regards Mirko
--
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/
https://bitbucket.org/mfriedenhagen/



On Sat, Sep 17, 2011 at 21:16, Mirko Friedenhagen
<mf...@gmail.com> wrote:
> Well, I will try. I use slf4j for logging. I normally log using
> logback to stderrr. When
> de.huxhorn.lilith.logback.appender.multiplex-classic is available, I
> want to log to Lilith (http://lilith.huxhorn.de/), a graphical
> logviewer.
>
> I think the relevant parts are:
>
>       <!-- logging -->
>        <dependency>
>            <groupId>org.slf4j</groupId>
>            <artifactId>slf4j-api</artifactId>
>            <version>1.6.1</version>
>        </dependency>
>
>        <profile>
>            <id>lilith</id>
>            <dependencies>
>                <dependency>·
>                    <groupId>de.huxhorn.lilith</groupId>·
>
> <artifactId>de.huxhorn.lilith.logback.appender.multiplex-classic</artifactId>·
>                    <version>0.9.41</version>·
>                    <scope>test</scope>·
>                </dependency>
>            </dependencies>
>        </profile>
>
> And in my logback-test.xml I have:
>
>    <if condition='property("maven.profile").contains("lilith")'>
>        <appender name="multiplex"
> class="de.huxhorn.lilith.logback.appender.ClassicMultiplexSocketAppender">
>            <Compressing>true</Compressing> <!-- will automatically
> use correct default port --> <!-- Default port for compressed is 10000
> and uncompressed 10001 -->
>            <ReconnectionDelay>10000</ReconnectionDelay>
>            <IncludeCallerData>true</IncludeCallerData>
>            <RemoteHosts>localhost</RemoteHosts>
>        </appender>
>    </if>
>
> I think I could workaround this by specify a system property
> -Dlogback.configurationFile=src/test/resources/logback-with-lilith.xml
> in the surefire plugin but just wanted to know if there is an easier
> way to do this.
>
> Regards Mirko
> --
> http://illegalstateexception.blogspot.com/
> https://github.com/mfriedenhagen/
> https://bitbucket.org/mfriedenhagen/
>
>
>
> On Sat, Sep 17, 2011 at 16:20, Martin Gainty <mg...@hotmail.com> wrote:
>>
>> Mirko-
>>
>> Profiles allow or restrict what is visible to the project hierarchy ... *usually* based on current environment conditions
>> For example developing in Scandanavia you may allow greater access to properties than you would say when you are running demonstrations in the US
>>
>> can you provide an brief example of the profiles you are implementing in a comprehensive pom.xml so we may suggest an appropriate solution?
>>
>> Takk,
>> Martin
>> ______________________________________________
>> do not alter or disrupt this transmission.
>>
>>
>>> Date: Sat, 17 Sep 2011 16:04:14 +0200
>>> Subject: Re: Accessing profiles via system properties etc.
>>> From: mfriedenhagen@gmail.com
>>> To: users@maven.apache.org
>>>
>>> Really no one? I would appreciate a negative answer as well ;-) .
>>>
>>> On Sep 14, 2011 10:11 PM, "Mirko Friedenhagen" <mf...@gmail.com>
>>> wrote:
>>> >
>>> > Hello,
>>> >
>>> > is there a possibility of accessing the activated Maven profile names
>>> during test runs programmatically or in configuration files?
>>> >
>>> > I want to activate logging to Lilith in a Maven profile. Adding the
>>> required dependency is no problem, but for adding the appended conditionally
>>> seems not to be possible. Are the activated profile names exposed?
>>> >
>>> > Regards Mirko
>>> > --
>>> > Sent from my phone
>>> > http://illegalstateexception.blogspot.com
>>> > http://github.com/mfriedenhagen/
>>
>

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


Re: Accessing profiles via system properties etc.

Posted by Mirko Friedenhagen <mf...@gmail.com>.
Well, I will try. I use slf4j for logging. I normally log using
logback to stderrr. When
de.huxhorn.lilith.logback.appender.multiplex-classic is available, I
want to log to Lilith (http://lilith.huxhorn.de/), a graphical
logviewer.

I think the relevant parts are:

       <!-- logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>

        <profile>
            <id>lilith</id>
            <dependencies>
                <dependency>·
                    <groupId>de.huxhorn.lilith</groupId>·

<artifactId>de.huxhorn.lilith.logback.appender.multiplex-classic</artifactId>·
                    <version>0.9.41</version>·
                    <scope>test</scope>·
                </dependency>
            </dependencies>
        </profile>

And in my logback-test.xml I have:

    <if condition='property("maven.profile").contains("lilith")'>
        <appender name="multiplex"
class="de.huxhorn.lilith.logback.appender.ClassicMultiplexSocketAppender">
            <Compressing>true</Compressing> <!-- will automatically
use correct default port --> <!-- Default port for compressed is 10000
and uncompressed 10001 -->
            <ReconnectionDelay>10000</ReconnectionDelay>
            <IncludeCallerData>true</IncludeCallerData>
            <RemoteHosts>localhost</RemoteHosts>
        </appender>
    </if>

I think I could workaround this by specify a system property
-Dlogback.configurationFile=src/test/resources/logback-with-lilith.xml
in the surefire plugin but just wanted to know if there is an easier
way to do this.

Regards Mirko
--
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/
https://bitbucket.org/mfriedenhagen/



On Sat, Sep 17, 2011 at 16:20, Martin Gainty <mg...@hotmail.com> wrote:
>
> Mirko-
>
> Profiles allow or restrict what is visible to the project hierarchy ... *usually* based on current environment conditions
> For example developing in Scandanavia you may allow greater access to properties than you would say when you are running demonstrations in the US
>
> can you provide an brief example of the profiles you are implementing in a comprehensive pom.xml so we may suggest an appropriate solution?
>
> Takk,
> Martin
> ______________________________________________
> do not alter or disrupt this transmission.
>
>
>> Date: Sat, 17 Sep 2011 16:04:14 +0200
>> Subject: Re: Accessing profiles via system properties etc.
>> From: mfriedenhagen@gmail.com
>> To: users@maven.apache.org
>>
>> Really no one? I would appreciate a negative answer as well ;-) .
>>
>> On Sep 14, 2011 10:11 PM, "Mirko Friedenhagen" <mf...@gmail.com>
>> wrote:
>> >
>> > Hello,
>> >
>> > is there a possibility of accessing the activated Maven profile names
>> during test runs programmatically or in configuration files?
>> >
>> > I want to activate logging to Lilith in a Maven profile. Adding the
>> required dependency is no problem, but for adding the appended conditionally
>> seems not to be possible. Are the activated profile names exposed?
>> >
>> > Regards Mirko
>> > --
>> > Sent from my phone
>> > http://illegalstateexception.blogspot.com
>> > http://github.com/mfriedenhagen/
>

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


RE: Accessing profiles via system properties etc.

Posted by Martin Gainty <mg...@hotmail.com>.
Mirko-

Profiles allow or restrict what is visible to the project hierarchy ... *usually* based on current environment conditions
For example developing in Scandanavia you may allow greater access to properties than you would say when you are running demonstrations in the US

can you provide an brief example of the profiles you are implementing in a comprehensive pom.xml so we may suggest an appropriate solution?

Takk,
Martin 
______________________________________________ 
do not alter or disrupt this transmission.


> Date: Sat, 17 Sep 2011 16:04:14 +0200
> Subject: Re: Accessing profiles via system properties etc.
> From: mfriedenhagen@gmail.com
> To: users@maven.apache.org
> 
> Really no one? I would appreciate a negative answer as well ;-) .
> 
> On Sep 14, 2011 10:11 PM, "Mirko Friedenhagen" <mf...@gmail.com>
> wrote:
> >
> > Hello,
> >
> > is there a possibility of accessing the activated Maven profile names
> during test runs programmatically or in configuration files?
> >
> > I want to activate logging to Lilith in a Maven profile. Adding the
> required dependency is no problem, but for adding the appended conditionally
> seems not to be possible. Are the activated profile names exposed?
> >
> > Regards Mirko
> > --
> > Sent from my phone
> > http://illegalstateexception.blogspot.com
> > http://github.com/mfriedenhagen/
 		 	   		  

Re: Accessing profiles via system properties etc.

Posted by Anders Hammar <an...@hammar.net>.
I would guess no.

/Anders

On Sat, Sep 17, 2011 at 16:04, Mirko Friedenhagen
<mf...@gmail.com> wrote:
> Really no one? I would appreciate a negative answer as well ;-) .
>
> On Sep 14, 2011 10:11 PM, "Mirko Friedenhagen" <mf...@gmail.com>
> wrote:
>>
>> Hello,
>>
>> is there a possibility of accessing the activated Maven profile names
> during test runs programmatically or in configuration files?
>>
>> I want to activate logging to Lilith in a Maven profile. Adding the
> required dependency is no problem, but for adding the appended conditionally
> seems not to be possible. Are the activated profile names exposed?
>>
>> Regards Mirko
>> --
>> Sent from my phone
>> http://illegalstateexception.blogspot.com
>> http://github.com/mfriedenhagen/
>

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


Re: Accessing profiles via system properties etc.

Posted by Mirko Friedenhagen <mf...@gmail.com>.
Really no one? I would appreciate a negative answer as well ;-) .

On Sep 14, 2011 10:11 PM, "Mirko Friedenhagen" <mf...@gmail.com>
wrote:
>
> Hello,
>
> is there a possibility of accessing the activated Maven profile names
during test runs programmatically or in configuration files?
>
> I want to activate logging to Lilith in a Maven profile. Adding the
required dependency is no problem, but for adding the appended conditionally
seems not to be possible. Are the activated profile names exposed?
>
> Regards Mirko
> --
> Sent from my phone
> http://illegalstateexception.blogspot.com
> http://github.com/mfriedenhagen/