Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <a href="http://ant.apache.org/manual/" rel="noreferrer">Ant</a> to set up, compile, <a href="http://ant.apache.org/manual/Tasks/war.html" rel="noreferrer">WAR</a>, and deploy your solution.</p> <pre><code>&lt;target name="default" depends="setup,compile,buildwar,deploy"&gt;&lt;/target&gt; </code></pre> <p>You can then execute one click in Eclipse to run that Ant target. Here are examples of each of the steps:</p> <h3>Preconditions</h3> <p>We'll assume that you have your code organized like:</p> <ul> <li><code>${basedir}/src</code>: Java files, properties, XML config files</li> <li><code>${basedir}/web</code>: Your JSP files</li> <li><code>${basedir}/web/lib</code>: Any JARs required at runtime</li> <li><code>${basedir}/web/META-INF</code>: Your manifest</li> <li><code>${basedir}/web/WEB-INF</code>: Your web.xml files</li> </ul> <h3>Set up</h3> <p>Define a <code>setup</code> task that creates the distribution directory and copies any artifacts that need to be WARred directly:</p> <pre><code>&lt;target name="setup"&gt; &lt;mkdir dir="dist" /&gt; &lt;echo&gt;Copying web into dist&lt;/echo&gt; &lt;copydir dest="dist/web" src="web" /&gt; &lt;copydir dest="dist/web/WEB-INF/lib" src="${basedir}/../web/WEB-INF/lib" /&gt; &lt;/target&gt; </code></pre> <h3>Compile</h3> <p>Build your Java files into classes and copy over any non-Java artifacts that reside under <code>src</code> but need to be available at runtime (e.g. properties, XML files, etc.):</p> <pre><code>&lt;target name="compile"&gt; &lt;delete dir="${dist.dir}/web/WEB-INF/classes" /&gt; &lt;mkdir dir="${dist.dir}/web/WEB-INF/classes" /&gt; &lt;javac destdir="${dist.dir}/web/WEB-INF/classes" srcdir="src"&gt; &lt;classpath&gt; &lt;fileset dir="${basedir}/../web/WEB-INF/lib"&gt; &lt;include name="*" /&gt; &lt;/fileset&gt; &lt;/classpath&gt; &lt;/javac&gt; &lt;copy todir="${dist.dir}/web/WEB-INF/classes"&gt; &lt;fileset dir="src"&gt; &lt;include name="**/*.properties" /&gt; &lt;include name="**/*.xml" /&gt; &lt;/fileset&gt; &lt;/copy&gt; &lt;/target&gt; </code></pre> <h3>Build WAR</h3> <p>Create the WAR itself:</p> <pre><code>&lt;target name="buildwar"&gt; &lt;war basedir="${basedir}/dist/web" destfile="My.war" webxml="${basedir}/dist/web/WEB-INF/web.xml"&gt; &lt;exclude name="WEB-INF/**" /&gt; &lt;webinf dir="${basedir}/dist/web/WEB-INF/"&gt; &lt;include name="**/*.jar" /&gt; &lt;/webinf&gt; &lt;/war&gt; &lt;/target&gt; </code></pre> <h3>Deploy</h3> <p>Finally, you can set up a task to deploy the WAR directly into your Tomcat deploy location:</p> <pre><code>&lt;target name="deploy"&gt; &lt;copy file="My.war" todir="${tomcat.deploydir}" /&gt; &lt;/target&gt; </code></pre> <h3>Click and go!</h3> <p>Once all this is set up, simply launching the <code>default</code> target from Eclipse will compile, WAR, and deploy your solution.</p> <p>The advantage of this approach is that it will work outside Eclipse as well as within Eclipse and can be used to easily share your deployment strategy (e.g. via source control) with other developers who are also working on your project.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload