You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Matej Lazar <ma...@gmail.com> on 2013/12/16 18:38:25 UTC

Setting user property via cmd using group-id & artifact-id

Hi,

Is there a way to set user property via command line for a specific module.

I would like to use something like:
mvn clean instrall -Dgroup-id.artifact-id.maven.test.skip=true


Thanks,
Matej.

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


Re: Setting user property via cmd using group-id & artifact-id

Posted by Jörg Schaible <Jo...@scalaris.com>.
Cemo wrote:

> On 17 December 2013 11:45, Stephen Connolly
> <stephen.alan.connolly@gmail.com
>> wrote:
> 
>> Nope no feature request. It would be rejected.
> 
> 
> Actually It would be nice to have a configuration like this:
> 
>       <profile>
>          <id>disable-test</id>
>          <activation>
>             <property>
>                <name>${pom.groupId}.
${pom.artifactId}.maven.test.skip</name>
>             </property>
>          </activation>
>          <properties>
>             <maven.test.skip>true</maven.test.skip>
>          </properties>
>       </profile>
> 
> What do you think about this?  :)

Wrong attempt. As Stephan said, *you* have to setup your POMs to support 
such a feature. And you don't even need profiles, just a shared parent, 
where you add in the configuration section of the surefire plugin

=== shared parent pom ======== %< ======
 <build>
 ...
   <pluginManagement>
   ...
     <plugin>
       <artifactId>maven-surefire-plugin</artifactId>
       ...
       <configuration>
         <skipTests>${local.skip.tests}</skipTests>
         ...
       </configuration>
     </plugin>
   ...
   </pluginManagement>
 ...
 </build>
 ...
 <properties>
   <local.skip.tests>${maven.test.skip.exec}</local.skip.tests>
   ...
 </properties>
=== shared parent pom ======== %< ======

and in the individual POMs of the projects:

=== project pom ======== %< =========
 <groupId>group-id</groupId>
 <artifactId>artifact-id</artifactId>
 ...
 <properties>
   <group-id.artifact-
id.skip.tests.skip.tests>${maven.test.skip.exec}</group-id.artifact-
id.skip.tests.skip.tests>
   <local.skip.tests>${group-id.artifact-id.skip.tests}</local.skip.tests>
   ...
 </properties>
=== project pom ======== %< =========

The tests for any project containing the last two lines can be disabled 
individually now using -Dgroup-id.artifact-id.skip.tests=true on the command 
line. Without the system property or if the properties are not defined in 
the project at all, the test execution depends on the value of 
maven.test.skip.exec - just as normal.

So, it is just as Stephan said, with a bit of own XML glue code, you can do 
what you want, but don't expect ever that Maven works like this OOTB.

Cheers,
Jörg



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


Re: Setting user property via cmd using group-id & artifact-id

Posted by Cemo <ce...@gmail.com>.
On 17 December 2013 11:45, Stephen Connolly <stephen.alan.connolly@gmail.com
> wrote:

> Nope no feature request. It would be rejected.


Actually It would be nice to have a configuration like this:

      <profile>
         <id>disable-test</id>
         <activation>
            <property>
               <name>${pom.groupId}.${pom.artifactId}.maven.test.skip</name>
            </property>
         </activation>
         <properties>
            <maven.test.skip>true</maven.test.skip>
         </properties>
      </profile>

What do you think about this?  :)

Re: Setting user property via cmd using group-id & artifact-id

Posted by Stephen Connolly <st...@gmail.com>.
Nope no feature request. It would be rejected.

If you regularly need to tweak config of something, it is up to you to
prepare your poms before hand to allow for such tweaking by binding
properties to the <configuration> elements that you want to tweak and
providing the sensible defaults that you need.

The feature is actually there... but it is against the spirit of the Maven
way, hence you need to work by typing out xml to pay the penance for
straying from the Maven way ;-)


On 17 December 2013 09:17, Matej Lazar <ma...@gmail.com> wrote:

>
> Working on productization we want to avoid code (also pom) changing,
> but often we have to change some plugin property (tesets, source packing,
> ...)
> being able to change it via external property would be useful.
>
> Should I file a feature request? Under which component?
>
> Thanks,
> Matej.
>
>
> On 12/16/2013 09:54 PM, Stephen Connolly wrote:
> > not without changing the pom.
> >
> > You could set each module to have its own configuration for the skip
> > property, e.g.
> >
> > <properties>
> >   <maven.test.skip>${foobar.test.skip}</maven.test.skip>
> >   <foobar.test.skip>false</foobar.test.skip>
> > </properties>
> >
> > the above in module foobar, in module barfoo you'd have
> >
> > <properties>
> >   <maven.test.skip>${barfoo.test.skip}</maven.test.skip>
> >   <barfoo.test.skip>false</barfoo.test.skip>
> > </properties>
> >
> > And then you can get what you think you want...
> >
> > Spread this over 10 modules and you'll quickly realise that this is not
> the
> > solution you want
> >
> >
> > On 16 December 2013 20:30, Anders Hammar <an...@hammar.net> wrote:
> >
> >> No.
> >>
> >> /Anders (mobile)
> >> Den 16 dec 2013 18:38 skrev "Matej Lazar" <ma...@gmail.com>:
> >>
> >>> Hi,
> >>>
> >>> Is there a way to set user property via command line for a specific
> >> module.
> >>> I would like to use something like:
> >>> mvn clean instrall -Dgroup-id.artifact-id.maven.test.skip=true
> >>>
> >>>
> >>> Thanks,
> >>> Matej.
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>> For additional commands, e-mail: users-help@maven.apache.org
> >>>
> >>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Setting user property via cmd using group-id & artifact-id

Posted by Matej Lazar <ma...@gmail.com>.
Working on productization we want to avoid code (also pom) changing,
but often we have to change some plugin property (tesets, source packing, ...)
being able to change it via external property would be useful.

Should I file a feature request? Under which component?

Thanks,
Matej.


On 12/16/2013 09:54 PM, Stephen Connolly wrote:
> not without changing the pom.
>
> You could set each module to have its own configuration for the skip
> property, e.g.
>
> <properties>
>   <maven.test.skip>${foobar.test.skip}</maven.test.skip>
>   <foobar.test.skip>false</foobar.test.skip>
> </properties>
>
> the above in module foobar, in module barfoo you'd have
>
> <properties>
>   <maven.test.skip>${barfoo.test.skip}</maven.test.skip>
>   <barfoo.test.skip>false</barfoo.test.skip>
> </properties>
>
> And then you can get what you think you want...
>
> Spread this over 10 modules and you'll quickly realise that this is not the
> solution you want
>
>
> On 16 December 2013 20:30, Anders Hammar <an...@hammar.net> wrote:
>
>> No.
>>
>> /Anders (mobile)
>> Den 16 dec 2013 18:38 skrev "Matej Lazar" <ma...@gmail.com>:
>>
>>> Hi,
>>>
>>> Is there a way to set user property via command line for a specific
>> module.
>>> I would like to use something like:
>>> mvn clean instrall -Dgroup-id.artifact-id.maven.test.skip=true
>>>
>>>
>>> Thanks,
>>> Matej.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>


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


Re: Setting user property via cmd using group-id & artifact-id

Posted by Stephen Connolly <st...@gmail.com>.
not without changing the pom.

You could set each module to have its own configuration for the skip
property, e.g.

<properties>
  <maven.test.skip>${foobar.test.skip}</maven.test.skip>
  <foobar.test.skip>false</foobar.test.skip>
</properties>

the above in module foobar, in module barfoo you'd have

<properties>
  <maven.test.skip>${barfoo.test.skip}</maven.test.skip>
  <barfoo.test.skip>false</barfoo.test.skip>
</properties>

And then you can get what you think you want...

Spread this over 10 modules and you'll quickly realise that this is not the
solution you want


On 16 December 2013 20:30, Anders Hammar <an...@hammar.net> wrote:

> No.
>
> /Anders (mobile)
> Den 16 dec 2013 18:38 skrev "Matej Lazar" <ma...@gmail.com>:
>
> > Hi,
> >
> > Is there a way to set user property via command line for a specific
> module.
> >
> > I would like to use something like:
> > mvn clean instrall -Dgroup-id.artifact-id.maven.test.skip=true
> >
> >
> > Thanks,
> > Matej.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>

Re: Setting user property via cmd using group-id & artifact-id

Posted by Anders Hammar <an...@hammar.net>.
No.

/Anders (mobile)
Den 16 dec 2013 18:38 skrev "Matej Lazar" <ma...@gmail.com>:

> Hi,
>
> Is there a way to set user property via command line for a specific module.
>
> I would like to use something like:
> mvn clean instrall -Dgroup-id.artifact-id.maven.test.skip=true
>
>
> Thanks,
> Matej.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>