I have a project Structure like below
P1 |trunk
|branches
|tags
P2 |trunk
|branches
|tags
P3 |trunk
|branches
|tags
p1 is an individual jar project. P2 is also a jar project but dependant on p1 and p3 requires both p1 and p2. P3 is basically a war file that has both p1 and p2 in it.
Till now i was trying to use a parent pom with these projects added as child modules and trying to perform a version upgrade, tag and release.Each of these projects inherit the parent pom However i see that the tagging is failing for individual projects.
So my question is
is it possible for me to use release plugin to upgrade the version and perform a tag update to individual projects like this?.
If not possible what is the best way to perform an automated release for an individual project structure like this?.
These are legacy code and the branches folder has a lot of branches checked in there. can't easily re factor it to plain parent - child model in maven.
Thanks in Advance
This should be possible. Could you show the relevant parts of your pom.xml and describe why the tagging is failing? And by the way, this is Subversion, right?
I would try with a POM structure like this. Parent:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>...</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>../child1/</module>
<module>../child2/</module>
</modules>
</project>
Child:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>...</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<groupId>...</groupId>
<artifactId>child-1</artifactId>
<version>1.1</version>
...
</project>
Related
Suppose there are two 3rd-party Maven artifacts with the following POM.XMLs:
artifact1 POM.XML:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group1</groupId>
<artifactId>artifact1</artifactId>
<version>${artifact1.version}</version>
<packaging>pom</packaging>
<properties>
<artifact1.version>0.0.1-SNAPSHOT</artifact1.version>
</properties>
<modules>
<module>../artifact2</module>
</modules>
artifact2 POM.XML:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>artifact2</artifactId>
<parent>
<groupId>group1</groupId>
<artifactId>artifact1</artifactId>
<version>${artifact1.version}</version>
<relativePath>../artifact1</relativePath>
</parent>
They are built normally using
mvn clean install
Now, if I try to reuse artifact2 in a 3rd POM.XML:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group2</groupId>
<artifactId>artifact3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>group1</groupId>
<artifactId>artifact2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
After executing...
mvn clean install
...the build fails trying to locate group1:artifact1:pom:${artifact1.version}
[ERROR] Failed to execute goal on project artifact3: Could not resolve dependencies for project group2:artifact3:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at group1:artifact2:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for group1:artifact2:jar:0.0.1-SNAPSHOT: Could not find artifact group1:artifact1:pom:${artifact1.version} in central (https://repo.maven.apache.org/maven2) -> [Help 1]
And setting the property in the command-line doesn't work either:
mvn clean install -Dartifact1.version=0.0.1-SNAPSHOT
How can I use artifact2 as a dependency?
<parent> doesn't allow variables. Because in order to get a list of variables Maven first has to build Effective POM and for this it needs to resolve parents.
Even if there is some version of Maven that allowed such module to be installed it's not a working solution in general. Maven's ideology is that all the dependencies (including parent) could be downloaded from a repo and are not necessarily present on local FS/in the reactor. With properties in the parent dependency definition you violate this rule.
Seems like you can only inherit plugin configurations. Can I inherit the full tag?
I want all my projects to use the same build chain. I was hoping to create a single parent pom w/ such a build chain. Sounds like a rather logical (and necessary) request, doesn't it?
You can a pom file for a particular project like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.soebes.smpp</groupId>
<artifactId>smpp</artifactId>
<version>2.3.0</version>
</parent>
<groupId>com.soebes.examples.j2ee</groupId>
<artifactId>parent</artifactId>
<version>3.4.6-SNAPSHOT</version>
<packaging>jar</packaging>
You can put the needed plugin configuration into the given parent. Like this example.
Apart from that you don't need to define the plugins in the build section only via pluginManagement where you define the configuration and the version of the appropriate plugins. Which can be seen here as an example.
What is the point of having a version in a Maven aggregate (multi-module) POM? What is it used for? What would be affected if I change it?
For example:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>foobar</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
…
Where is the 1.0-SNAPSHOT used? What artifacts are affected?
On a related note, what semantics does it have? Is it the version of my combined project? Or is it the version solely of the aggregation (which may remain constant through many release versions of the individual modules)?
I am creating multimodule project using maven in eclipse.After configuring parent in that configuration tab,to add modules I have selected Add and selected the modules to be added and I have checked the 'Update POM parent section in selected projects'.But it doesnot include the parent information in the selected modules.
I was not aware that such a feature exists, but you can do it by your own, with more reliability adding those lines to your parent pom :
parent pom.xml
Here put your modules configuration
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.company.bla.bla</groupId>
<artifactId>you-parent-artifact</artifactId>
<version>1.0</version>
<modules>
<module>module-child-1</module>
<module>module-child-2</module>
</modules>
childs pom.xml
Here put you parent reference and ommit version
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.company.bla.bla</groupId>
<artifactId>you-parent-artifact</artifactId>
<version>1.0</version>
</parent>
<artifactId>child-1</artifactId>
More information here : http://www.sonatype.com/books/mvnex-book/reference/multimodule.html
I want to split my continous integration job (Hudson) into two steps. (Because the runtime with build and reporting together takes too long.)
In the first job, I build my multi module maven project with "mvn package" successfully.
Then I copy my workspace to another location and try to build the project again only with the goal "site" and/or findbugs/checkstyle/pmd to create reports.
But this doesn't work! Maven can't resolve a dependency of my submodules.
(But all JARs are available in its target folders.)
Example:
My structure looks like this:
Parent
A
B
C
D
Project C has as dependency project B.
When I build everything with "mvn site", it generates for project A and B all reports. But halted at project C with error message "Could not resolve dependencies for project B."
But project B is already builded with "mvn package". I.e. I can find the JAR file of project B in its target folder.
Is there any way to resolve the dependency from submodule B without a "mvn install"?
(I don't wanna do this on my ci server. I fear it could be dangerous for other jobs with the same code base.)
Update 08/20/12:
POM of root folder:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Foo</name>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>parent</module>
</modules>
</project>
Parent POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Foo</name>
<groupId>foo</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>../bar-a</module>
<module>../bar-b</module>
<module>../bar-c</module>
<module>../bar-d</module>
</modules>
[...]
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.1</version>
[...]
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
[...]
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
[...]
</plugin>
</plugins>
</reporting>
</project>
POM of B:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>foo</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<relativePath>../parent</relativePath>
</parent>
<name>Bar B</name>
<artifactId>bar-b</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
[...]
</project>
POM of C:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>foo</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<relativePath>../parent</relativePath>
</parent>
<name>Bar C</name>
<artifactId>bar-c</artifactId>
<packaging>jar</packaging>
[...]
<dependencies>
<dependency>
<groupId>foo</groupId>
<artifactId>bar-b</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
[...]
</project>
I was facing quite the same "long time" issue.
The only way (I think) to solve it with your way of working is indeed mvn install, as you suggested it.
But the problem is indeed the way you try to have different behaviours with copying your workspace.
You should instead considering that CI will build and test as often as you want (each commit or every hour), but make reporting just one time (each midnight for example). You would be able to have faster continous builds, and correct documentation and reporting by night.
This is the way we work, and it is quite sufficient. We use jenkins for that, but you could trigger it with every CI soft I think) !
#hourly : mvn clean package (or install) --> from 1 to 5 minutes to run all test on all modules
#daily : mvn clean install site --> from 15 to 35 minutes to run all test on all modules + doc + reports + PDF reports
You can also use profiles to trigger different behaviours, but this is too much sophisticated for such a basic use.