Re: Profile inheritance in 3.0.1: file activates, property doesn't
I think the best thing is to create a test project that re-produces this. Then create a jira and attach the test project. Explain the exact command you execute, the actual outcome and what you expected the outcome to be. Then it will be easy for someone to spot if it's a Maven issue or incorrect usage. /Anders On Thu, Dec 16, 2010 at 23:18, Laird Nelson ljnel...@gmail.com wrote: After reading about the pitfalls and spotty implementation of pseudo-inheritance of profiles, I can report that it appears that for a profile defined in a parent pom you can activate it from a child as long as the child doesn't try to activate it using a property value. So a profile defined in a parent pom that is defined to be active when a file exists and when a property is true will never be activated by a child, because the child--or the command line--can never fulfill the property condition. I find this to be counterintuitive and weird. Is this a bug, or by some kind of design that I'm not smart enough to comprehend? :-) Best, Laird
Re: Profile Inheritance
That is not correct, if I have a project structure like this: A |pom.xml --- B | pom.xml And I define the profile profile1 in A/pom.xml when running : B myuser$ mvn help:active-profiles -Pprofile1 [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'help'. [INFO] [INFO] Building Project B [INFO]task-segment: [help:active-profiles] (aggregator-style) [INFO] [INFO] [help:active-profiles] [INFO] Active Profiles for Project 'com.mycompany:b:jar:0.9.0-SNAPSHOT': The following profiles are active: - profile1 (source: pom) For more info [1] and [2] can also help. HTH, Gab [1] http://maven.apache.org/guides/introduction/introduction-to-profiles.html [2] http://mindthegab.com/2008/12/02/howto-give-your-multimodule-maven-build-subprojectenvironment-specific-behavior/ 2009/3/11 Roman Kournjaev kournj...@gmail.com Hi All I have done a little search on the net , and understood from it that a profile defined in the parent pom cant be explicitly invoked from when running the child pom. It just sound so unbelivable to me! So I just wanted to hear it from you guys too. Thanks in Advance. Roman -- Gabriele Columbro Alfresco ECM Product Strategy Consultant +31 627 565 103 Sourcesense - Making sense of open Source (http://www.sourcesense.com)
Re: Profile Inheritance
But try it with a profiles.xml file; for example, if I create a project with the app-fuse archetype: mvn \ archetype:create \ -DarchetypeGroupId=org.appfuse.archetypes \ -DarchetypeArtifactId=appfuse-modular-spring \ -DremoteRepositories=http://static.appfuse.org/releases \ -DgroupId=com.mycompany.app \ -DartifactId=myproject Then go into myproject and create the following profiles.xml file: ?xml version=1.0? profilesXml xmlns=http://maven.apache.org/xsd/profiles-1.0.0; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://maven.apache.org/xsd/profiles-1.0.0.xsd; profiles profile idprofile1/id activation activeByDefaultfalse/activeByDefault /activation /profile /profiles /profilesXml Then notice that profile1 is only active for the parent; not the children. $ mvn help:active-profiles -Pprofile1 [INFO] Scanning for projects... [INFO] Reactor build order: [INFO] AppFuse Modular Application [INFO] AppFuse Modular Application - Core [INFO] AppFuse Modular Application - Web (Spring MVC) [INFO] Searching repository for plugin with prefix: 'help'. [INFO] [INFO] Building AppFuse Modular Application [INFO]task-segment: [help:active-profiles] (aggregator-style) [INFO] [INFO] [help:active-profiles] [INFO] Active Profiles for Project 'com.mycompany.app:myproject:pom:1.0-SNAPSHOT': The following profiles are active: - profile1 (source: profiles.xml) Active Profiles for Project 'com.mycompany.app:myproject-core:jar:1.0-SNAPSHOT': There are no active profiles. Active Profiles for Project 'com.mycompany.app:myproject-webapp:war:1.0-SNAPSHOT': The following profiles are active: - integration-test (source: pom) [INFO] [INFO] BUILD SUCCESSFUL [INFO] [INFO] Total time: 4 seconds [INFO] Finished at: Wed Mar 11 10:04:27 PST 2009 [INFO] Final Memory: 5M/11M [INFO] Likewise, if you go into a child module: $ cd web $ mvn help:active-profiles -Pprofile1 [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'help'. [INFO] [INFO] Building AppFuse Modular Application - Web (Spring MVC) [INFO]task-segment: [help:active-profiles] (aggregator-style) [INFO] [INFO] [help:active-profiles] [INFO] Active Profiles for Project 'com.mycompany.app:myproject-webapp:war:1.0-SNAPSHOT': The following profiles are active: - integration-test (source: pom) [INFO] [INFO] BUILD SUCCESSFUL [INFO] [INFO] Total time: 4 seconds [INFO] Finished at: Wed Mar 11 10:05:29 PST 2009 [INFO] Final Memory: 5M/11M [INFO] Gabriele Columbro wrote: That is not correct, if I have a project structure like this: A |pom.xml --- B | pom.xml And I define the profile profile1 in A/pom.xml when running : B myuser$ mvn help:active-profiles -Pprofile1 [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'help'. [INFO] [INFO] Building Project B [INFO]task-segment: [help:active-profiles] (aggregator-style) [INFO] [INFO] [help:active-profiles] [INFO] Active Profiles for Project 'com.mycompany:b:jar:0.9.0-SNAPSHOT': The following profiles are active: - profile1 (source: pom) For more info [1] and [2] can also help. HTH, Gab [1] http://maven.apache.org/guides/introduction/introduction-to-profiles.html [2] http://mindthegab.com/2008/12/02/howto-give-your-multimodule-maven-build-subprojectenvironment-specific-behavior/ 2009/3/11 Roman Kournjaev kournj...@gmail.com Hi All I have done a little search on the net , and understood from it that a profile defined in the parent pom cant be explicitly invoked from when running the child pom. It just sound so unbelivable to me! So I just wanted to hear it from you guys too. Thanks in Advance. Roman - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: profile inheritance and activation
hallo glad to help :) i have no mixture of the profiles neeeded for the builds within settings.xml (so everyone who gets the pom can built it). you dont have a profiles.xml too? i have put everything in pom.xml profiles: profiles profile idlocal/id properties envDEV/env /properties activation activeByDefaulttrue/activeByDefault /activation build filters /filters /build /profile profile idtest/id properties envTEST/env /properties build filters /filters /build /profile ... i have never encountered profiles beeing active where they where not supposed to, give 'mvn help:effective-settings' and 'mvn help:effective-pom' and 'mvn help:active-profiles' a try. it may tell you what maven does. i do not have the war-plugin within the profile section. i've put it within the normal built section: profiles /profiles build plugins plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-war-plugin/artifactId executions execution goals goalwar/goal /goals configuration ... /plugins /plugins /build apart from that i do not see any differences :/ regards ossi Philippe Le Marchand schrieb: Hi ossi, thank you very much for your reaction, I just figured it out searching in Nabble's archives, so I prepared myself to ask for help on what I needed instead of how to inherit profiles to accomplish it :-) So the idea is to: - access the filter properties file corresponding to the target environment - override waven war plugin behaviour for local deployment only (that is setting another webapp directory than the Maven's default target/artifactId) - activate the local profile by default if none is provided through the CLI (with -P profileId). I've got several filter properties files under parent/src/main/filters: - filter-local.properties - filter-dev.properties and I would like the path to the deploy folder of my AS (JBoss) user dependent. Here are more relevant extracts: *** parent POM *** build filters filter${parent.relativePath}/src/main/filters/filter-${env}.properties/filter /filters /build profiles profile idlocal/id properties envlocal/env /properties build pluginManagement plugins plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-war-plugin/artifactId configuration webappDirectory${appserver.deploy}/${build.finalName}.war/webappDirectory /configuration /plugin /plugins /pluginManagement /build /profile profile iddev/id properties envdev/env /properties /profile /profiles *** moduleN POM *** build resources resource filteringtrue/filtering directorysrc/main/resources/directory /resource /resources /build *** user's settings.xml *** profiles profile idlocal/id activation activeByDefaulttrue/activeByDefault /activation properties appserver.deploy/path/to/deploy/folder/appserver.deploy /properties /profile /profiles When launching the CLI 'mvn install' in a module or the parent, everything works fine, but with 'mvn install -P dev' it seems that the 'local' profile (activeByDefault) is not deactivated. The 'env' property is ok, as the right filter properties file is chosen, but it still assemble the webapp under 'appserver.deploy', which is not asked (see pluginManagement under 'local' profile) and the property itself shouldn't be set (see user's settings.xml). I've found the following interesting issue in Jira: http://jira.codehaus.org/browse/MNG-2136 But I still don't understand why the 'local' profile is not deactivated. If not possible, should there be another way to meet my needs? Thanks, Philippe On 9/6/07, ossi petz [EMAIL PROTECTED] wrote: hallo the profiles are not inherited to child modules, but the effects are. so the child will not show the profile as active but it will work nontheless. see: http://www.nabble.com/Profile-inheritance-tf2953156s177.html#a8259757 for a better explanation regards ossi Philippe Le Marchand schrieb: Hi
Re: profile inheritance and activation
hallo the profiles are not inherited to child modules, but the effects are. so the child will not show the profile as active but it will work nontheless. see: http://www.nabble.com/Profile-inheritance-tf2953156s177.html#a8259757 for a better explanation regards ossi Philippe Le Marchand schrieb: Hi all, This is my first post, necessary as I can't find an answer in the archives ;-) I'm trying to define profiles, mainly for filtering purpose, on different modules of my project: local, test and prod, for instance. I configured my project and modules with inheritance and aggregation, which is working fine except that profiles defined in the parent's POM doesn't seem to be inherited by its modules. Here is an extract from the parent's POM: groupIdparent-groupId/groupId artifactIdparent-artifactId/artifactId packagingpom/packaging version1.0-SNAPSHOT/version modules module../module1/module module../module2/module /modules profiles profile idlocal/id properties envlocal/env /properties /profile profile iddev/id properties envdev/env /properties /profile /profiles Here is an extract from the module1's POM: parent groupIdparent-groupId/groupId artifactIdparent-artifactId/artifactId version1.0-SNAPSHOT/version relativePath../parent/relativePath /parent groupIdmodule1-groupId/groupId artifactIdmodule1-artifactId/artifactId packagingjar/packaging version1.0-SNAPSHOT/version The module2's POM is the same with 'module2' as ids and 'war' as packaging. When launching the following CLI in the parent's base dir : mvn help:active-profiles -P local I see : Active Profiles for Project 'parent-groupId:parent-artifactId:pom:1.0-SNAPSHOT': The following profiles are active: - local (source: pom) - alwaysActiveProfile (source: settings.xml) Active Profiles for Project 'module1-groupId:module1-artifactId:jar:1.0-SNAPSHOT': The following profiles are active: - alwaysActiveProfile (source: settings.xml) Active Profiles for Project 'module2-groupId:module2-artifactId:war:1.0-SNAPSHOT': The following profiles are active: - alwaysActiveProfile (source: settings.xml) Same result with '-P dev' in the CLI, and same problem running the CLI in a module's base dir. How can I have 'local' or 'dev' profile active in the modules? Thanks for your help, Philippe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: profile inheritance and activation
Hi ossi, thank you very much for your reaction, I just figured it out searching in Nabble's archives, so I prepared myself to ask for help on what I needed instead of how to inherit profiles to accomplish it :-) So the idea is to: - access the filter properties file corresponding to the target environment - override waven war plugin behaviour for local deployment only (that is setting another webapp directory than the Maven's default target/artifactId) - activate the local profile by default if none is provided through the CLI (with -P profileId). I've got several filter properties files under parent/src/main/filters: - filter-local.properties - filter-dev.properties and I would like the path to the deploy folder of my AS (JBoss) user dependent. Here are more relevant extracts: *** parent POM *** build filters filter${parent.relativePath}/src/main/filters/filter-${env}.properties/filter /filters /build profiles profile idlocal/id properties envlocal/env /properties build pluginManagement plugins plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-war-plugin/artifactId configuration webappDirectory${appserver.deploy}/${build.finalName}.war/webappDirectory /configuration /plugin /plugins /pluginManagement /build /profile profile iddev/id properties envdev/env /properties /profile /profiles *** moduleN POM *** build resources resource filteringtrue/filtering directorysrc/main/resources/directory /resource /resources /build *** user's settings.xml *** profiles profile idlocal/id activation activeByDefaulttrue/activeByDefault /activation properties appserver.deploy/path/to/deploy/folder/appserver.deploy /properties /profile /profiles When launching the CLI 'mvn install' in a module or the parent, everything works fine, but with 'mvn install -P dev' it seems that the 'local' profile (activeByDefault) is not deactivated. The 'env' property is ok, as the right filter properties file is chosen, but it still assemble the webapp under 'appserver.deploy', which is not asked (see pluginManagement under 'local' profile) and the property itself shouldn't be set (see user's settings.xml). I've found the following interesting issue in Jira: http://jira.codehaus.org/browse/MNG-2136 But I still don't understand why the 'local' profile is not deactivated. If not possible, should there be another way to meet my needs? Thanks, Philippe On 9/6/07, ossi petz [EMAIL PROTECTED] wrote: hallo the profiles are not inherited to child modules, but the effects are. so the child will not show the profile as active but it will work nontheless. see: http://www.nabble.com/Profile-inheritance-tf2953156s177.html#a8259757 for a better explanation regards ossi Philippe Le Marchand schrieb: Hi all, This is my first post, necessary as I can't find an answer in the archives ;-) I'm trying to define profiles, mainly for filtering purpose, on different modules of my project: local, test and prod, for instance. I configured my project and modules with inheritance and aggregation, which is working fine except that profiles defined in the parent's POM doesn't seem to be inherited by its modules. Here is an extract from the parent's POM: groupIdparent-groupId/groupId artifactIdparent-artifactId/artifactId packagingpom/packaging version1.0-SNAPSHOT/version modules module../module1/module module../module2/module /modules profiles profile idlocal/id properties envlocal/env /properties /profile profile iddev/id properties envdev/env /properties /profile /profiles Here is an extract from the module1's POM: parent groupIdparent-groupId/groupId artifactIdparent-artifactId/artifactId version1.0-SNAPSHOT/version relativePath../parent/relativePath /parent groupIdmodule1-groupId/groupId artifactIdmodule1-artifactId/artifactId packagingjar/packaging version1.0-SNAPSHOT/version The module2's POM is the same with 'module2' as ids and 'war' as packaging. When launching the following CLI in the parent's base dir : mvn help:active-profiles -P local I see : Active Profiles for Project 'parent-groupId:parent-artifactId:pom:1.0-SNAPSHOT': The following profiles are active: - local (source: pom) - alwaysActiveProfile (source: settings.xml) Active Profiles for Project 'module1-groupId:module1-artifactId:jar:1.0-SNAPSHOT': The following profiles are active: - alwaysActiveProfile (source: settings.xml) Active Profiles for Project
Re: Profile inheritance
Profiles are not inherited, period. Now, having said that, profiles in parent POMs can be triggered by the building of a child. When activated, they are applied directly to the parent POM, prior to that parent being used for inheritance into the child. So, the effects of an active profile in a parent POM will be felt by the child. Also, since a parent's profile is applied to it before inheritance calculations take place, inheriting the profile itself (and presumably, re-applying it at the child level) would lead to double-application of that profile. It's a little bit of a confusing topic, so I'm sorry if that explanation is a bit jumbled. I hope if makes sense now. -john On 1/10/07, David Jackman [EMAIL PROTECTED] wrote: I've searched the mail archives, and this question seems to be asked a lot and answered never. Are profiles inherited from parent poms? The scant (and confusing) docs seem to imply that they are, but doing a help:active-profiles command does not agree with this. Please someone explain how this is supposed to work. ..David.. FASTforward '07 The Industry's Largest Business Technology Conference Focused on Search February 7th - 9th, San Diego, CA www.fastforward07.com
Re: Profile inheritance
David Jackman [EMAIL PROTECTED] writes: Are profiles inherited from parent poms? The scant (and confusing) docs seem to imply that they are, but doing a help:active-profiles command does not agree with this. Please someone explain how this is supposed to work. Hello, As a follow-up to John Casey's post, I can tell that according to my own experiences: - profiles are not inherited per se (see JC's post) but their effects are - if you have profiles with the same id in several poms (and settings.xml), they are all activated in their own poms when invoking the build. Sort of method overloading ... HTH, -- OQube software engineering \ génie logiciel Arnaud Bailly, Dr. \web http://www.oqube.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Profile Inheritance
On 8/14/06, Douglas Ferguson [EMAIL PROTECTED] wrote: Are profiles inherited from the parent pom? They are supposed to be, although there have been a few issues here and there. The one that bit us (Shale project) was MNG-2221[1], which looks like it's been fixed for 2.0.5 when that is released. Craig [1] http://jira.codehaus.org/browse/MNG-2221 __ Douglas W. Ferguson EPSIIA - Another Fiserv Connection Development Office Phone: 512-329-0081 ext. 3309 Dial Toll Free: 800-415-5946 Mobile Phone: 512-293-7279 Fax: 512-329-0086 [EMAIL PROTECTED] www.epsiia.com http://www.epsiia.com/ __
Re: Profile Inheritance
Actually, profiles themselves are NOT inherited as such. Instead, they are triggered when the parent POM delcaring them is loaded, and applied to that parent POM. Then, the effects of the profile are inherited via normal parent inheritance calculation. It's a small difference in most cases, but it can be important to understand. -john On 8/14/06, Craig McClanahan [EMAIL PROTECTED] wrote: On 8/14/06, Douglas Ferguson [EMAIL PROTECTED] wrote: Are profiles inherited from the parent pom? They are supposed to be, although there have been a few issues here and there. The one that bit us (Shale project) was MNG-2221[1], which looks like it's been fixed for 2.0.5 when that is released. Craig [1] http://jira.codehaus.org/browse/MNG-2221 __ Douglas W. Ferguson EPSIIA - Another Fiserv Connection Development Office Phone: 512-329-0081 ext. 3309 Dial Toll Free: 800-415-5946 Mobile Phone: 512-293-7279 Fax: 512-329-0086 [EMAIL PROTECTED] www.epsiia.com http://www.epsiia.com/ __
RE: Profile Inheritance
I think this may explain what I was seeing.. I have a parent pom.xml which defines 2 profiles. When I run mvn help:active-profiles for the child, I couldn't get it to say that either profile was active. So perhaps the profile is active in the parent but not in the child? -Original Message- From: John Casey [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 3:20 PM To: Maven Users List Subject: Re: Profile Inheritance Actually, profiles themselves are NOT inherited as such. Instead, they are triggered when the parent POM delcaring them is loaded, and applied to that parent POM. Then, the effects of the profile are inherited via normal parent inheritance calculation. It's a small difference in most cases, but it can be important to understand. -john On 8/14/06, Craig McClanahan [EMAIL PROTECTED] wrote: On 8/14/06, Douglas Ferguson [EMAIL PROTECTED] wrote: Are profiles inherited from the parent pom? They are supposed to be, although there have been a few issues here and there. The one that bit us (Shale project) was MNG-2221[1], which looks like it's been fixed for 2.0.5 when that is released. Craig [1] http://jira.codehaus.org/browse/MNG-2221 __ Douglas W. Ferguson EPSIIA - Another Fiserv Connection Development Office Phone: 512-329-0081 ext. 3309 Dial Toll Free: 800-415-5946 Mobile Phone: 512-293-7279 Fax: 512-329-0086 [EMAIL PROTECTED] www.epsiia.com http://www.epsiia.com/ __ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Profile Inheritance
right. if you ran from the parent, and the parent specified these child POMs as modules (or sub-modules), then you'd get a listing of all POMs in the build, and the profiles which are active for each. On 8/14/06, Douglas Ferguson [EMAIL PROTECTED] wrote: I think this may explain what I was seeing.. I have a parent pom.xml which defines 2 profiles. When I run mvn help:active-profiles for the child, I couldn't get it to say that either profile was active. So perhaps the profile is active in the parent but not in the child? -Original Message- From: John Casey [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 3:20 PM To: Maven Users List Subject: Re: Profile Inheritance Actually, profiles themselves are NOT inherited as such. Instead, they are triggered when the parent POM delcaring them is loaded, and applied to that parent POM. Then, the effects of the profile are inherited via normal parent inheritance calculation. It's a small difference in most cases, but it can be important to understand. -john On 8/14/06, Craig McClanahan [EMAIL PROTECTED] wrote: On 8/14/06, Douglas Ferguson [EMAIL PROTECTED] wrote: Are profiles inherited from the parent pom? They are supposed to be, although there have been a few issues here and there. The one that bit us (Shale project) was MNG-2221[1], which looks like it's been fixed for 2.0.5 when that is released. Craig [1] http://jira.codehaus.org/browse/MNG-2221 __ Douglas W. Ferguson EPSIIA - Another Fiserv Connection Development Office Phone: 512-329-0081 ext. 3309 Dial Toll Free: 800-415-5946 Mobile Phone: 512-293-7279 Fax: 512-329-0086 [EMAIL PROTECTED] www.epsiia.com http://www.epsiia.com/ __ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Profile Inheritance
I'm only running this build from each child. I'm using the parent for inheritance. The parent doesn't even define the children as there are 100s. If I have: 2 poms: pom a pom b Pom b declare pom a as it's parent. Pom a has 2 profiles decared in it. I run mvn -Pprofile1 from pom b's directory will profile1 activate for the loading of pom a? When I run mvn -Pprofile1 help:active-profiles it doesn't show. D- -Original Message- From: John Casey [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 4:25 PM To: Maven Users List Subject: Re: Profile Inheritance right. if you ran from the parent, and the parent specified these child POMs as modules (or sub-modules), then you'd get a listing of all POMs in the build, and the profiles which are active for each. On 8/14/06, Douglas Ferguson [EMAIL PROTECTED] wrote: I think this may explain what I was seeing.. I have a parent pom.xml which defines 2 profiles. When I run mvn help:active-profiles for the child, I couldn't get it to say that either profile was active. So perhaps the profile is active in the parent but not in the child? -Original Message- From: John Casey [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 3:20 PM To: Maven Users List Subject: Re: Profile Inheritance Actually, profiles themselves are NOT inherited as such. Instead, they are triggered when the parent POM delcaring them is loaded, and applied to that parent POM. Then, the effects of the profile are inherited via normal parent inheritance calculation. It's a small difference in most cases, but it can be important to understand. -john On 8/14/06, Craig McClanahan [EMAIL PROTECTED] wrote: On 8/14/06, Douglas Ferguson [EMAIL PROTECTED] wrote: Are profiles inherited from the parent pom? They are supposed to be, although there have been a few issues here and there. The one that bit us (Shale project) was MNG-2221[1], which looks like it's been fixed for 2.0.5 when that is released. Craig [1] http://jira.codehaus.org/browse/MNG-2221 __ Douglas W. Ferguson EPSIIA - Another Fiserv Connection Development Office Phone: 512-329-0081 ext. 3309 Dial Toll Free: 800-415-5946 Mobile Phone: 512-293-7279 Fax: 512-329-0086 [EMAIL PROTECTED] www.epsiia.com http://www.epsiia.com/ __ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]