du-it
du-it

Reputation: 3009

Maven profiles are not considered in Eclipse

I have three profiles defined in my pom.xml:

   <profiles>
    <profile>
        <id>ABC</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <url.base>http://server1.de</url.base>
            <url.searchevse>/search</url.searchevse>
            <url.reservation>/reservation</url.reservation>
            <url.cancelation>/reservation/cancel</url.cancelation>
            <xxx.devmode>false</xxx.devmode>
        </properties>
    </profile>
    <profile>
        <id>XYZ</id>
        <properties>
            <url.base>http://server2.de</url.base>
            <url.searchevse>/cns/search</url.searchevse>
            <url.reservation>/cns/reservation</url.reservation>
            <url.cancelation>/cns/cancel_reservation</url.cancelation>
            <xxx.devmode>false</xxx.devmode>
        </properties>
    </profile> 
   <profile>
        <id>DEVELOPMENT</id>
        <properties>
            <url.base>http://localhost/noservices</url.base>
            <url.searchevse>/no/search</url.searchevse>
            <url.reservation>/no/reservation</url.reservation>
            <url.cancelation>/no/cancel_reservation</url.cancelation>
            <xxx.devmode>true</xxx.devmode>
        </properties>
    </profile>
</profiles>

In Eclipse I have a Run Configuration

clean install XYZ

and I tried both using -PXYZ (and -P XYZ) in the Goals field as well as

clean install

in the Goals field and XYZ in the Profiles field.

The problem:

The defined profile is never used.

Inserting the active profile under Properties-->Maven-->Active Maven Profiles doesn't work (or do I have to use a special syntax, e.g. no spaces after a comma or so).

Upvotes: 17

Views: 53378

Answers (4)

anre
anre

Reputation: 3755

In Eclipse 4.20 you can right click on project -> Maven -> Select Maven Profiles...

Upvotes: 3

Right click your project in the Project Explorer then go to

Properties --> Maven --> Active Maven Profiles

enter image description here

and type in only the profile name that you want to run.

If you want to run your ABC profile, type in ABC in the Active Maven Profile input box.

The description(separated by commas) given there is a bit confusing.

Once you define your profile name or id in the input box. You can clean and run your project on your server.

By doing so, your mentioned active maven profile will be run.

Upvotes: 39

levolutionniste
levolutionniste

Reputation: 424

For those who still have problems. I am not really used to Eclipse nor STS but I actually use Spring Tool Suite Version: 4.7.1.RELEASE. I think the Active Maven Profile input box. may be named Write here your already activated Maven Profile :) as I think its purpose is to select an activated profile to run.

In my case, what I did was :

  1. edit my Maven settings.xml (maven folder, conf folder) file to activate the desired profile with <activeProfile>MyProfileId</activeProfile> in the activeProfiles section. The one thing I really appreciate is that it accepts profile even defined in your project pom.xml and that is great for peoject with sub modules. If you have time, read this https://maven.apache.org/guides/introduction/introduction-to-profiles.html
  2. Then add your profile to Active Maven Profile input box (Ctrl+Alt+P or right click on your project, Maven, Select Maven profiles). You can also deactivate a profile with ! or - before a profile name. You might need to restart Eclipse.

The first step is only to activate your profile. So if you have any way to achieve this, feel free to do as so.

Upvotes: 1

Pippo Basta
Pippo Basta

Reputation: 11

verify that plugin execution id are not equal in different profiles

Upvotes: 1

Related Questions