cancel
Showing results for 
Search instead for 
Did you mean: 

Maven SDK and configurations for specific environements

jneeve
Champ in-the-making
Champ in-the-making
New to Maven so helpfully this makes sense..

We're converting from an old ANT SDK to Maven - We've setup our ANT project to load specific property files per environment based on naming convention's (config.test, config.prod,etc) when packaging up the amps. So in ANT we just have build targets for each AMP, and specific file copy actions depending on what each amp module needs for itself) 

I see in the new SDK instructions on setting up different environments for Alfresco itself (alfresco-global.properties) but not how to setup individual AMPS to pull in different configurations.

So for example, we have a custom authentication AMP built in Maven now, that requires a different config for dev/test vs production. (This is inside a larger all-in-one archetype project)

So ideally I would want Maven configured that when i specify the environment (-Denv=test) it also does something similar for the AMP's, as well as the same for the overall Alfresco environment.

IE: customizations\crowd\src\main\amp\config\alfresco\module\crowd\alfresco-global-properties.test (.prod, etc etc)

I know Maven supports profiles, but would it be possible to tweak Alfresco's build process to do this automatically, or is there some preferred way to accomplish this?

Thanks.





3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator
Hello,

the preferred way is not to have environment specific build processes done in Maven. The resulting AMP should always be identical unless something in its functionality has been changed. Environment-specific configuration belongs in the alfresco-global.properties or the extension/web-extension folder of the server instance. It should typically not be managed within the project - if it is managed in the project, it should not be included in the main AMP, but can be attached to it in secondary artifacts (like a prod.config.zip).

Regards
Axel

jneeve
Champ in-the-making
Champ in-the-making
Yes, I agree normally that would be best practice, and our current 4.1 install is setup that way.

I think what I'm confused on then, is how to do manage this in Maven when you're doing an all in one archetype startup or Pamp-to-war. (Vs say building for the production environment)

Currently we run our ant script, assembled all the amps to a directory, then copy them over them to the specific environment. Then run the alfresco-mmt tool to build a new war. Environment specific stuff sits in tomat/shared/classes/extension.

With the way I have Maven all-in-one project setup, I ended up with both the license and alfresco-global.properties all inside the produced WAR, because without those files I couldn't run the embedded tomcat properly. I can just drop the new WAR into the environment, but everything is self contained and I dont really like have environment specific configs right tin the war.

So, now I have one alfresco-global.properties inside my custom Crowd AMP that contains environment specific URL for authentication (injected through a spring context), and then I have an alfresco-global.properties under repo/src/main/properties/test that contains normal Alfresco environment stuff.

Ideally, I wanted my Crowd AMP to contain different property files per environment, but I couldnt figure out how to reference them when running the pamp-to-war. (Normally they would just be in the classpath and we used a propertyWrapper to reference them).

Do you have an link to any examples on how you would configure secondary objects for different environments?

jneeve
Champ in-the-making
Champ in-the-making
After playing around with this for a bit, I think we should be able to do what we need just by paying attention to the order of which alfresco-global.properties gets loaded

For a module inside an all-in-one project, the module.xxx/alfresco-global.properties contains all the development defaults. If on a different environment, test,uat,etc we need to override that, just use the external tomcat/shared/alfresco-global.properties - we can keep those inside repo/src/main/properties/{env} for source control but, we don't have to include them when building the war if tell maven to exclude including property files.

This allows us to run both the full development alfresco/share/solr environment, or individually run one of children amp modules (amp-to-war) for quick testing/development.

The only problem I'm having with this setup, is that the individual amp module may require something that's outside it's own project and stored in the repo/resources (ie: enterprise license) and I'm having problems when I converted to mySQL.

When I -Pamp-to-war it grabs the mySQL DB settings from the all-in-one project.pom, but it creates it's own alf_data_dev folder, so you get a data inconsistency error when booting. I either need to make it use the same data folder as the all-in-one project, or force a purge to delete the db/data.