How can I automate (script) the creation of a war file in eclipse?

He presses 5 buttons to get an eclipse to create a deployed war file for my eclipse project. I suppose there may be an eclipse command line option to do the same, so I can just write it in a script, but I'm not seeing this.

+6
eclipse war
source share
5 answers

Use the Ant war task , configure the appropriate build file, and you can simply click the "external tools" button to execute it.

+3
source share

You can also customize the Maven build for your web project. After that, type the mvn package from the command line to create the project.

For integration between Maven and Eclipse, see m2Eclipse and the Maven Eclipse Plugin .

+2
source share

I can’t say anything about the WAR packaging itself, sorry.

But as I wrote in How to automatically export a WAR after building Java in Eclipse? : If you can describe the WAR packaging using an Ant script, you can execute the Ant script automatically after every change to your project. Use Project-> Properties-> Builders-> Add β†’ Ant Builder. Give this builder a custom Ant script and it will be automatically executed after the "normal" developers of your project. You can even specify in the linker settings if it will only respond to changes to certain files, etc.

Ant's constructor is a kind of Swiss army knife for everything you want to automate in building a project, without using large tools like maven.

+1
source share

This question has been asked several different solutions in this thread .

0
source share

This Ant script should work for the standard Dynamic Web Project project structure:

Create Ant build.xml with the replacement of two properties at the beginning:

 <?xml version="1.0" encoding="UTF-8"?> <project name="Deploy From Eclipse to JBoss" basedir="." default="deploy"> <!-- This replace with yours project name and JBoss location: --> <property name="warfile" value="MyProject"/> <property name="deploy" value="/home/honza/jboss-as-7.1.1.Final/standalone/deployments"/> <target name="create"> <war destfile="${warfile}.war" webxml="WebContent/WEB-INF/web.xml" update="true"> <classes dir="build\classes"/> <fileset dir="WebContent"> <exclude name="WEB-INF/web.xml"/> </fileset> </war> </target> <target name="copy"> <copy todir="${deploy}" overwrite="true"> <fileset dir="."> <include name="${warfile}.war"/> </fileset> </copy> </target> <target name="clear"> <delete includeemptydirs="true"> <fileset dir="${deploy}" defaultexcludes="false"> <include name="${warfile}.*/**" /> </fileset> </delete> </target> <target name="deploy"> <antcall target="create"/> <antcall target="clear"/> <antcall target="copy"/> </target> </project> 

Now you need to command "ant" to create a WAR and copy them to JBoss. JBoss automatically deploys wars that are in the deployment directory.

To start automatically after build (Project-Build) add this build file here:

 MyProject - Properties - New - Ant builder 
0
source share

All Articles