2012-07-23 65 views
1

我有一個使用NetBeans開發的現有項目,我想將Apache Ivy集成到項目中。我更新了由netbeans生成的build.xml以下載ivy(如果需要)並使用它來檢索依賴關係。使用Apache Ivy和netbeans

有沒有人知道我可以如何將下載的依賴項添加到項目的構建路徑中,這樣它就可以編譯好了,也可以在界面中顯示缺少的庫錯誤。

如果可以的話,我寧願不使用netbeans插件來做到這一點。如果不是,你會推薦使用哪個插件。

編輯:此外,我現在在「-pre-init」目標中是doint,如果它有任何相關性的話。

+0

netbeans插件用於ivy有什麼問題? – 2012-07-23 17:34:27

回答

1

不幸的是,我不熟悉netbeans的配置文件。

下面是一個整合的目標我用來生成的Eclipse元數據文件:

  • 的.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> 
+0

Netbeans有一個ant build.xml,它導入由IDE生成的另一個ant文件,它還生成一個project.properties文件,在該文件中保存從接口和項目的其他設置中設置的編譯類路徑。 – Razvi 2012-07-24 08:08:07