Using Apache Ivy with netbeans
Asked Answered
D

3

1

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.

Dime answered 23/7, 2012 at 12:29 Comment(1)
What's the problem using the netbeans plugin for ivy?Nellenelli
L
1

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>
Lykins answered 23/7, 2012 at 17:39 Comment(1)
Netbeans has an ant build.xml which imports another ant file which is generated by the IDE, it also generates a project.properties file where it keeps the compile class path set from the interface and other settings of the project.Dime
L
0

Maybe you could try http://code.google.com/p/ivybeans/

Lesko answered 23/8, 2012 at 17:45 Comment(0)
K
0

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://code.google.com/p/ivybeans/source/browse/trunk/ivybeans/ivy-module/src/com/googlecode/ivybeans/module/resources/ivy-impl_.xml

Khorma answered 25/3, 2013 at 8:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.