How do I create a WAR file using NetBeans' generated ant script? - netbeans

I'm trying to configure an automated build process, and I need to get a WAR file to deploy to Tomcat. The project was created in Netbeans, which automatically generates an ant script. I think when I click "Clean and Build Project" from the menu it runs a series of ant targets and generates the WAR that I need. So does anyone know which ant targets Netbeans runs when you click "Clean and Build Project". My theory is that I can just run the same targets on my own. Does that make sense or is there a better way to do it? Thanks.

You can run the 'dist' target to generate the war file that you can distribute to Tomcat. If you ant to do the equivalent of 'Clean and Build', you can run 'ant clean dist'.

Related

Where are the eclipse product build scripts stored?

i'm exporting an eclipse product with the eclipse Product export wizard. when i run this wizard a lot of build scripts are generated and executed - i want to re-use these build scripts for my p2e-build. where does eclipse store these build scripts?
The files for the build are created in the root folder of the project containing the xxx.product file you are using. They only exist while the build is running. The main file is a build.xml Ant script.

Ant build and deploy application is OK, how to debug application?

Ant help us to build and deploy applications, but how to debug application in the Application server?
Could you please help me to debug the EAR file created with Ant build?
(I have imported the EAR file in to Eclipse to debug using Eclipse, I am able to run the project successfully, but when I start debug after setting a breakpoint it reports as Source not found, please help me to resolve this issue)
You have to not only "import" your EAR file (containing compiled bytecode) but also your source code files. If you import the EAR as a "referenced library" you may edit the library with alt-enter, and add the path/jar of the sources.
How do you start & publish in eclipse anyways?

Run Ant files when performing Build and Deploy Worklight 5.x.x Application

I have a Worklight application set up in Eclipse. Before executing Build And Deploy Worklight Application, I need to run a bat that compiles a bunch of HTML templates. This templates are necessary to run the app correctly.
So, I would like to know if it is possible to link (maybe under Run Configurations...?) an Ant file or similar that allows me to execute the bat and perform the build & deploy in an automatic way. Any advice?
Hope the question is clear.
I believe you can add an extra project builder to your application that invokes the Ant task you need.
Under Eclipse take a look at Project->Properties->Builders->New.
You will find Ant buildfiles as project builders a useful link.

Automatic Build for Non-Java Eclipse Project

I have a project that contains xml files. I also have an Ant build in that project to generate documentation based on the xml files. The Ant build calls a Ruby script for generation.
I would like a way run that Ant build after the modification of any resource in the "{project}/xml" folder. I know that I can right click on the build.xml and Run As->Ant Build, but I want it to be more like the incremental build for Java projects. I have tried creating a builder, importing the Ant build and setting up relevant resources, but when I make a change to the XML file, a build does not start. I have "Build Automatically" checked for the project as well.
This must be possible. What am I missing?
A custom builder will only run when a file is saved that is in a source directory. Make sure the /xml folder is included as a source location in the Project Properties, Java Build Path.

I need Eclipse to deploy the WAR file my ANT script builds, not what it builds internally

I'm using Eclipse Helios. I have a dynamic web project going and I've set up Eclipse to use an Ant Builder to generate a WAR file. This all works fine; if I change a .java file, Eclipse automatically runs my build.xml via Ant and updates my WAR. If I deploy the WAR to an external instance of Tomcat, it works perfectly.
However, when I tell Eclipse to run my project under Tomcat, it is not using the WAR file generated by the Ant build, or using my Ant script to generate a temporary WAR.
I know this because my build.xml script includes some additional XML configuration files in WEB-INF/classes in the WAR that are not ending up in the WEB-INF/classes dir that Eclipse pushes out.
I can't seem to find anything within Eclipse that says "when you publish, use this WAR file instead of building your own".
An alternate approach would be to tell Tomcat when it is building a WAR to do so by adding a list of files, but I can't seem to find a way to do that either.
I'm also curious how Eclipse knows what to publish since it is obviously ignoring my build.xml and my previously-generated WAR file.
Eclipse deploys a web application by looking at the Web Deployment Assembly options for your project. You can see this by right-clicking the project, choosing Properties, and then click on Deployment Assembly. Eclipse usually uses an expanded directory deployment here rather than creating and deploying a WAR (this is based on the server plugin being used, but I think most of them use an expanded directory structure for speed). If you export as a WAR it will create a WAR with the same content.
There are two main choices to do what you'd like:
Modify the Web Deployment Assembly options to match exactly what you would like in the deployed app
Don't use Eclipse's deployment; add an "External Ant Builder" to the "Builders" options for your project (right-click project, choose Properties->Builders). You can then select which targets in the ant file you want to use when eclipse builds the project. One of these options can be a deployment step
I can't seem to find anything within Eclipse that says "when you publish, use this WAR file instead of building your own".
I'm an IntelliJ user, so take this with a grain of salt. But...
Right-click on the Project Explorer target/foo.war, select Mark Deployable.
Then right-click on the foo.war file again and Run As... -> Run On Server...
Choose the JBoss instance.
If you go to the Servers view, you'll now see your WAR file under the JBoss instance as /proj_root/target/foo.war
Oh Eclipse, sigh...