I wonder if it is possible to ignore parent tag in the pom.xml file. I need this because I have the following situation:
the structure is:
super root pom
root pom
module1 pom
module2 pom
module2.1 pom
module2.2 pom
module2.3 pom
I need to set super root pom as parent pom for root pom to make it availible to build it specifically on build server, but the trick is, that I don't have super root pom locally and need to ignore parent tag or do something not to be dependent on super parent pom. So, for example, I need to run root pom clean install independently from the super root pom. Is there any way to do this using some parameters or some pom.xml tricks?
Thanks everyone in advance!
If you have a corporate repo (Nexus, Artifactory...) The simpler would be to mvn deploy your parent, to make it available for all your projects, all your team, with no need of a local (relative file system path) relationship.
Related
My parent pom modules list looks something like this:
<modules>
<module>jarProject1</module>
<module>jarProject2</module>
<module>jarProject2</module>
<module>warProject1</module>
<module>warProject2</module>
</modules>
I would like warProject1 and warProject2 to be ignored when I run mvn clean install on the parent pom. I want install to only build jars and put them in the maven repo but not the war producing projects. Currently I do it using profiles but I have some problems related to that. I would like the parent pom to keep a comprehensive list of modules in its default modules tag and not under profiles. Is there a way to do it and how?
I have a multi-module POM file:
...
<modules>
<module>../project1</module>
<module>../project2</module>
<module>../project3</module>
...
</modules>
...
Each of the modules is itself a Maven project with its own POM. Inside each of these POMs I have the scm tag defined with the developerConnection specified like this:
<scm>
<developerConnection>scm:svn:svn://hostname:port/path/to/trunk</developerConnection>
</scm>
My goal is to run the following Maven goals/options:
versions:update-parent versions:commit scm:checkin \
-Dmessage="automated commit" -Dusername=user -Dpassword=pass
My expected results are:
The parent of each module's POM is updated to the latest released version.
The changes to each POM would be checked in to the SVN path specified in the POM for the module. E.g. project1 POM checked in using project1 <scm>/<developerConnection> path, project2 checked in using project2 path, etc.
Actual Results:
The parent of each module's POM is updated to latest released version. This works as expected.
Only the multi-module POM is checked in to SVN, none of the module POMs are checked in. This is the problem.
Is there a way to achieve the expected results above or is this something that the SCM plugin simply was not designed to do? If it is possible, how would I modify what I have in order to get the results I want?
Note: I can't change the project structure - I can't put the modules inside of the parent project, they have to remain separate.
Not sure if it's relevant but I'm using Maven 3.3.9.
In a maven project which pom.xml is the parent pom? And is that the one I need to change in order to add a profile?
I have a simple project and am trying to add a profile to download from a specific repository but nothing's seems to be working.
I assume you have a multi-module build.
Parent relationship is optional between poms, and specified with the <parent> tag inside the pom.
You may point to a single pom, but if not, you point to a default super-pom.
Use mvn help:effective-pom to shed some light on your settings.
If you have a shared pom file, you can add profiles to that one, otherwise you need to include them in each pom.
Use mvn help:active-profiles to see which ones are enabled.
For ref: http://maven.apache.org/guides/introduction/introduction-to-profiles.html
I have a parent pom and children pon and when I run the mvn clean package on the parent pom I am getting .jar file, is there anyway to change this to tar.gz file? For the children files I have created assembly.xml files to specify tar.gz file do I need to do the same for parent pom?
Specify POM packaging:
<packaging>pom</packaging>
I'm a little surprised that your parent POM is working without that setting. I've received errors from Maven before when I create a new parent POM and forget to change the packaging from jar (default) to POM.
The parent is not really meant to produce artifacts other tan the pom.
You could try attaching the assembly plugin to a phase such as process-resources or something and try to have it package whatever resources you have in mind, but... generally, it's not a good idea to keep resources in your parent.
If the projects that extend this parent do not define <packaging/>, their packaging will default to pom.
Per Maven documentation Maven will only look in local and remote repos for a parent pom after it fails to find it locally. The best solution I've found to dummy this out is by adding
<relativePath>.</relativePath>
which is obviously a kludge and produces warnings (as it well should). Maven seems to be like file-system coupling when dealing with parent modules and multi-module projects so this is the only way I see to have both of those co-exist without something that feels obviously wrong (e.g. inheriting from a filesystem child).
You reference the parent pom using the tag:
<parent>
<groupId>com.mycompany</groupId>
<artifactId>my-parentpom</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
You must install the parent pom into your local repo using the mvn install -N command from the directory that contains the parent POM.