I based my answer on @walyrious idea. I execute bash -c 'source run.sh; custom-script.sh'
in maven-antrun-plugin so that custom-script.sh
is in the same shell as the sourced run.sh
. Though, I think this maven execution is much cleaner than his answer:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<executions>
<execution>
<id>source file</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec executable="bash">
<arg line="-c 'source run.sh; custom-script.sh'"/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>