0

I have a HTML page which consist of <script> tag as follows

<script type="text/javascript">
   window.location ="THIRD PARTY URL"
</script>

The above code runs properly.
Now my requirement is: change the value of this Third Part URL from one environment to another during Deployment Time.
This THIRD PARTY URL will vary in DEV Environment, UAT environment and Production environment.

I don't want to change this value manually every time before deploying the EAR to my Weblogic server. Instead I am looking for some script which can perform this task.

I know using ANT script it can be done.
But I am not able to figure out the exact configuration of build.xml required for my case.

I have already gone through the following links in stackoverflow:

ANT replacing strings in specified files using file with properties

Has anyone any suitable solution to this?

Community
  • 1
  • 1
Sumit Ghosh
  • 484
  • 4
  • 13
  • 36

2 Answers2

0

I would suggest to you a bit different solution. Have a file:

   // setup.js
   var url = "THIRD_PARTY_URL";

And your main file will contain:

<script type="text/javascript" src="setup.js"></script>
<script type="text/javascript">
   window.location = url;
</script>

During the deployment time you will have to copy over the correct setup.js for given environment. It is a bit cleaner then modifying file, I think. And with this approach you can actually have more configuration options for the environment, if needed.

Vladimir M
  • 4,403
  • 1
  • 19
  • 24
0

Easiest solution would be replace the regex.

<replaceregexp file="test.html" match="window.location(.*)" replace="window.location=&quot;${MYURLVALUE}&quot;" byline="true"/>

Here file specifies your html file. We are matching the key and value as a regular expression. Note the &quot; in the replace parameter. This is to ensure your URL results inside quotes.

MJO
  • 16
  • 2