Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Maven task does not support profile in Goal

Rasha Elsayed April 12, 2023

Hi,

I have a bamoo build plan in which I added a maven task. In Goal I wrote 

package -P prod-profile

But the artifact generated (jar file) is created with the default profile configurations, as it seems that the -P above is ignored.

 

Is there anything wrong in my entry?

 

I appreciate your support and look forward to hear from you.

Thanks a lot and best regards

Regards

Rasha Elsayed

1 answer

1 accepted

1 vote
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 12, 2023

Hello @Rasha Elsayed

Welcome to Atlassian Community!

Check the pom.xml file for any activeByDefault set to false. Maven will only consider it if it is active.

Running mvn help:active-profiles will show the active profiles.

You also need to understand that the profile configuration needs to be carried on by the Project's pom.xml file. Or, you will have to replicate the profile configuration in one of the Agent's own locations (outside of the build scope):

  • %USER_HOME%/.m2/settings.xml
  • ${maven.home}/conf/settings.xml

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Rasha Elsayed April 12, 2023

Hello Eduardo,

thanks a lot for your reply. Actually I have 2 profiles:

  • dev-profile having activeByDefault = and
  • prod-profile does not set this property.

Running mvn package -P prod-profile from the command line on my local machine works correctly. The jar artifact is generated with the prod-profile configurations.

However in bamboo mvn task, when I enter package -P prod-profile in the Goal field, the jar file gets generated with the dev-profile configurations.

 

In addition, from command line

  • running mvn help:active-profiles shows only dev-profile
  • running  mvn help:active-profiles -P prod-profile shows prod-profile

So, it seems that the Maven task in bamboo ignores the -P setting in the goal, right?

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 12, 2023

Hello @Rasha Elsayed

You should set activeByDefault on prod-profile in pom.xml so mvn would consider it. That's validated when you run the help:active-profiles command.

Your local machine or the Agent may have other Maven settings that may be considering/not considering that profile.

Thank you,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Like Steffen Opel _Utoolity_ likes this
Rasha Elsayed April 13, 2023

Hi @Eduardo Alvarenga 

Thanks for your Response. I think i will replace the maven task with a script task in which i can run maven simply as 

mvn package -P prod-profile

 

Regards

Rasha

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events