将 Apache Ivy 与 netbeans 结合使用 [英] Using Apache Ivy with netbeans

查看:24
本文介绍了将 Apache Ivy 与 netbeans 结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 netbeans 开发的现有项目,我想在该项目中集成 Apache Ivy.我更新了由 netbeans 生成的 build.xml 以下载 ivy(如果需要)并使用它来检索依赖项.

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.

如果可能的话,我更愿意在不使用 netbeans 插件的情况下执行此操作.如果没有,你会推荐使用什么插件.

I would prefer to do this without using a netbeans plugin if this is possible. If not, what plugin would you recommend using.

如果有任何相关性,我现在也在-pre-init"目标中执行此操作.

Also I am doint this in the "-pre-init" target right now, if it is of any relevance.

推荐答案

很遗憾我不熟悉 netbeans 的配置文件.

Unfortunately I'm not familiar with netbeans' configuration file.

以下是我用来生成 Eclipse 元数据文件的集成目标:

The following is an integration target I used to generate Eclipse metadata files:

  • .classpath
  • .project

也许你可以适应它.

<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>

这篇关于将 Apache Ivy 与 netbeans 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆