Maven配置文件属性中的值未在.properties文件中使用 [英] Value from Maven profile properties is not getting used in .properties file

查看:87
本文介绍了Maven配置文件属性中的值未在.properties文件中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在pom.xml文件下面

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>

我有如下的serenity.properties文件

I've got serenity.properties file as below

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

当我尝试使用以下pom.xml中的值时,它无法按预期工作.Serenity.properties文件没有在特定配置文件名称下提到的获取值.

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

推荐答案

您的目录规范错误.不要使用 $ {basedir} ,而不要使用 $ {project.basedir} ,这样可以正常工作:

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

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

更好的做法是坚持使用标准的Maven目录布局,并将您的资源放在此处:

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

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

这篇关于Maven配置文件属性中的值未在.properties文件中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆