title: How to Run a Process Before .class Files are Generated
body: <p>I have almost identical code for Create/Update/Delete APIs that I am trying to replace with a Template model.</p>
  
  <p>So I defined the Controller code in a text Template and then on Application startup I am trying to copy the Template into my project directory and replace the variables with real values to generate the APIs with the respective class names. </p>
  
  <p>Then when I need to make a change I can change my Template and not every API to reduce overall code maintenance. The copy functionality is working, but it's happening after the .class files are generated. Meaning the code my application is actually using is always one version behind the current version. </p>
  
  <p>In order for me to get the correct version running I need to restart the application once again without changing the Templates. That way the current version and previous version would be identical and it seems to be working properly. </p>
  
  <p>However this isn't very convenient from a Production perspective. I tried using javax.tools.* to compile the code, but because I am using many dependencies inside my application it's failing unless I can compile my project together (including the files that need to be generated). </p>
  
  <pre><code>src\main\java\com\project\dao\model\User.java:3: error: package com.vividsolutions.jts.geom does not exist
  import com.vividsolutions.jts.geom.Point;
                                    ^
  src\main\java\com\project\dao\model\User.java:5: error: package javax.persistence does not exist
  import javax.persistence.*;
  </code></pre>
  
  <p>Is it possible to: </p>
  
  <ol>
  <li><p>Create the files before the .class files are generated so that the project can be compiled together. This was if the Template has errors or invalid variables were supplied a compilation error will be thrown.</p></li>
  <li><p>Automate the Application Restart before it becomes fully available. This way the code will start and generate the files from the Template(s). Then it will shutdown. Then it will restart again automatically and recognize the newly generated files so the project can be compiled together. </p></li>
  </ol>