Tomasz Bekas
Tomasz Bekas

Reputation: 686

Maven, switching to a different profile

I have a problem with proper maven profile configuration of a project that is deployed to a continuous integration server.

In my project, there are some resources that needs to be included only during tests at the daily building phase and others that needs to be included during nightly builds, and they can never be included both at the same time, because building process will fail, I can achive this locally by activating one profile at the same time.

Continuous integration server runs following maven commands:
-during daily builds:

mvn clean package -Pci -Dci

-during nightly builds

mvn clean install -Dmaven.test.failure.ignore -Pci,nightly -Dci -Dnightly

As you see, nightly build command include maven variables and profiles defined in daily build command, which makes some troubles for me, becouse I want to have only one profile activated at the same time.

Specifically, what I want is having 3 separate profiles:
-my-pforile (activated by default, not used on CI server)
-ci-profile (activated only on daily builds, used on CI server)
-nightly-profile (activated only on nightly builds, used on CI server)

How can I achieve that? I tried almost everything. Reconfiguring CI server is not an option.

Upvotes: 0

Views: 983

Answers (1)

noandrea
noandrea

Reputation: 384

When I have to configure the same build with different profiles, using Jenkins as a CI, I usually create as much builds as profiles, so each build uses the correct configuration.

If adding a new build is not an option probably you can try to create a workaround using something like the exec plugin (http://mojo.codehaus.org/exec-maven-plugin/) to download the resources from a ftp (or something else). You will have also to create a cron job (or equivalent) to replace the correct resources between the builds: in the evening you put there the resources for the night, in the morning the ones for the day.

But considering how cumbersome this process will be, probably it is better to try to add a new build.

Upvotes: 2

Related Questions