Is it possible to see the actual pom.xml executed, including parent dependencies/plugins? - maven

I need to extract a project from a repository which uses several layers of parent projects. Every parent project adds some dependency or plugins or properties. This is becoming a nightmare as I'm not able to build any more the project, once I've manually added pieces from parent projects.
Is there a way to create a list of all dependencies/plugins/properties which are linked by a single pom.xml so that I can build a portable, single Maven project?
Thanks

You can create the effective pom (https://maven.apache.org/plugins/maven-help-plugin/effective-pom-mojo.html) that is a kind of merge with all parent POMs.
This is useful to understand the complete list and configuration of plugins.
Whether this helps you to build a "portable" Maven project, I don't know. Without the appropriate Maven repositories with all the plugins, dependencies and so on, Maven will not build.

Base concept of Maven is CoC (Convention over Configuration). Maven has a SuperPOM and all model is inherited from that. SuperPOM is located in maven-model-builder jar. Here is the source https://maven.apache.org/ref/3.6.2/maven-model-builder/super-pom.html
Each Maven goal is using a merged model called effective pom. The help plugin has effective-pom goal which displays the full model including parent model(s) and SuperPOM.
So the answer is just run: mvn help:effective-pom command to see actual model.

Related

maven archetype resource additional filtering

I have built a Maven Archetype that generates other Maven project. So far, so good :)
Now, the generated project inherits from a specific parent POM. Upon release, all versions bump up, except the one under src/main/resources/archetype-resources/pom.xml.
I tried to use ${project.version} -- not expanded.
Then I tried ${archetypeVersion} -- not expanded.
Any suggestion?

Is it possible to define an "abstract" build in parent pom?

I want to define a build in the parent pom to enforce that build to the children.
Ideally a child pom just does mvn install and applies the build defined at the parent level.
I have 2 problems:
The build makes use of properties that are defined only in children
When I do mvn install on the parent I just want to create the pom and save it on my maven repo, not actually do a build (that should be done in children)
Is it possible to store helper files inside of the parent pom to use them in the child?
Is this possible?
You can define pretty much in the parent POM.
You can define all the plugins in the pluginManagement. You can use the <plugins> section of the parent POM to activate the plugins without using them in the build of the POM itself (with <phase>none</phase> and <inherited>false</inherited> on the execution)
You can build the parent POM and put it in a repository.
You can predefine properties and let child POMs override them.
But you cannot add additional files.
4all who stumbled upon this question only now (like me):
in addition to the possibilities described in the previous answer, you could define profiles in parent project, but activate them only in concrete project, e.g. by overriding profile activation property. This way you can avoid execution of the stuff during the build of the parent.
you could even go further and workaround limitation of additional files (beware, this is evil*):
define helper module(s) in the repository of your parent project
add dependency to the helper module in the profile defined in parent project
unpack helper files using the maven-resources-plugin (copy-resources)
*) why this is evil? - well, if you need a hack like this, it is an indicator that something is wrong with your architecture. Otherwise, if this would be a common requirement, the Maven team would provide a proper way to handle it.

Gradle: project depending on a Maven "child" (sub) project with dependencyManagement at parent

My (new) Gradle project depends on a Maven project that is a child of a parent Maven project with many subprojects. Notice that I only care about one little subproject there, nothing else from that parent.
Trouble is, Gradle walks up the Maven project tree and when it sees the "dependencyManagement" in parent pom instead of treating it for what it is - list of "approved versions" of dependencies for any and all subprojects of that parent, it actually assumes that they are ALL actual dependencies of the child/subproject I care about... And that brings waaaay too much stuff into my Gradle project.
I am presently working around by explicitly excluding all those dependencies I presently know are not presently (again) not needed, but I don't want to do that as that would mean that I have to keep up my project essentially in sync with ALL projects from that parent.
This is with Gradle 1.6. I MAY have some (little) level of influence on how those Maven projects are structured but preferably such a thing would not be needed and I could somehow tell Gradle to behave as it should... Is there a way?
Please help!
EDIT 1
The dependency is via a maven repository. The dependency I have is a subproject of a project built and deployed by Maven, to a Maven repository.
I also asked this on Gradle forums: http://forums.gradle.org/gradle/topics/8mftwmyn8uu75?rfm=1
Turns out this was not a problem at all. Huge POM of that parent project was hiding some actual dependencies that exploded...

Tycho: Parent POM needs to list plug-ins included in my feature?

I am transitioning from using Buckminster to build an Eclipse product to Tycho. I've mavenized my plug-ins and features and have a question:
I created a parent feature with a POM that references my features and plugins. I don't know if I am doing this correctly, but I find that I need to add all features and plugins as modules. So if I have pluginA, pluginB and feature1 that includes pluginA and pluginB, I add all three to parent POM. This is a bit strange to me, because in Buckminster I had to reference only feature1 and it would get its dependencies based on the feature.xml file.
I am doing something wrong in my Tycho builds, or is this how it's suppose to work?
A Tycho build is driven by Maven, i.e. Maven first determines which modules should be part of the build reactor, and then Tycho builds the modules. Therefore, you'll need an aggregator POM that tells Maven about the list of artifacts to be built.

Maven Grouping Dependencies without installing pom

I have a maven project which has multiple profiles and lots of dependencies which are specific to each of those profiles. The current solution to clean this up works by creating an intermediate dependency pom for each profile which groups the dependencies together as described here in 3.6.1: http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-pom-best-practice.html Each of these dependency grouping poms lives in their own svn project and is build and deployed as a separate jenkins job.
The problem is that these poms, and the dependencies within them change and are released often and it has become difficult to maintain. Ideally, I would like all of the dependency management to live under one svn project and one build.
Any suggestions would be appreciated.
As khmarbaise writes, it would help with more information and an example.
However, just answering your actual question, how to get all your depenency grouping poms as one project and one build. It sound as if a multi module project with each module being one of your "dependency grouping pom" projects would be what you are looking for.
The Maven Release Plugin did what we needed.

Resources