title: Skip step based on job parameter
body: <p>I've read through the spring batch docs a few times and searched for a way to skip a job step based on job parameters.</p>
  
  <p>For example say I have this job</p>
  
  <pre><code>&lt;batch:job id="job" restartable="true"
          xmlns="http://www.springframework.org/schema/batch"&gt;
          &lt;batch:step id="step1-partitioned-export-master"&gt;
              &lt;batch:partition handler="partitionHandler"
                  partitioner="partitioner" /&gt;
              &lt;batch:next on="COMPLETED" to="step2-join" /&gt;
          &lt;/batch:step&gt;
          &lt;batch:step id="step2-join"&gt;
              &lt;batch:tasklet&gt;
                  &lt;batch:chunk reader="xmlMultiResourceReader" writer="joinXmlItemWriter"
                      commit-interval="1000"&gt;
                  &lt;/batch:chunk&gt;
              &lt;/batch:tasklet&gt;
              &lt;batch:next on="COMPLETED" to="step3-zipFile" /&gt;
          &lt;/batch:step&gt;
          &lt;batch:step id="step3-zipFile"&gt;
              &lt;batch:tasklet ref="zipFileTasklet" /&gt;
              &lt;!-- &lt;batch:next on="COMPLETED" to="step4-fileCleanUp" /&gt; --&gt;
          &lt;/batch:step&gt;
          &lt;!-- &lt;batch:step id="step4-fileCleanUp"&gt;
              &lt;batch:tasklet ref="fileCleanUpTasklet" /&gt;
          &lt;/batch:step&gt; --&gt;
      &lt;/batch:job&gt;
  </code></pre>
  
  <p>I want to be able to skip step4 if desired by specifying in the job paramaters.</p>
  
  <p>The only somewhat related question I could find was <a href="https://stackoverflow.com/questions/25122103/how-to-select-which-spring-batch-job-to-run-based-on-application-argument-spri">how to select which spring batch job to run based on application argument - spring boot java config</a></p>
  
  <p>Which seems to indicate that 2 distinct job contexts should be created and the decision made outside the batch step definition.</p>
  
  <p>I have already followed this pattern, since I had a csv export as well as xml as in the example. I split the 2 jobs into to separate spring-context.xml files one for each export type, even though the there where not many differences. </p>
  
  <p>At that point I though it was perhaps cleaner since I could find no examples of alternatives.</p>
  
  <p>But having to create 4 separate context files just to make it possible to include step 4 or not for each export case seems a bit crazy.</p>
  
  <p>I must be missing something here.</p>