title: Install Jar Dependency to Local Repository as Part of Maven Build Process
body: <p>I have a third-party jar that is a dependency of my project.  Because of business constraints, I do not have access to an enterprise or company repository, which would definitely be my preference for this issue.  But regardless, this third-party jar is not available publicly, and so it is included in the web project under <code>src\main\resources</code>.  </p>
  
  <p>This is a Maven project, and so I list this third-party jar as a compile time dependency, and include in my pom a build plugin that will install the third-party jar to my local repository as part of the build process; I tell Maven to perform this goal during the <code>validate</code> phase of the build lifecycle, which to my knowledge would be before any other Maven phase.  </p>
  
  <p>However, when I run a <code>clean install</code> and have my local repository cleared out, the build fails due to the third-party jar not being resolvable locally or in the Maven central repository.  As far as I know, I have set up the pom correctly and I should be seeing Maven attempt to install the third-party jar locally before it begins dependency resolution.</p>
  
  <p>The issue is that if the dependency is listed before the jar has ever been installed locally, the build will fail due to being unable to resolve that dependency.  If I remove the third-party jar declaration and run the build, <em>after</em> dependency resolution occurs (which is the very first thing it does after the clean), but before any other phase, it will locally install the jar and things are fine.  But to my knowledge, it should run the <code>validate</code> phase before it collects and resolves dependencies, and so the jar <em>should</em> be locally installed before it's resolved by Maven.  Any ideas or thoughts?</p>
  
  <p>My pom:  </p>
  
  <pre><code>&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/maven-v4_0_0.xsd"&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.company&lt;/groupId&gt;
      &lt;artifactId&gt;project&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;name&gt;Web Services&lt;/name&gt;
      &lt;description&gt;This project will handle communication.&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;!-- This plugin installs the Evip jar from the project's resource folder to the local 
                  repository for normal Maven consumption --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.2.1&lt;/version&gt;
                  &lt;inherited&gt;false&lt;/inherited&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;install-evip-jar&lt;/id&gt;
                          &lt;phase&gt;validate&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;mvn&lt;/executable&gt;
                      &lt;arguments&gt;
                          &lt;argument&gt;install:install-file&lt;/argument&gt;
                          &lt;argument&gt;-Dfile=${basedir}\src\main\resources\EVIPSoapServer.jar&lt;/argument&gt;
                          &lt;argument&gt;-DgroupId=com.company&lt;/argument&gt;
                          &lt;argument&gt;-DartifactId=EVIPSoapServer&lt;/argument&gt;
                          &lt;argument&gt;-Dversion=1.0.0&lt;/argument&gt;
                          &lt;argument&gt;-Dpackaging=jar&lt;/argument&gt;
                      &lt;/arguments&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.4&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;!-- EXCLUDE EVIPSOAPSERVER JAR FROM CLASSES DIRECTORY --&gt;
                      &lt;packagingExcludes&gt;
                          ${basedir}\src\main\resources\EVIPSoapServer.jar
                      &lt;/packagingExcludes&gt;
                      &lt;webResources&gt;
                          &lt;!-- INCLUDE SOURCE FILES WITH WAR --&gt;
                          &lt;resource&gt;
                              &lt;directory&gt;${project.build.sourceDirectory}&lt;/directory&gt;
                              &lt;targetPath&gt;WEB-INF/classes&lt;/targetPath&gt;
                          &lt;/resource&gt;
                      &lt;/webResources&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
  
          &lt;pluginManagement&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;!-- mvn clean install tomcat:run-war to deploy Look for "Running war 
                          on http://xxx" and "Setting the server's publish address to be /yyy" in console 
                          output; WSDL browser address will be concatenation of the two: http://xxx/yyy?wsdl --&gt;
                      &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
                      &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.0&lt;/version&gt;
                      &lt;executions&gt;
                          &lt;execution&gt;
                              &lt;id&gt;start-tomcat&lt;/id&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;run-war&lt;/goal&gt;
                              &lt;/goals&gt;
                              &lt;phase&gt;pre-integration-test&lt;/phase&gt;
                              &lt;configuration&gt;
                                  &lt;port&gt;${test.server.port}&lt;/port&gt;
                                  &lt;path&gt;/webservice&lt;/path&gt;
                                  &lt;fork&gt;true&lt;/fork&gt;
                                  &lt;useSeparateTomcatClassLoader&gt;true&lt;/useSeparateTomcatClassLoader&gt;
                              &lt;/configuration&gt;
                          &lt;/execution&gt;
                      &lt;/executions&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;1.7&lt;/source&gt;
                          &lt;target&gt;1.7&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-eclipse-plugin&lt;/artifactId&gt;
                      &lt;configuration&gt;
                          &lt;projectNameTemplate&gt;[artifactId]-[version]&lt;/projectNameTemplate&gt;
                          &lt;wtpmanifest&gt;true&lt;/wtpmanifest&gt;
                          &lt;wtpapplicationxml&gt;true&lt;/wtpapplicationxml&gt;
                          &lt;wtpversion&gt;2.0&lt;/wtpversion&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
  
                  &lt;!--This plugin's configuration is used to store Eclipse m2e settings 
                      only. It has no influence on the Maven build itself. --&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.eclipse.m2e&lt;/groupId&gt;
                      &lt;artifactId&gt;lifecycle-mapping&lt;/artifactId&gt;
                      &lt;version&gt;1.0.0&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;lifecycleMappingMetadata&gt;
                              &lt;pluginExecutions&gt;
                                  &lt;pluginExecution&gt;
                                      &lt;pluginExecutionFilter&gt;
                                          &lt;groupId&gt;
                                              org.codehaus.mojo
                                          &lt;/groupId&gt;
                                          &lt;artifactId&gt;
                                              exec-maven-plugin
                                          &lt;/artifactId&gt;
                                          &lt;versionRange&gt;
                                              [1.2.1,)
                                          &lt;/versionRange&gt;
                                          &lt;goals&gt;
                                              &lt;goal&gt;exec&lt;/goal&gt;
                                          &lt;/goals&gt;
                                      &lt;/pluginExecutionFilter&gt;
                                      &lt;action&gt;
                                          &lt;ignore&gt;&lt;/ignore&gt;
                                      &lt;/action&gt;
                                  &lt;/pluginExecution&gt;
                              &lt;/pluginExecutions&gt;
                          &lt;/lifecycleMappingMetadata&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/pluginManagement&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;!-- COMPILE DEPENDENCIES --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.company&lt;/groupId&gt;
              &lt;artifactId&gt;EVIPSoapServer&lt;/artifactId&gt;
              &lt;version&gt;1.0.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-rt-frontend-jaxws&lt;/artifactId&gt;
              &lt;version&gt;2.7.7&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-rt-transports-http&lt;/artifactId&gt;
              &lt;version&gt;2.7.7&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;3.0.7.RELEASE&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!-- PROVIDED/TEST DEPENDENCIES --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.11&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>