Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make Netbeans 6.5 use my file nb-build.xml instead of build.xml?

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 ?

like image 424
Leonel Avatar asked Dec 08 '22 07:12

Leonel


2 Answers

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.

like image 78
Karl von L Avatar answered Apr 29 '23 11:04

Karl von L


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.

like image 36
PålOliver Avatar answered Apr 29 '23 11:04

PålOliver