facebook

Maven profile properties in pom.xml

  1. MyEclipse IDE
  2.  > 
  3. Maven for MyEclipse (Maven4MyEclipse)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #310402 Reply

    Akumadevil
    Member

    Hi, what is the easiest way to tell MyEclipse to use the profile properties from the pom.xml when I start the application server?

    pom.xml:

    
    ...
    <profiles>
       <profile>
          <id>dev</id>
          <properties>
             <foo>bar</foo>
             ...
          </properties>
       </profile>
    </profiles>
    ...
    

    At the moment it throws an error because a field in one of my properties relies on the pom.xml, which is not being populated.

    properties file:

    
    ...
    something=${foo}
    ...
    

    In the past we used maven to run the project through a Jetty server rather than deploying and starting the app server through MyEclipse (which is preferred).

    Any help would be greatly appreciated.

    #310534 Reply

    support-joy
    Member

    Akumadevil,

    Add the maven-resources-plugin (please note that it is a maven-war plugin even in case it is a war)
    Then add the following node in POM.xml
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.3</version>
    <configuration>
    <encoding>UTF-8</encoding>
    </configuration>
    </plugin>

    and also add the following node
    <resources>
    <resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
    </resource>
    </resources>

    The resources node will specify the resources directroy (i.e the property file which needs to be populated)

    Create a profile and use this resource plugin to substitute the value in the property file.For details refer – http://www.manydesigns.com/documentation/tutorials/using-maven-profiles-and-resource-filtering.html

    #310579 Reply

    Akumadevil
    Member

    Hi,

    The example link relies on building the package through maven specifying the profile (e.g. “mvn package -P development”).

    I normally use the MyEclipse “Add Deployment” feature to build the webapp — can I configure MyEclipse to automatically run the relevant maven command on deployment?

    #316538 Reply

    deeeed
    Member

    Did you find out how to do it?
    I have the exact same issue, I can run my profile through the command line but not via myeclipse.
    I added my profile into my project preferences into the Maven4Myeclipse config.

    #316563 Reply

    support-swapna
    Moderator
Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Maven profile properties in pom.xml

This topic is marked as closed to new replies, however your posting capabilities still allow you to do so.

You must be logged in to post in the forum log in