title: How do you include a jar in the classpath so Maven recognizes it without specifying the jar by name in the POM?
body: <p>I am working with a proprietary maven plugin that generates connection code for artifacts created in a third party application. The proprietary plugin requires different settings in the POM file depending on the artifact it is generating the code for. I am attempting to make it so my Java application doesn't require a code change in the POM between deploying to TEST and deploying to PROD that way I can use the same jar for my application in the TEST and the PROD deployment. The issue is the connection artifacts and thus the POM code for the plugin will be different between TEST and PROD.</p>
  <p>The solution I have in the works is to run the code generating plugin for TEST and for PROD separately then jar the generated code and use a script to include the correct generated code jar in the classpath depending on which environment the Java application jar is being deployed to.</p>
  <p>I was able to jar the generated libraries and include the jar in the classpath which makes Eclipse happy with the dependencies, but when I attempt to run a &quot;mvn compile&quot; and generate the Jar for my Java application Maven isn't recognizing the generated code jar I added to the classpath which prevents the spring-boot-maven-plugin from creating my application jar.</p>
  <p>All the solutions I have seen so far for getting maven to recognize a jar seem to involve specifying the name of the jar in the POM which I wanted to avoid since the names of the TEST and PROD generated code jars will be different (ex. generated_TEST.jar, generated_PROD.jar) and the whole point of this is to not modify any code between the TEST and PROD deployments so I can use the same Java application jar in both TEST and PROD.</p>
  <p>Is there a way to get maven to include any jars on the classpath without having to specify the jar by name in the POM?</p>
  <p>EDIT:
  This might end up being easier than I thought. I used Eclipse to export the generated code to a jar, then I ended up renaming the jar from Generated.jar to Generated-TEST.jar. I added Generated-TEST.jar to the classpath in Eclipse and tried to run &quot;mvn compile&quot; but the jar was not recognized. When I tried changing the name of the jar back to Generated.jar and added it to the classpath I was able to run &quot;mvn compile&quot; successfully. I am not sure why changing the name of the jar made a difference as I put the appropriate name in the classpath both times.</p>