Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven pom xml variables

Tags:

java

maven

When setting a dependency. Let's assume the following

<dependency>
        <groupId>com.atlassian.plugins</groupId>
        <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
        <version>${plugin.testrunner.version}</version>
        <scope>test</scope>
</dependency>

Where does the

${plugin.testrunner.version}

variable get initialized? Is there a properties file or where does it gets it value?

like image 691
luca.p.alexandru Avatar asked Nov 27 '15 16:11

luca.p.alexandru


People also ask

How do you declare variables in POM XML?

To refer to environment variables from the pom. xml, we can use the ${env. VARIABLE_NAME} syntax. We should remember to pass the Java version information via environment variables.

What is POM XML in Maven?

What is a POM? A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects.

What are properties in POM XML?

Properties can be defined in a POM or in a Profile. The properties set in a POM or in a Maven Profile can be referenced just like any other property available throughout Maven. User-defined properties can be referenced in a POM, or they can be used to filter resources via the Maven Resource plugin.


1 Answers

This should be intialised in a properties section, at the same level as your dependencies section, eg

<project>
    <properties>
        <plugin.testrunner.version>1.0</plugin.testrunner.version>
    </properties>
...
    <dependencies>
...
    </dependencies>
</project>

If you have a multi project application with a parent pom.xml it's common to put all your properties in there so they can be used by all of the individual poms.

like image 71
ewanc Avatar answered Oct 06 '22 10:10

ewanc