I have an existing project that is developed using netbeans, and I would like to integrate Apache Ivy in the project. I updated the build.xml generated by netbeans to download ivy (if necesarry) and use it to retrieve the dependencies.
Does anyone know how I can add the downloaded dependencies to the build path of the project, such that it will compile okay and also so that it doesn't show missing libraries errors in the interface.
I would prefer to do this without using a netbeans plugin if this is possible. If not, what plugin would you recommend using.
EDIT: Also I am doint this in the "-pre-init" target right now, if it is of any relevance.
Unfortunately I'm not familiar with netbeans' configuration file.
The following is an integration target I used to generate Eclipse metadata files:
- .classpath
- .project
Perhaps you could adapt it.
<target name="eclipse">
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<ivy:cachefileset setid="libfiles" conf="compile"/>
<groovy>
<arg value="${src.dir}"/>
<arg value="${build.dir}/classes"/>
import groovy.xml.MarkupBuilder
//
// Generate the project file
//
project.log("Creating .project")
new File(".project").withWriter { writer ->
def xml = new MarkupBuilder(writer)
xml.projectDescription() {
name(project.name)
comment()
projects()
buildSpec() {
buildCommand() {
name("org.eclipse.jdt.core.javabuilder")
arguments()
}
}
natures() {
nature("org.eclipse.jdt.core.javanature")
}
}
}
//
// Generate the classpath file
//
// The "lib" classpathentry fields are populated using the ivy artifact report
//
project.log("Creating .classpath")
new File(".classpath").withWriter { writer ->
def xml = new MarkupBuilder(writer)
xml.classpath() {
classpathentry(kind:"src", path:args[0])
classpathentry(kind:"output", path:args[1])
classpathentry(kind:"con", path:"org.eclipse.jdt.launching.JRE_CONTAINER")
project.references.libfiles.each {
classpathentry(kind:"lib", path:it)
}
}
}
</groovy>
</target>
Maybe you could try http://code.google.com/p/ivybeans/
If you don't want to use the ivybeans plugin maybe you can inspire yourself of the different ant task generated by the plugin :
来源:https://stackoverflow.com/questions/11612549/using-apache-ivy-with-netbeans