Maven multiproject: sharing common files between subprojects

Are you using multiproject and want to use common files in all your subprojects?

Then you can define a variable “rootdir” pointing to the dir where common files are stored, so they can be refered as ${rootdir}/filename, both in your properties (, and project.xml files.

To do so you just need to create a maven.xml in the top level project (supposing you have a LICENSE.txt in the top level dir, you can use any other file). This var will point to the same dir from every subproject.


    <!-- =========== Set root dir =========== -->

    <j:set var="rootdir">${basedir}</j:set>

    <j:while test="${true}">
        <util:available file="${rootdir}/LICENSE.txt">
        <j:set var="rootdir">${rootdir}/..</j:set>

    <ant:dirname property="rootdirname" file="${rootdir}/project.xml"/>
    <j:set var="rootdir">${rootdirname}</j:set>
    <echo>Using root dir: ${rootdir}</echo>


You’d like to set some properties using this new var

# License plugin settings

# multiproject

2 thoughts on “Maven multiproject: sharing common files between subprojects

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s