put datadog in its own task as it has a bunch of properties and deps. set build dir as ant property to handle backslashes correctly. use built in regex instead of using sed
<arg value="${build.dir}/conf"/>
</exec>
- <!-- update with datadog config only if monitoring vars are set -->
- <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
- <if>
- <not>
- <equals arg1="${CELLBASE.MONITOR.AGENT}" arg2=""/>
- </not>
- <then>
- <echo>Setting datadog params ${build.dir}</echo>
- <exec executable="sed">
- <arg value="-i"/>
- <arg value="s/JAVA_OPTS/JAVA_OPTS -javaagent:build.dir\/monitor\/dd-java-agent.jar -Ddd.agent.host=${CELLBASE.MONITOR.AGENT} -Ddd.agent.port=${CELLBASE.MONITOR.PORT} /"/>
- <arg value="${project.basedir}/target/appassembler/bin/cellbase-admin.sh"/>
- </exec>
- </then>
- </if>
-
<echo>Copying to ${build.dir}</echo>
<exec executable="cp">
<arg value="-r"/>
<goal>run</goal>
</goals>
</execution>
-
+ <execution>
+ <id>add-datadog</id>
+ <phase>install</phase>
+ <configuration>
+ <target name="add datadog">
+ <property name="antProperty" value="${build.dir}"/>
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
+ <if>
+ <not>
+ <equals arg1="${CELLBASE.MONITOR.AGENT}" arg2=""/>
+ </not>
+ <then>
+ <echo>Setting params for: ${CELLBASE.MONITOR.AGENT}</echo>
+ <replaceregexp file="${build.dir}/bin/cellbase-admin.sh" match="JAVA_OPTS" replace="JAVA_OPTS -javaagent:${antProperty}\/monitor\/dd-java-agent.jar -Ddd.agent.host=${CELLBASE.MONITOR.AGENT} -Ddd.agent.port=${CELLBASE.MONITOR.PORT} " byline="true"/>
+ </then>
+ </if>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
</executions>
<dependencies>
<dependency>
