1

I have a parent pom which defines a number of plugins and dependencies I want my child poms to inherit. However, we use the scm element as part of our release builds and I would like to add the parent's scm to the pom but it not be inherited by any children pom (in case the child forgets to define it and uses the parent's). Is there a way to set an element to be not inheritable?

Larry Shatzer
  • 3,579
  • 8
  • 29
  • 36
sdoca
  • 7,832
  • 23
  • 70
  • 127
  • see this post, maybe it will help you [exclude artifacts inherited from a parent POM?][1] [1]: http://stackoverflow.com/questions/2681759/is-there-anyway-to-exclude-artifacts-inherited-from-a-parent-pom – mike.tihonchik Mar 05 '13 at 19:48
  • I would use the enforcer plugin to make sure projects that use the parent pom have populated the correct elements, such as scm. – Larry Shatzer Mar 05 '13 at 19:49
  • @Larry, I don't suppose you have a link to an example for the enforcer plugin? The rules page for the plugin (http://maven.apache.org/enforcer/maven-enforcer-plugin/rules/index.html) is a dead link. – sdoca Mar 05 '13 at 20:23
  • http://maven.apache.org/enforcer/enforcer-rules/index.html is the link you want. – Larry Shatzer Mar 05 '13 at 20:55
  • Thanks, I'll have to do some more reading, but that sounds like a good solution. – sdoca Mar 05 '13 at 21:10

1 Answers1

0

I don't think so.

But could you make it use a property that ends up with different values in the parent pom and the dependent pom such that it will fail in the child if they don't have their own <scm> tag? Use <profile> to define the property differently in the parent and child.

Sometimes that works.

The reason it works on occasion is that profiles are not inherited by the child but if the profile in the parent sets a property, that property is inherited by the child.

So, sometimes you can use that "feature" to accomplish what you are doing. If you activate a profile in the parent and the <scm> section is in the profile, it won't be inherited by the child.

Another possible solution is for you to use the permissions on the version control system. The user credentials that allow checkin in the child projects could, in some cases, NOT be given permission to checkin in the parent. If the child project doesn't declare their own <scm> then they won't have permission to fool with the part of the repo in the parent's <scm> section.

Lee Meador
  • 12,829
  • 2
  • 36
  • 42
  • The builds are done by our CI system (Hudson) and therefore are executed by the same user. – sdoca Mar 05 '13 at 20:25
  • @LarryShatzer mentioned the enforcer plugin. It has a rule to require a property. If you put an `` tag in the parent that uses a property, maybe you can require all the children to define the property on their own. – Lee Meador Mar 05 '13 at 21:08