Maven implicit profile Activation

115 views Asked by At

I have two maven profiles

  1. buildProfile
  2. testProfile

So whenever i do

mvn clean install -P buildProfile

it should activate testProfile implicitly first and if testProfile fails it should not proceed to buildProfile and mark the result as Failure.

i want testProfile to be activated only when i run buildprofile.

mvn clean install -P buildprofile --> testProfile(if testProfile success then proceed to buildProfile) + buildProfile

mvn clean install -P anotherProfile ---> anotherProfile

is there anyways to achieve this?

2

There are 2 answers

2
QA Automation tester On

Yes. You can do this by using Jenkins. In Jenkins you will have to create 2 jobs, 1 for buildProfile and another for testProfile... and you can create dependency between these two jobs that 'buildProfile' should run only if the 'testProfile' gets passed (complates without any test failures)

0
Michał Kalinowski On

It is not possible with Maven's profiles mechanism itself, however you can use profile activation on property, e.g.

<activation>
    <property>
        <name>buildProfile</name>
    </property>
</activation>

Then the same property can activate multiple profiles. Maven call then looks like this:

mvn -DbuildProfile ...