1

I want to change the value of different properties during the maven build. Maven Change a value in a file based on profile I also tried many other but it never works, and i don't understand why...

Here is my pom.xml

<profiles>
    <profile>
        <id>dev</id>
        <activation>
            <property>
                <name>environment</name>
                <value>dev</value>
            </property>
        </activation>
        <properties>
            <aem.url.prop>hugoL</aem.url.prop>
        </properties>
    </profile>
</profiles>
<build>
<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
</resources>
<plugins>
  <plugin>
    <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <executable>true</executable>
        </configuration>
    </plugin>
</plugins>

I have a maven based project and here what is under src/main/resources in a file named front-config.properties:

enter image description here

After, i run the following command:

"mvn clean install -DskipTests -Pdev" or

"mvn clean install -DskipTests -Denvironment=dev"

I keep having my token inside the properties file, it never gets replaced...

If someone could help me, thanks in advance !

Community
  • 1
  • 1
La Hu
  • 85
  • 1
  • 11

1 Answers1

0

If you have a file with filter properties you should

  1. have the location of filter property file in your <profile>

```

<properties>
    <filter.properties>filter-values-myId.properties</filter.properties>
</properties>

```

  1. add a filter tag to within your <build>

```

<filters>
    <filter>${[a filter property] file location}</filter>
</filters>

```

Refer: https://gist.github.com/Qkyrie/6018561

https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

Dhruvan Ganesh
  • 1,502
  • 1
  • 18
  • 30
  • I don't understant what i need to do, in the link i put, the guy don't explain this and the situation is like mine... – La Hu May 10 '17 at 09:33