2016-09-07 117 views
2

我在Eclipse中为.classpath文件添加了一个类路径条目,以避免在每次运行.eclipse任务时手动添加它,同时添加一些依赖项。我需要一些资源在本地运行。Eclipse Gradle添加类路径条目

这个作品,

eclipse.classpath.file { 
    withXml { 
    def node = it.asNode() 
    node.appendNode('classpathentry', 
       [kind: 'lib', path: '/some/path']) 
      } 
} 

这不,

eclipse.classpath.file { 
    whenMerged { classpath -> 
     classpath.entries.add { entry -> kind: 'lib', path: '/some/path' } 
       } 
} 

我得到的是错误,

启动失败:的build.gradle':75:意外标记:lib @第75行,第48列。 .entries.add {entry - > kind:'lib',pat ^

为了将来的参考,第二个例子有什么问题?

回答

0

等效应该是这样的:

eclipse.classpath.file { 
    whenMerged { classpath -> 
    def lib = new org.gradle.plugins.ide.eclipse.model.Library(fileReference(file('path/to/my/jar))) 
    lib.exported = true 
    classpath.entries << lib 
    } 
} 

见摇篮文档为Library及其接口ClasspathEntry

相关问题