Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to access properties defined in other module pom in maven multimodule project

In pom of A.B.C i have defined a property as abc where A B C are modules. Now i want to access that property in pom of A.D.F module.

<properties>
<A.B.C>${buildNumber}</A.B.C>
</properties>

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                <id>buildnumber</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
            <timestampFormat>{0,date,dd-MM-yyyy HH:mm:ss}</timestampFormat>
            <doCheck>false</doCheck>
            <doUpdate>false</doUpdate>
            <providerImplementations>
                <svn>javasvn</svn>
            </providerImplementations>
            <revisiononscmfailure>

                    <!-- 71 Generate sequence build number based on: 72 build number and 
                        timestamp 73 -->

                    <format>Build: #{0} ({1,date})</format>

                    <items>

                        <item>buildNumber\d*</item>

                        <item>timestamp</item>

                    </items>

                </revisiononscmfailure>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
                <artifactId>maven-scm-provider-svnjava</artifactId>
                <version>2.1.1</version>
            </dependency>
            <dependency>
                <groupId>org.tmatesoft.svnkit</groupId>
                <artifactId>svnkit</artifactId>
                <version>1.8.5</version>
            </dependency>
        </dependencies>

        </plugin>

I am using ${A.B.C} as value of version in a dependency in A.D.F module's pom.

<dependency>
        <groupId></groupId>
        <artifactId></artifactId>
        <version>${A.B.C}</version>
        <type>bundle</type>
    </dependency>

So it is giving me error: bundle must be a valid version but is ${A.B.C}.

EDIT:

or can i use version of C module in someway as i have defined:

<version>${A.B.C}</version> 
like image 734
HimanshuR Avatar asked Aug 26 '14 06:08

HimanshuR


2 Answers

Do those modules share a parent pom? Seems like if you want them linked, it would be a good idea to have them share properties via parent, especially if you want to tightly couple module versions between many modules.

like image 195
coffeeaddict Avatar answered Oct 28 '22 11:10

coffeeaddict


Explanation provided in answer of this question explains it in a very good manner that what can be used and when.

Reading Properties file from POM file in Maven

like image 23
HimanshuR Avatar answered Oct 28 '22 11:10

HimanshuR