You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "KARR, DAVID" <dk...@att.com> on 2017/02/20 16:32:46 UTC

Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Although my issue is about configuring the "jacoco-maven-plugin", I think it's really more of a pure Maven configuration issue, as I don't think this situation is unique to JaCoCo.

I have a somewhat large multi-module project.  Each of the child modules has a parent pom that configures the "jacoco-maven-plugin" to do offline instrumentation (at present, all the modules having unit tests using PowerMock, which doesn't work with online instrumentation).

I've designed a change that I'll have to make in a few classes in each module that will allow the unit tests to use Mockito, and for JaCoCo to use online instrumentation.  I'll eventually fix all of them to work this way, but it will take a little while.  In the meantime, I just want to override the configuration in the "fixed" modules with online instrumentation and let the other modules use the default of offline instrumentation.

The simple-minded way to do this is just to define the same configuration using online instrumentation in each "fixed" module, so it will override the parent pom.  Copying that block to every "fixed" module is not a great idea.  I'd like a solution that requires less code duplication.

I suppose I could define ANOTHER parent pom, that specifies the existing parent as its parent, and have that second parent use online instrumentation, and have the fixed modules use that second parent instead.  I will eventually delete this second parent pom once all of the modules are "fixed".

Note that I have a separate aggregator pom that is not a parent pom.

Are there other reasonable strategies for this "use original parent for some, override in same way for others" situation?



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


Re: Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Posted by Jörg Schaible <jo...@bpm-inspire.com>.
Hi Anders,

Anders Hammar wrote:

> Profiles are never a "perfect match". They are evil.

Profiles are a tool, that can be used for good or bad (e.g. defining 
additional/different dependencies). There's no need to demonise it.

Cheers,
J�rg


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


Re: Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Posted by Anders Hammar <an...@hammar.net>.
Profiles are never a "perfect match". They are evil.

My suggestion is this:
Add the "correct" configuration (the one you want in the end, online
instrumentation) to your parent pom. Then in all projects where your still
want offline configuration you override this. Ideally it's just a few
config lines for the jacoco-maven-plugin in pluginMgmt.
The thinking is that for every project/module your change to online
instrumentation you also then clean up the pom wrt the old offline config.
The other way around to change to online instrumentation by ADDING config
is not right IMO.

/Anders

On Tue, Feb 21, 2017 at 8:48 AM, Jörg Schaible <
joerg.schaible@bpm-inspire.com> wrote:

> Hi David,
>
> this is a perfect match for a profile. Define your "fixed" configuration in
> a profile of the parent that is activated based on the existance of a file.
> Add such a "dummy" file in all sub project that should run with the profile
> activated, e.g. "touch profiles/fixed". Then you will not even have to
> modify the POMs of the sub projects.
>
> Cheers,
> Jörg
>
> KARR, DAVID wrote:
>
> > Although my issue is about configuring the "jacoco-maven-plugin", I think
> > it's really more of a pure Maven configuration issue, as I don't think
> > this situation is unique to JaCoCo.
> >
> > I have a somewhat large multi-module project.  Each of the child modules
> > has a parent pom that configures the "jacoco-maven-plugin" to do offline
> > instrumentation (at present, all the modules having unit tests using
> > PowerMock, which doesn't work with online instrumentation).
> >
> > I've designed a change that I'll have to make in a few classes in each
> > module that will allow the unit tests to use Mockito, and for JaCoCo to
> > use online instrumentation.  I'll eventually fix all of them to work this
> > way, but it will take a little while.  In the meantime, I just want to
> > override the configuration in the "fixed" modules with online
> > instrumentation and let the other modules use the default of offline
> > instrumentation.
> >
> > The simple-minded way to do this is just to define the same configuration
> > using online instrumentation in each "fixed" module, so it will override
> > the parent pom.  Copying that block to every "fixed" module is not a
> great
> > idea.  I'd like a solution that requires less code duplication.
> >
> > I suppose I could define ANOTHER parent pom, that specifies the existing
> > parent as its parent, and have that second parent use online
> > instrumentation, and have the fixed modules use that second parent
> > instead.  I will eventually delete this second parent pom once all of the
> > modules are "fixed".
> >
> > Note that I have a separate aggregator pom that is not a parent pom.
> >
> > Are there other reasonable strategies for this "use original parent for
> > some, override in same way for others" situation?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Posted by Jörg Schaible <jo...@bpm-inspire.com>.
Hi David,

this is a perfect match for a profile. Define your "fixed" configuration in  
a profile of the parent that is activated based on the existance of a file. 
Add such a "dummy" file in all sub project that should run with the profile 
activated, e.g. "touch profiles/fixed". Then you will not even have to 
modify the POMs of the sub projects.

Cheers,
J�rg

KARR, DAVID wrote:

> Although my issue is about configuring the "jacoco-maven-plugin", I think
> it's really more of a pure Maven configuration issue, as I don't think
> this situation is unique to JaCoCo.
> 
> I have a somewhat large multi-module project.  Each of the child modules
> has a parent pom that configures the "jacoco-maven-plugin" to do offline
> instrumentation (at present, all the modules having unit tests using
> PowerMock, which doesn't work with online instrumentation).
> 
> I've designed a change that I'll have to make in a few classes in each
> module that will allow the unit tests to use Mockito, and for JaCoCo to
> use online instrumentation.  I'll eventually fix all of them to work this
> way, but it will take a little while.  In the meantime, I just want to
> override the configuration in the "fixed" modules with online
> instrumentation and let the other modules use the default of offline
> instrumentation.
> 
> The simple-minded way to do this is just to define the same configuration
> using online instrumentation in each "fixed" module, so it will override
> the parent pom.  Copying that block to every "fixed" module is not a great
> idea.  I'd like a solution that requires less code duplication.
> 
> I suppose I could define ANOTHER parent pom, that specifies the existing
> parent as its parent, and have that second parent use online
> instrumentation, and have the fixed modules use that second parent
> instead.  I will eventually delete this second parent pom once all of the
> modules are "fixed".
> 
> Note that I have a separate aggregator pom that is not a parent pom.
> 
> Are there other reasonable strategies for this "use original parent for
> some, override in same way for others" situation?



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


RE: Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Martin Hoeller [mailto:martin@xss.co.at]
> Sent: Monday, February 20, 2017 11:44 PM
> To: Maven Users List <us...@maven.apache.org>
> Subject: Re: Strategies for overriding parent plugin configuration in
> some modules without duplicating config code?
> 
> Hi!
> 
> On Mon, 20 Feb 2017 16:32 "KARR, DAVID" <dk...@att.com> wrote:
> 
> > Although my issue is about configuring the "jacoco-maven-plugin", I
> > think it's really more of a pure Maven configuration issue, as I don't
> > think this situation is unique to JaCoCo.
> >
> > I have a somewhat large multi-module project.  Each of the child
> > modules has a parent pom that configures the "jacoco-maven-plugin" to
> > do offline instrumentation (at present, all the modules having unit
> > tests using PowerMock, which doesn't work with online
> > instrumentation).
> >
> > I've designed a change that I'll have to make in a few classes in each
> > module that will allow the unit tests to use Mockito, and for JaCoCo
> > to use online instrumentation.  I'll eventually fix all of them to
> > work this way, but it will take a little while.  In the meantime, I
> > just want to override the configuration in the "fixed"
> > modules with online instrumentation and let the other modules use the
> > default of offline instrumentation.
> >
> > The simple-minded way to do this is just to define the same
> > configuration using online instrumentation in each "fixed" module, so
> > it will override the parent pom.  Copying that block to every "fixed"
> > module is not a great idea.  I'd like a solution that requires less
> > code duplication.
> 
> 
> Just two weeks ago Tamás Cservenák pointed out on this list the
> configuration-maven-plugin [1]. I haven't used it myself, but it sounds
> like this plugin could help you saving some code duplication.
> 
> hth,
> - martin
> 
> [1] https://github.com/cstamas/configuration-maven-plugin

It does look promising, but as the README says, this is just a "proof of concept" and doesn't appear to be available in mavencentral.

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


Re: Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Posted by Martin Hoeller <ma...@xss.co.at>.
Hi!

On Mon, 20 Feb 2017 16:32 "KARR, DAVID" <dk...@att.com> wrote:

> Although my issue is about configuring the "jacoco-maven-plugin", I
> think it's really more of a pure Maven configuration issue, as I
> don't think this situation is unique to JaCoCo.
> 
> I have a somewhat large multi-module project.  Each of the child
> modules has a parent pom that configures the "jacoco-maven-plugin" to
> do offline instrumentation (at present, all the modules having unit
> tests using PowerMock, which doesn't work with online
> instrumentation).
> 
> I've designed a change that I'll have to make in a few classes in
> each module that will allow the unit tests to use Mockito, and for
> JaCoCo to use online instrumentation.  I'll eventually fix all of
> them to work this way, but it will take a little while.  In the
> meantime, I just want to override the configuration in the "fixed"
> modules with online instrumentation and let the other modules use the
> default of offline instrumentation.
> 
> The simple-minded way to do this is just to define the same
> configuration using online instrumentation in each "fixed" module, so
> it will override the parent pom.  Copying that block to every "fixed"
> module is not a great idea.  I'd like a solution that requires less
> code duplication.


Just two weeks ago Tamás Cservenák pointed out on this list the
configuration-maven-plugin [1]. I haven't used it myself, but it sounds
like this plugin could help you saving some code duplication.

hth,
- martin

[1] https://github.com/cstamas/configuration-maven-plugin

RE: Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: KARR, DAVID
> Sent: Wednesday, February 22, 2017 11:04 AM
> To: Maven Users List <us...@maven.apache.org>
> Subject: RE: Strategies for overriding parent plugin configuration in
> some modules without duplicating config code?
> 
> > -----Original Message-----
> > From: Justin Georgeson [mailto:JGeorgeson@lgc.com]
> > Sent: Monday, February 20, 2017 8:40 AM
> > To: Maven Users List <us...@maven.apache.org>
> > Subject: RE: Strategies for overriding parent plugin configuration in
> > some modules without duplicating config code?
> >
> > Have you looked at combine.children="append" or
> combine.self="override"
> > attributes to the <configuration> element?
> >
> > https://urldefense.proofpoint.com/v2/url?u=http-
> > 3A__blog.sonatype.com_2011_01_maven-2Dhow-2Dto-2Dmerging-2Dplugin-
> > 2Dconfiguration-2Din-2Dcomplex-2Dprojects_&d=DQIFAg&c=LFYZ-
> > o9_HUMeMTSQicvjIg&r=OsTemSXEn-
> > xy2uk0vYF_EA&m=FHuWQ_q8B5maEN_es6oJCbGAxMD8fxn8FxP0AQ9VZ3w&s=hQ-
> > pliBIxKnBjdS66GjKAlZqdGHagiZTuPSvxK1SoFU&e=
> > https://urldefense.proofpoint.com/v2/url?u=https-
> > 3A__maven.apache.org_pom.html&d=DQIFAg&c=LFYZ-
> > o9_HUMeMTSQicvjIg&r=OsTemSXEn-
> > xy2uk0vYF_EA&m=FHuWQ_q8B5maEN_es6oJCbGAxMD8fxn8FxP0AQ9VZ3w&s=GptXYbOIz
> > Ww
> > xSTYZmwZufxSKr6WYerQ_ll_D1fVE-D4&e=
> 
> How do I override the "executions" list?  These properties aren't valid
> there.

If anyone searches for this in the future, I've figured out how to do this.  If I need to make an execution defined in the parent do nothing in the child, I set it in the child to phase "none".

Yes, this is clearly a hack, but as I intend to make the config in the child the default in the very near future, this will hopefully be removed before I get hit by a truck. :)

> > -----Original Message-----
> > From: KARR, DAVID [mailto:dk068x@att.com]
> > Sent: Monday, February 20, 2017 10:33 AM
> > To: Maven Users List <us...@maven.apache.org>
> > Subject: [EXTERNAL] Strategies for overriding parent plugin
> > configuration in some modules without duplicating config code?
> >
> > External Sender: Use caution with links/attachments.
> >
> >
> >
> > Although my issue is about configuring the "jacoco-maven-plugin", I
> > think it's really more of a pure Maven configuration issue, as I don't
> > think this situation is unique to JaCoCo.
> >
> > I have a somewhat large multi-module project.  Each of the child
> > modules has a parent pom that configures the "jacoco-maven-plugin" to
> > do offline instrumentation (at present, all the modules having unit
> > tests using PowerMock, which doesn't work with online
> instrumentation).
> >
> > I've designed a change that I'll have to make in a few classes in each
> > module that will allow the unit tests to use Mockito, and for JaCoCo
> > to use online instrumentation.  I'll eventually fix all of them to
> > work this way, but it will take a little while.  In the meantime, I
> > just want to override the configuration in the "fixed" modules with
> > online instrumentation and let the other modules use the default of
> > offline instrumentation.
> >
> > The simple-minded way to do this is just to define the same
> > configuration using online instrumentation in each "fixed" module, so
> > it will override the parent pom.  Copying that block to every "fixed"
> > module is not a great idea.  I'd like a solution that requires less
> > code duplication.
> >
> > I suppose I could define ANOTHER parent pom, that specifies the
> > existing parent as its parent, and have that second parent use online
> > instrumentation, and have the fixed modules use that second parent
> > instead.  I will eventually delete this second parent pom once all of
> > the modules are "fixed".
> >
> > Note that I have a separate aggregator pom that is not a parent pom.
> >
> > Are there other reasonable strategies for this "use original parent
> > for some, override in same way for others" situation?
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> > ----------------------------------------------------------------------
> > This e-mail, including any attached files, may contain confidential
> > and privileged information for the sole use of the intended recipient.
> > Any review, use, distribution, or disclosure by others is strictly
> > prohibited.  If you are not the intended recipient (or authorized to
> > receive information for the intended recipient), please contact the
> > sender by reply e-mail and delete all copies of this message.
> >
> > ---------------------------------------------------------------------
> > 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


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


RE: Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Justin Georgeson [mailto:JGeorgeson@lgc.com]
> Sent: Monday, February 20, 2017 8:40 AM
> To: Maven Users List <us...@maven.apache.org>
> Subject: RE: Strategies for overriding parent plugin configuration in
> some modules without duplicating config code?
> 
> Have you looked at combine.children="append" or combine.self="override"
> attributes to the <configuration> element?
> 
> https://urldefense.proofpoint.com/v2/url?u=http-
> 3A__blog.sonatype.com_2011_01_maven-2Dhow-2Dto-2Dmerging-2Dplugin-
> 2Dconfiguration-2Din-2Dcomplex-2Dprojects_&d=DQIFAg&c=LFYZ-
> o9_HUMeMTSQicvjIg&r=OsTemSXEn-
> xy2uk0vYF_EA&m=FHuWQ_q8B5maEN_es6oJCbGAxMD8fxn8FxP0AQ9VZ3w&s=hQ-
> pliBIxKnBjdS66GjKAlZqdGHagiZTuPSvxK1SoFU&e=
> https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__maven.apache.org_pom.html&d=DQIFAg&c=LFYZ-
> o9_HUMeMTSQicvjIg&r=OsTemSXEn-
> xy2uk0vYF_EA&m=FHuWQ_q8B5maEN_es6oJCbGAxMD8fxn8FxP0AQ9VZ3w&s=GptXYbOIzWw
> xSTYZmwZufxSKr6WYerQ_ll_D1fVE-D4&e=

How do I override the "executions" list?  These properties aren't valid there.

> -----Original Message-----
> From: KARR, DAVID [mailto:dk068x@att.com]
> Sent: Monday, February 20, 2017 10:33 AM
> To: Maven Users List <us...@maven.apache.org>
> Subject: [EXTERNAL] Strategies for overriding parent plugin
> configuration in some modules without duplicating config code?
> 
> External Sender: Use caution with links/attachments.
> 
> 
> 
> Although my issue is about configuring the "jacoco-maven-plugin", I
> think it's really more of a pure Maven configuration issue, as I don't
> think this situation is unique to JaCoCo.
> 
> I have a somewhat large multi-module project.  Each of the child modules
> has a parent pom that configures the "jacoco-maven-plugin" to do offline
> instrumentation (at present, all the modules having unit tests using
> PowerMock, which doesn't work with online instrumentation).
> 
> I've designed a change that I'll have to make in a few classes in each
> module that will allow the unit tests to use Mockito, and for JaCoCo to
> use online instrumentation.  I'll eventually fix all of them to work
> this way, but it will take a little while.  In the meantime, I just want
> to override the configuration in the "fixed" modules with online
> instrumentation and let the other modules use the default of offline
> instrumentation.
> 
> The simple-minded way to do this is just to define the same
> configuration using online instrumentation in each "fixed" module, so it
> will override the parent pom.  Copying that block to every "fixed"
> module is not a great idea.  I'd like a solution that requires less code
> duplication.
> 
> I suppose I could define ANOTHER parent pom, that specifies the existing
> parent as its parent, and have that second parent use online
> instrumentation, and have the fixed modules use that second parent
> instead.  I will eventually delete this second parent pom once all of
> the modules are "fixed".
> 
> Note that I have a separate aggregator pom that is not a parent pom.
> 
> Are there other reasonable strategies for this "use original parent for
> some, override in same way for others" situation?
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> ----------------------------------------------------------------------
> This e-mail, including any attached files, may contain confidential and
> privileged information for the sole use of the intended recipient.  Any
> review, use, distribution, or disclosure by others is strictly
> prohibited.  If you are not the intended recipient (or authorized to
> receive information for the intended recipient), please contact the
> sender by reply e-mail and delete all copies of this message.
> 
> ---------------------------------------------------------------------
> 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: Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Justin Georgeson [mailto:JGeorgeson@lgc.com]
> Sent: Monday, February 20, 2017 8:40 AM
> To: Maven Users List <us...@maven.apache.org>
> Subject: RE: Strategies for overriding parent plugin configuration in
> some modules without duplicating config code?
> 
> Have you looked at combine.children="append" or combine.self="override"
> attributes to the <configuration> element?
> 
> https://urldefense.proofpoint.com/v2/url?u=http-
> 3A__blog.sonatype.com_2011_01_maven-2Dhow-2Dto-2Dmerging-2Dplugin-
> 2Dconfiguration-2Din-2Dcomplex-2Dprojects_&d=DQIFAg&c=LFYZ-
> o9_HUMeMTSQicvjIg&r=OsTemSXEn-
> xy2uk0vYF_EA&m=FHuWQ_q8B5maEN_es6oJCbGAxMD8fxn8FxP0AQ9VZ3w&s=hQ-
> pliBIxKnBjdS66GjKAlZqdGHagiZTuPSvxK1SoFU&e=
> https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__maven.apache.org_pom.html&d=DQIFAg&c=LFYZ-
> o9_HUMeMTSQicvjIg&r=OsTemSXEn-
> xy2uk0vYF_EA&m=FHuWQ_q8B5maEN_es6oJCbGAxMD8fxn8FxP0AQ9VZ3w&s=GptXYbOIzWw
> xSTYZmwZufxSKr6WYerQ_ll_D1fVE-D4&e=

Good to know that mechanism exists, but I don't think it applies to my situation.

Still looks like the alternate parent pom has the best balance of tradeoffs, for now.

> -----Original Message-----
> From: KARR, DAVID [mailto:dk068x@att.com]
> Sent: Monday, February 20, 2017 10:33 AM
> To: Maven Users List <us...@maven.apache.org>
> Subject: [EXTERNAL] Strategies for overriding parent plugin
> configuration in some modules without duplicating config code?
> 
> External Sender: Use caution with links/attachments.
> 
> 
> 
> Although my issue is about configuring the "jacoco-maven-plugin", I
> think it's really more of a pure Maven configuration issue, as I don't
> think this situation is unique to JaCoCo.
> 
> I have a somewhat large multi-module project.  Each of the child modules
> has a parent pom that configures the "jacoco-maven-plugin" to do offline
> instrumentation (at present, all the modules having unit tests using
> PowerMock, which doesn't work with online instrumentation).
> 
> I've designed a change that I'll have to make in a few classes in each
> module that will allow the unit tests to use Mockito, and for JaCoCo to
> use online instrumentation.  I'll eventually fix all of them to work
> this way, but it will take a little while.  In the meantime, I just want
> to override the configuration in the "fixed" modules with online
> instrumentation and let the other modules use the default of offline
> instrumentation.
> 
> The simple-minded way to do this is just to define the same
> configuration using online instrumentation in each "fixed" module, so it
> will override the parent pom.  Copying that block to every "fixed"
> module is not a great idea.  I'd like a solution that requires less code
> duplication.
> 
> I suppose I could define ANOTHER parent pom, that specifies the existing
> parent as its parent, and have that second parent use online
> instrumentation, and have the fixed modules use that second parent
> instead.  I will eventually delete this second parent pom once all of
> the modules are "fixed".
> 
> Note that I have a separate aggregator pom that is not a parent pom.
> 
> Are there other reasonable strategies for this "use original parent for
> some, override in same way for others" situation?
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> ----------------------------------------------------------------------
> This e-mail, including any attached files, may contain confidential and
> privileged information for the sole use of the intended recipient.  Any
> review, use, distribution, or disclosure by others is strictly
> prohibited.  If you are not the intended recipient (or authorized to
> receive information for the intended recipient), please contact the
> sender by reply e-mail and delete all copies of this message.
> 
> ---------------------------------------------------------------------
> 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: Strategies for overriding parent plugin configuration in some modules without duplicating config code?

Posted by Justin Georgeson <JG...@lgc.com>.
Have you looked at combine.children="append" or combine.self="override" attributes to the <configuration> element?

http://blog.sonatype.com/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/
https://maven.apache.org/pom.html


-----Original Message-----
From: KARR, DAVID [mailto:dk068x@att.com] 
Sent: Monday, February 20, 2017 10:33 AM
To: Maven Users List <us...@maven.apache.org>
Subject: [EXTERNAL] Strategies for overriding parent plugin configuration in some modules without duplicating config code?

External Sender: Use caution with links/attachments.



Although my issue is about configuring the "jacoco-maven-plugin", I think it's really more of a pure Maven configuration issue, as I don't think this situation is unique to JaCoCo.

I have a somewhat large multi-module project.  Each of the child modules has a parent pom that configures the "jacoco-maven-plugin" to do offline instrumentation (at present, all the modules having unit tests using PowerMock, which doesn't work with online instrumentation).

I've designed a change that I'll have to make in a few classes in each module that will allow the unit tests to use Mockito, and for JaCoCo to use online instrumentation.  I'll eventually fix all of them to work this way, but it will take a little while.  In the meantime, I just want to override the configuration in the "fixed" modules with online instrumentation and let the other modules use the default of offline instrumentation.

The simple-minded way to do this is just to define the same configuration using online instrumentation in each "fixed" module, so it will override the parent pom.  Copying that block to every "fixed" module is not a great idea.  I'd like a solution that requires less code duplication.

I suppose I could define ANOTHER parent pom, that specifies the existing parent as its parent, and have that second parent use online instrumentation, and have the fixed modules use that second parent instead.  I will eventually delete this second parent pom once all of the modules are "fixed".

Note that I have a separate aggregator pom that is not a parent pom.

Are there other reasonable strategies for this "use original parent for some, override in same way for others" situation?



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

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

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