Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3601630
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:38:44+00:00 2026-05-18T20:38:44+00:00

I have some Java projects that use Apache Commons Configuration and they get deployed

  • 0

I have some Java projects that use Apache Commons Configuration and they get deployed to multiple servers in multiple environments (dev/test/prod).

All code is the same, but some config items change, such as JMS URLs (dev should point to dev, etc) as well as the server name and environment (I use these config items for debugging).

Example:

<config>
    <!-- environment can be dev|test|prod -->
    <environment>dev</environment>

    <serverName>myServer1</serverName>

    <jmsUrl>http://my-jms-url-dev1,http://my-jms-url-dev2</jmsUrl>
</config>

Currently, I deploy, build, then edit the files manually to provide the server-specific configurations. I want a way to automate this when I deploy it to individual servers, but all the ways I’ve considered require an equal amount of pain to setup.

  • ANT – Check out the project with SVN and build it on each server with ANT. ANT reads the server name and the environment from two static files – .servername and .environment – and copies a server-specific config to the generic config. The problem with this is, I still have to create a config file for each server (I have 24 servers, and this may increase, so scalability is not good).

  • SVN – Branch each of my projects to a server-specific distribution. Here, scalability is worse and it becomes a nightmare to maintain.

Does anybody have any tips for me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:38:44+00:00Added an answer on May 18, 2026 at 8:38 pm

    I figured this out.

    Step 1.

    Get the host name:

    <target name="getHostname" description="Stores the current machines hostname in a property named 'hostname'">
        <property environment="env" />
        <condition property="hostname" value="${env.HOSTNAME}">
            <os family="unix" />
        </condition>
    
        <!-- Execute hostname command on Linux systems -->
        <exec executable="hostname"
              osfamily="unix"
              failifexecutionfails="false"
              outputproperty="env.COMPUTERNAME"/>
    
        <!-- On Windows, the hostname is an environment variable -->
        <condition property="hostname" value="${env.COMPUTERNAME}">
            <os family="windows" />
        </condition>
    
        <echo message="${env.COMPUTERNAME}" />
    
    </target>
    

    Step two, create a template file and use to copy the file and do a find/replace on it:

        <copy file="${scripts}/.servername.template"
              tofile="${scripts}/.servername">
            <filterchain>
                <replacetokens>
                    <token key="SERVER_NAME"
                           value="${env.COMPUTERNAME}" />
                </replacetokens>
            </filterchain>
        </copy>
    

    The .servername.template file contains this string:

    @SERVER_NAME@
    

    Then, I use a web service to get a JSON string to tell me what environment I’m in. And I use the task to process the JSON and get the environment.

    Pretty heavy-duty for such a simple task, but it works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to port some existing j2se libraries (e.g. Apache Compression libs) to use
I have some questions about logging, more specifically about setting it up and making
I have a side project I do = in Java. It's a pretty straight-forward
I've got a client who already has some applications in production and therefore has
Dealing with Java - which the option you prefer in the most cases -
I have inherited a broad, ill-designed web portfolio at my job. Most pages are
I'm trying to use Circumflex ORM (as suggested on StackOverflow - here , here
I've looked through many of the existing threads about this error, but still no
I find the nature of this question to be quite suited for the practical-minded
I'm trying to write an embedded ( NOT web, not enterprise ) content management

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.