javamavenmaven-2maven-pluginmaven-profiles

Value from Maven profile properties is not getting used in .properties file


I've below pom.xml file

<resources>
            <resource>
                <directory>${basedir}</directory>
                <includes>
                    <include>*.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>

<profiles>
        <profile>
            <id>android</id>
            <properties>
                <automationName>uiautomator2</automationName>
                <platformName>Android</platformName>
                <platformVersion>6.0</platformVersion>
                <deviceName>Android Emulator</deviceName>
                <app>/Users/name/Documents/serenity-core/serenity-appium/src/test/java/integration/resources/WordPress-debug.apk</app>
                <appPackage>org.wordpress.android</appPackage>
                <appActivity>org.wordpress.android.ui.accounts.LoginActivity</appActivity>
            </properties>
        </profile>

        <profile>
            <id>ios</id>
            <properties>
                <automationName>XCUITest</automationName>
                <platformName>IOS</platformName>
                <platformVersion>11.4</platformVersion>
                <deviceName>iPhone SE</deviceName>
                <app>/Users/name/Documents/serenity-core/serenity-appium/src/test/java/integration/resources/WordPress.app</app>
            </properties>
        </profile>
    </profiles>

I've got serenity.properties file as below

appium.automationName = ${automationName}
appium.platformName = ${platformName}
appium.platformVersion = ${platformVersion}
appium.deviceName  = ${deviceName}
appium.app = ${app}

When I am trying to use values from pom.xml as below it doesn't work as expected. Serenity.properties file doesn't the get values mentioned under particular profile name.

mvn install -Pandroid

Solution

  • Your directory specification is wrong. Do not use ${basedir} but ${project.basedir}, then it works as expected:

    <directory>${project.basedir}</directory>
    

    Even better would be to stick with the standard Maven directory layout and put your resources here:

    <directory>src/main/resources</directory>