When I create a new project in Netbeans, it generates a build.xml file which it will use to compile and run the project, along with other stuff in folder nbproject.
Now, I want to have my very own build.xml file that I will use to compile to project on the server side. Some guys have tried to use the generated build file both in Netbeans and with pure Ant, but it's more trouble than it's worth.
I want to rename the auto-generated file to nb-build.xml
and have my own build.xml file that Netbeans will not touch.
How do I achieve that ?
Go into the nbproject
directory in your project directory, and edit the file project.properties
. Look for the section that looks like this:
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
and add the line:
buildfile=nb-build.xml
When you next open the project in NetBeans, it will create a new file of this name, and start ignoring the existing build.xml file.
We solved this problem this way. Assume your own Ant build script is called "myBuild.xml" and is placed in the same folder as build.xml - Open your build.xml file and replace its contents to:
<?xml version="1.0" encoding="UTF-8"?>
<project name="payroll_web_ice_jq" default="default" basedir=".">
<condition property="import.path" value="myBuild.xml">
<not><isset property="netbeans.user"/></not>
</condition>
<condition property="import.path" value="nbproject/build-impl.xml">
<isset property="netbeans.user"/>
</condition>
<!-- conditional import. If triggered from NetBeans, use old build script
if triggered from shell, user new build script -->
<import file="${import.path}" />
</project>
As you can see, we check for the existence of the "netbeans.user" property that only should exist within Netbeans and not on the command line. This works for us.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With