I have an ant build file that loads custom configuration settings based on the developer working on the project. This file is loaded based on the developers windows login name. So if it is bobross there is a file called bobross.properties in the directory alongside the build.xml file. But, we have started to migrate to using Azure Active directory with our machine logins and when you login your username ends up being azuread\bobross that slash really causes some problems since that is the windows directory delimiter. Ant hates the slash and won’t load the file. Fortunately, there is a solution - regex to the rescue.

Before importing the properties file I have the following ant logic near the top of the build file:

    <loadresource property="username">
        <propertyresource name="user.name"/>
                <replaceregex pattern=".*\\" replace="" />

    <import file="base_build.xml" />
    <property file="${username}.properties" />