Profile property not resolving in POM - Maven 3.2.1

851 views Asked by At

My requirement is to have profile specific properties. So, I defined <profile>.properties inside src/main/resources/filters/, and I want to use that to populate application.properties file.

Part of POM:

<profiles>
        <profile>
            <id>local</id>
            <properties>
                <build.profile.id>local</build.profile.id>
            </properties>
            <activation>
                <property>
                    <name>env</name>
                    <value>local</value>
                </property>
            </activation>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <build.profile.id>prod</build.profile.id>
            </properties>
            <activation>
                <property>
                    <name>env</name>
                    <value>prod</value>
                </property>
            </activation>
        </profile>
    </profiles>

    <build>
        <filters>
            <filter>src/main/resources/filters/${build.profile.id}.properties</filter>
        </filters>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

Application.properties:

filter-path=${filter-path}

local.properties:

filter-path=C:\\Users\\username\\Documents\\filter-config.conf

The problem is I'm receiving the following error in my POM on the war packaging line:

Multiple annotations found at this line:
    - Error loading property file 'C:\Users\username\workspace\xe-receiver\src\main\resources\filters\${build.profile.id}.properties' (org.apache.maven.plugins:maven-resources-plugin:
     2.6:testResources:default-testResources:process-test-resources)
    - Error loading property file 'C:\Users\username\workspace\xe-receiver\src\main\resources\filters\${build.profile.id}.properties' (org.apache.maven.plugins:maven-resources-plugin:
     2.6:resources:default-resources:process-resources)

Can anyone please me resolve this? Thanks.

0

There are 0 answers