Search code examples
javamavenmaven-jetty-pluginjetty-9

How to set Temporary Directory while using maven Jetty Plugin?


I currently use the jetty maven plugin to deploy my war files.

Something like :-

    <plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.3.7.v20160115</version>
  <configuration>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <webApp>
      <contextPath>/test</contextPath>
    </webApp>
    <contextHandlers>
      <contextHandler implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
        <war>${project.basedir}../../B.war</war>
        <contextPath>/B</contextPath>
      </contextHandler>
      <contextHandler implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
        <war>${project.basedir}../../C.war</war>
        <contextPath>/C</contextPath>
      </contextHandler>
    </contextHandlers>
  </configuration>
</plugin>

When I do mvn:jetty run, folders like jetty-localhost.somedomain.com-8080-someApp.war-_someApp-any-931174362474622988.dir get created under the temp directory of my user. Such folders are created every time I build and run my app and it consumes a lot of space and I have to manually delete temp directories each time my pc becomes slow.

Is there a way I could tell jetty to use a particular directory every time so that the older temp folders get replaced.


Solution

  • While giving the war configuration we can mention the temp directory using the tag <tempDirectory></tempDirectory> as shown :-

    <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext"> <war>warNamw</war> <contextPath>contextPath</contextPath> <tempDirectory>giveTheTempPath</tempDirectory> </contextHandler>