Search code examples
mavenjenkinsjava-home

How to skip variable dereferencing in Maven for specific file?


I have Maven project in Jenkins, Jenkins is running on Windows Server 2012. There is init.script in the project with following line which I want to keep untouched:

echo "export JAVA_HOME=${JAVA_HOME}" >> ${CMD_START}

The issue is that after successful build I got dereferenced JAVA_HOME variable inside init.script file:

echo "export JAVA_HOME=c:\Program Files\Java\jdk1.7.0_79" >> ${CMD_START}

My question is how can I instruct Maven to ignore variables dereferencing for this specific init.script file? Maybe there is some trick I can do with Jenkins instead of Maven?


Solution

  • I assume that you configured Maven to filter your resources (in src/main/resources). If that is the case, exclude the init script like this:

    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <excludes>
          <exclude>path/to/init.script</exclude>
        </excludes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <includes>
          <include>path/to/init.script</include>
        </includes>
      </resource>
    </resources>