How to generate build file for project in Netbeans - netbeans

I know eclipse can automatically create a build file for a given project through its inbuilt wizard (Export->General->Ant File).
But wondering how to do the same if my project is in Netbeans.
Does NetBeans also provide a similar wizard screen to create build file. If not, any other way around.?

NetBeans uses Ant as its build system. Ant build script is already there (unless you used Maven project type).
Some related questions are linked in How do I build ant's build.xml using NetBeans?

I could not find to create build file from Netbeans. But found a workaround, by creating a build for my project in eclipse and then modifying it to suit to netbeans project structure.

Related

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.

cmake, add_subdirectory without adding it to the generated project file?

I have a project that is build with cmake. In my cmakelists I have a
add_subdirectory(externals/foo)
to build the dependency "foo" which has it's own cmakelists.
Now it is so that also the whole foo sources and headers are included in the generated Project file (I'm using Eclipse). But all I want is to only have my project available in Eclipse (Eclipse has problems with subprojects in the same folder structure).
So that the cmakelists from "foo" is only used to build "foo" automatically and link it to my project. I don't want to see it in my IDE however.
Is this possible? If yes: How?
When I use Eclipse with CMake, I create the Eclipse project manually (with the New Project wizard) and for CMake I use the standard makefile generator. It requires a little extra setup: you need to set the build directory in the project properties if you're doing an out-of-source build, and I usually set the build command to make VERBOSE=1.
I'm not sure since I haven't used the Eclipse generator(s), but for the lack of a better solution, perhaps this method would solve your issue, since it gives you more control over the Eclipse project.
No, how should the ide know what to compile if you don't tell it what to compile? If you don't want to have the project in you project file, just don't add it.
Just compile the external lib by itself (use "cmake externals/foo") and then add the libraries in your project's CMakeLists.txt with
target_link_libraries(your_project externals/foo/bin/foo.lib)

NetBeans -- Is it possible to bypass the IDE-generated Ant build for an existing project?

I have a Java project with sub-projects that is currently built using NetBeans's IDE-generated Ant scripts. I am converting the entire project to a Maven build.
My Maven build works fine from the command line and loads perfectly in Eclipse. However, the only way I can get the project to load as a Maven project in NetBeans is to delete the Ant scripts, i.e. build.xml and the directory nbproject for each sub-project. It seems that as long as I have the old IDE-generated build files, NetBeans recognizes the project as a NetBeans Java project only, not as a Maven Java project, even though there is also a pom.xml file present.
Short of deleting the IDE-generated build files, is there any way to tell NetBeans to load the project as a Maven project?
I have been told that we want to keep the Ant build for a while during the transition to Maven.
Using NetBeans 6.9.1, Maven 2.2.
Any help would be appreciated.
Thanks
Well, the nb ant project metadata has precedence over occurence of pom.xml file (that's how maven projects are recognized and loaded). The whole precedence order hardwired in the IDE, you could only influence it be uninstalling the j2se ant project type for example.
So, yes. You need to get rid of the ant project metadata before you can open the project as maven project. Depending on how and when you delete the metadata, you might need to restart the IDE as well to get the new stuff loaded.
Have you seen http://wiki.netbeans.org/MavenBestPractices? It indicates that you must install the NetBeans maven plugin first. Perhaps that's why your Maven projects aren't recognized.
I must note that I'm not a NetBeans user anymore!
Here is what I ended up doing:
I wrote an Ant script (ironic, huh?) that, for every subproject of my project, renames the file nbproject/project.xml if it exists to nbproject/nb_project_disabled.xml. If nbproject/nb_project_disabled.xml exists instead, the script renames it back to nbproject/project.xml. In this way, the script toggles the opening of the project as a NetBeans Ant build or as a Maven build.
It would be nice if NetBeans, you know, had a setting to open both kinds of projects. Currently (6.9.1), there is just the "Open Project" command. In Eclipse, there is the command "Import Existing Maven Projects" vs. "Import Existing Project Into Workspace" (i.e. native Eclipse format).

Build eclipse project with ant

I am developing JSR 268 compliant portlet and utility with eclipse.
Now, the utility is designed to be a separate JAR from the portlet itself.
Does anyone now how to write an ant build.xml that will
1. Compile and JAR my utility class
2. Move the JAR to the ./lib folder of the portlet
3. Compile and maybe even delpoy the portlet to a tomcat running on localhost?
My biggest problem right now are the build-time dependencies. I dont want to hardcode all the folders as I share this project with two other developers which are on another platform.
Is it possible to reuse the buildpath from eclipse?
Thank you in advance,
Felipe
Does this wizard help
Rigth-click on project -> Export ... -> Ant buildfiles.
?
Though you probably have figured something out by now, for future references I would suggest taking a look at Eclipse's ability to use Ant files as project builders.
An advantage of this is, that will happen automatically as you build and since you only pack and copy the jar file, you don't have to worry about changes in e.g. the class paths, as you would in the two previous answers
Create a ant file that jar the utility project. Follow: [1]
Add it as a ant-builder to your utility project as described in [1]
Now Eclipse will automatically generate the jar file every time you build.
Extend the ant script to also copy to jar file to the lib dir.
Eclipse have ant task to convert workspace/project relative paths to
normal file paths. See [2]. Note that for those tasks to work, you must select ''Run is the same JRE as the workspace'' under the ''JRE'' tab when configuring the ant builder
In order to ensure your utility is build first add a project reference from your portlet to your utility project right click > properties > project references
When you build the following will now happen:
You utility project will build first, because of the project reference
The ant-builder will pack the jar, and copy it to the lib folder.
You portlet project will build using the new jar.
[1] http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2FgettingStarted%2Fqs-92_project_builders.htm
[2] http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/ant_eclipse_tasks.htm
For 1. Just use the and Ant tasks
For 2. Is it on a remote server? How do you get it there? Windows share?
For 3. Set up the Tomcat manager and then use Tomcat's deploy/undeploy Ant tasks:
http://blog.techstacks.com/2009/05/tomcat-management-setting-up-tomcat.html
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask" />
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask" />
If you want to avoid hard-coding paths, try to use relative paths. Where are you dependencies right now? What do you feel you may have to specify an absolute path for?
In Eclipse,
Goto Window->preference->Ant->Runtime->Classpath->ant Home
Then add what are the thing u need to add,atlast click ok button to create ant file.

How can I reference ANT HOME from the libraries in the properties of a project when using eclipse?

In our code base we have a dependency on the ant version used in eclipse.
In the the ant.jar has been set up as a library which the project uses
This is a pain when moving versions of eclipse as the Ant plugin folder name changes (although I see it is now just called Ant1.7)
Is there a way to access eclipses reference to ANT Home which appears in the workspace preferences so that I don't have to explicitly set a variable that has the hard coded path to the ant plugins folder
Your project should not have a dependency on eclipse's version of Ant in the first place, you should keep your own version so as to decouple your project from eclipse. What if a developer or yourself decides to use intelliJ?
Although i don't know what the nature of your project is, i would have thought all dependencies should be added to your projects lib directory or something similar.
One possible suggestion would be to :
transform your project into a plugin project (properties on your project / PDE tools / convert Project to Plug-in Projects...) and
add to its dependencies the 'ant' required plugin.
That would be easier to manage when you change the version of eclipse.
Have you considered installing Ant separately, creating an environment variable, and then referencing the location via the ANT_HOME environment variable within your Ant build.xml?
From within your eclipse, on the package explorer view, right click on the specific project and build path.
Move into the Libraries tab and select the "Add Variable..." button. From here you'll see that is where the JDK system libraries path, maven(if you're using it, tomcat, eetc...) If ANT_HOME doesn't appear, you can add it by clicking the Configure Variables... button. From this moment, the ANT_HOME path will be considered in the build path of the project.
Hope it helps.
Carlos
Your ant home is available in the property ${ant.home}
E.g:
<echo> ${ant.home} </echo>
Gives the following on my machine:
[echo] D:\java\eclipse_3.4_jee\plugins\org.apache.ant_1.7.0.v200803061910