如何通过gradle在Eclipse项目中添加对类路径的具体引用?

Gan*_*nus 1 eclipse gradle gradle-eclipse eclipse-classpath build.gradle

我在文档中看到的所有说明如何通过 build.gradle 文件向 Eclipse 项目类路径添加条目的示例都太常见了。他们没有说如何添加条目:

<classpathentry exported="true", kind="con" path="GROOVY_SUPPORT"/>
Run Code Online (Sandbox Code Playgroud)

Doc或“Gradle Effective Implementation Guide”一书对于建议毫无用处

  //closure executed after .classpath content is loaded from existing file
  //and after gradle build information is merged
  whenMerged { classpath ->
    //you can tinker with the Classpath here
  }
Run Code Online (Sandbox Code Playgroud)

Ben*_*hko 5

您可以通过创建org.gradle.plugins.ide.eclipse.model.Container的实例来添加另一个类路径条目:

eclipse {
    classpath {
        file {
            whenMerged { classpath ->
                def groovySupportContainer = new org.gradle.plugins.ide.eclipse.model.Container('GROOVY_SUPPORT')
                groovySupportContainer.exported = true
                classpath.entries << groovySupportContainer
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)