title: Maven: partial compilation before code generation
body: <p><strong>tl;dr-edition:</strong> I have a compilation I know that will fail, but want the subset of classes that are still compilable in my <code>target/classes</code> folder after compilation. I have configured <code>&lt;failOnError&gt;false&lt;/failOnError&gt;</code>, but no classes are generated, not even a dummy class that is independent of any other classes except <code>Object</code>. Is there some configuration to achieve this?</p>
  
  <hr>
  
  <p>I have a maven-powered project whose workflow consists of basically the following (relevant) goals:</p>
  
  <ul>
  <li><code>...</code></li>
  <li><p><code>init-compile</code></p>
  
  <p>The code generator (below) uses a config that is reflection-based, so, in a first pass, I want to try compile as much of the project as possible so that no ClassNotFoundExceptions are thrown there. This compilation is configured with <code>&lt;failOnError&gt;false&lt;/failOnError&gt;</code> so that the build continues.</p>
  
  <p>Unfortunately (you could call it a design flaw), the config is used both for code generation (specifying the OWL file and namespace to package mappings) and at runtime, so it also contains other elements that are not needed for the code generator, but are still read and therefore needed on the classpath to succeed.</p></li>
  <li><p><code>generate-model</code></p>
  
  <p>In this step, some model classes are generated from an OWL-Ontology, creating the code that makes the rest of the project completely compileable.</p></li>
  <li><p><code>default-compile</code></p>
  
  <p>Now, the rest of the classes should be compiled, obviously</p></li>
  <li><p><code>save-model</code></p>
  
  <p>Now, the instances from the ontology are read and serialized to a file for runtime</p></li>
  <li><p><code>...</code></p></li>
  </ul>
  
  <p>Side note: both generate and save model use <code>maven-exec-plugin</code>, but I sincerely don't think that matters at all.</p>
  
  <p><strong>Question:</strong></p>
  
  <p>When I run my build with <code>mvn -e -U clean package source:jar javadoc:jar install:install</code>, it fails during the <code>generate-model</code> goal with the errors I'm trying to avoid. <code>target/classes</code> is empty, so it seems that the compiler doesn't spit out the subset of classes it could/should have been able to process. Is there a way to achieve this?</p>
  
  <p>I have two workarounds in mind which I both don't like:</p>
  
  <ul>
  <li>Editing the config file "AST" before parsing it into Java-Objects, so that only the part relevant for the code generator is parsed (needs tweaking of code that I have access to but should be considered immutable by my project);</li>
  <li>and to configure the <code>init-compile</code> goal to only include the needed classes (too inflexible, because the POM should/could be a template for future applications using the same model).</li>
  </ul>
  
  <p>If you can imagine another way to work around my problem that you can see from my description, I would be glad to hear them, too!</p>