title: Maven to include JAR that is generated by that build
body: <p>Normally we use <em>dependency</em> tag in pom.xml to have Maven include a JAR on the classpath and it also packages that dependency.</p>
  
  <p>What if the JAR is generated in a step of the same project's build? I mean, it's not the compile plugin that generates it, it is a JAR without any java source and an external executable creates it.</p>
  
  <p>I can use maven exec plugin to have my JAR generated and maven install plugin to have it installed to my local repository. But still I can't have it as a dependency in the same project: No matter which phase I put my JAR generator command in, the dependency check will happen before that and fail because the JAR does not yet exist.</p>
  
  <p>Is system scope dependency my best choice? Then I need to give up packaging. And it's deprecated. And the JAR needs to be outside the project directory.</p>
  
  <p>Or the JAR generator must be in a separate pom? Also not very nice because the JAR is only used by this one project.</p>
  
  <p>Can I configure the dependency plugin to defer the dependency check and download to compile phase?</p>
  
  <p>Any other solution?</p>
  
  <p>This pom almost works, but first time I need to install the generated thing manually to the repo.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;parent&gt;
          &lt;artifactId&gt;something-parent&lt;/artifactId&gt;
          &lt;groupId&gt;something&lt;/groupId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;artifactId&gt;something-sample&lt;/artifactId&gt;
  
      &lt;properties&gt;
          &lt;jnbridge.path&gt;C:/Program Files (x86)/JNBridge/JNBridgePro v9.0&lt;/jnbridge.path&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;generate-proxies-jar&lt;/id&gt;
                          &lt;phase&gt;generate-test-resources&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;exec&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;executable&gt;jnbproxy.bat&lt;/executable&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;8&lt;/source&gt;
                      &lt;target&gt;8&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-install-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.4&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;process-test-resources&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;install-file&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;groupId&gt;jnbridge.local&lt;/groupId&gt;
                              &lt;artifactId&gt;proxies&lt;/artifactId&gt;
                              &lt;version&gt;0.0.0&lt;/version&gt;
                              &lt;packaging&gt;jar&lt;/packaging&gt;
                              &lt;file&gt;${basedir}/proxies.jar&lt;/file&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;!--
          Yes, these are true system-scope dependencies. JNBridge is expected to be
          installed on the system wherever this project is built.
          --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.jnbridge.org.apache&lt;/groupId&gt;
              &lt;artifactId&gt;bcel&lt;/artifactId&gt;
              &lt;version&gt;5.1&lt;/version&gt;
              &lt;scope&gt;system&lt;/scope&gt;
              &lt;systemPath&gt;${jnbridge.path}/jnbcore/bcel-5.1-jnbridge.jar&lt;/systemPath&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.jnbridge&lt;/groupId&gt;
              &lt;artifactId&gt;jnbcore&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
              &lt;scope&gt;system&lt;/scope&gt;
              &lt;systemPath&gt;${jnbridge.path}/jnbcore/jnbcore.jar&lt;/systemPath&gt;
          &lt;/dependency&gt;
  
          &lt;!--
          This one will be installed to local maven repo in the process-test-resources phase,
          as defined in the project/build/plugins section of this file.
          --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;jnbridge.local&lt;/groupId&gt;
              &lt;artifactId&gt;proxies&lt;/artifactId&gt;
              &lt;version&gt;0.0.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- other dependencies... --&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>