Multiple environments with Composer

Similar to the previous posts about configuring dqMan/DQLTester (Multiple environments with dqMan/DQLTester) and tomcat (Multiple environments with Tomcat/DA), Composer can be launched the same way:

Folder structure:

  • composer.bat
  • properties
    • env1
      • dev
        • dfc.properties
      • prod
        • dfc.properties
    • env2
      • dev
        • dfc.properties
      • prod
        • dfc.properties
  • etc.

Composer.bat:

@Echo off
SETLOCAL ENABLEEXTENSIONS

SET composerfolder=path to composer folder<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;">&#65279;</span>
SET folderbase=dfcproperties
SET parambase=-Ddfc.properties.file=

echo ****************
echo 1. env1 dev
echo 2. env2 prod
...
echo ****************

SET /p var= ^&gt; Choose option:

if "%var%"=="1" goto op1
if "%var%"=="2" goto op2
...

:op1
SET JAVA_TOOL_OPTIONS=%parambase%%cd%\%folderbase%\env1\dev\dfc.properties
goto finish

:op2
SET JAVA_TOOL_OPTIONS=%parambase%%cd%\%folderbase%\env1\prod\dfc.properties
goto finish
...

:finish

start "" /D %composerfolder% /B %composerfolder%\composer.exe
cls&amp;exit

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.