It's common for the parent and child projects to be located outside the workspace. For historic reasons, Eclipse doesn't deal well with nested projects in the workspace. It's also common for the parent project to host all the Tycho configuration information, which makes setting up the child projects a lot easier.
General
project by navigating to File | New | Project | General | Project.com.packtpub.e4.parent
.pom.xml
in the root of the project.pom.xml
file to the parent, but change the artifactId
to com.packtpub.e4.parent
and the packaging
to pom
.properties
element in the pom.xml
file. Inside, create two child tags: tycho-version
(which has the content 0.18.0
) and eclipse
(with the value http://download.eclipse.org/releases/juno
).0.18.0
in the existing Tycho
plugin and replace it with ${tycho-version}
.${eclipse}
.com.packtpub.e4.clock.ui
plug-in underneath the parent project.modules
element to the pom.xml
file, and underneath a module
element with the value com.packtpub.e4.clock.ui
.pom.xml
should look like:<?xml version="1.0" encoding="UTF-8"?> <project xsi:schemaLocation="http://maven.apache.org/ POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>com.packtpub.e4</groupId> <artifactId>com.packtpub.e4.parent</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>pom</packaging> <properties> <tycho-version>0.18.0</tycho-version> <eclipse>http://download.eclipse.org/releases/ juno</eclipse> </properties> <modules> <module>com.packtpub.e4.clock.ui</module> </modules> <build> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-maven-plugin</artifactId> <version>${tycho-version}</version> <extensions>true</extensions> </plugin> </plugins> </build> <repositories> <repository> <id>juno</id> <layout>p2</layout> <url>${eclipse}</url> </repository> </repositories> </project>
com.packtpub.e4.clock.ui/pom.xml
file and add a parent element with a groupId
, artifactId
, and version
that are the same as the parent. It is also possible to remove the version
and groupId
from the child pom.xml
file, as it will default to the parent's groupId
and version
, if not specified:<parent> <groupId>com.packtpub.e4</groupId> <artifactId>com.packtpub.e4.parent</artifactId> <version>1.0.0-SNAPSHOT</version> </parent>
plugins
and repositories
elements from the pom.xml
file of com.packtpub.e4.clock.ui
.mvn clean package
. The parent will be built, which in turn builds all the modules in the list:[INFO] Reactor Summary: [INFO] [INFO] com.packtpub.e4.parent ............ SUCCESS [0.049s] [INFO] com.packtpub.e4.clock.ui .......... SUCCESS [1.866s] [INFO] [INFO] BUILD SUCCESS
Each plug-in is its own Eclipse project, and therefore its own Maven project. To build a set of projects together, there needs to be a parent pom.xml
file, which acts as an aggregator.
At build time, Maven calculates the order in which projects need to be built, and then arranges the build steps accordingly.
The other benefit provided by a parent pom.xml
is the ability to specify standard build plug-ins and configuration information. In this case, the parent specifies the link with Tycho and its versions. This simplifies the implementation of the other plug-ins and features that lie underneath the parent project.