简体   繁体   English

Gradle Eclipse插件在生成的.classpath文件中不包括exported =“true”

[英]Gradle Eclipse Plugin not including exported=“true” in generated .classpath file

I'm trying to update my Gradle version from 2.3 to 2.12. 我正在尝试将我的Gradle版本从2.3更新到2.12。 When I run the "eclipse" task to generate the eclipse files I'm running into an issue when using the new version (2.12). 当我运行“eclipse”任务来生成eclipse文件时,我在使用新版本时遇到了问题(2.12)。

The classpathentry nodes generated in the .classpath file no longer contain the exported="true" attribute which is necessary to create a working run target in eclipse. 在.classpath文件中生成的classpathentry节点不再包含export =“ true”属性,该属性对于在Eclipse中创建工作运行目标是必需的。

With version 2.3 与版本2.3

<classpathentry 
sourcepath="/../some-lib-sources.jar" kind="lib" path="/../some-lib.jar"
exported="true"/>

With version 2.12 (exported="true" is missing) 版本2.12(缺少exports =“true”)

<classpathentry 
sourcepath="/../some-lib-sources.jar" kind="lib" path="/../some-lib.jar"/>

I couldn't find anything helpful about this issue in the Gradle documentation. 我在Gradle文档中找不到关于此问题的任何帮助。 I'm hoping this is just a simple configuration change. 我希望这只是一个简单的配置更改。

Does anyone know how to fix this issues? 有谁知道如何解决此问题?

Update: 更新:

So I found the change that I think is causing this issue in the 2.5 release notes 因此,我在2.5版本说明中找到了我认为引起此问题的更改

Changes in IDE classpath generation ... All dependencies in projects are marked as exported = false. IDE类路径生成中的更改...项目中的所有依赖项都标记为export = false。

.. But I still haven't be able to find any information on how to control what classpathentries get the exported=true attribute. ..但我仍然无法找到有关如何控制classpathentries获取exported = true属性的任何信息。

Allowing a build and dependency management tool to manage IDE-specific files is, in my opinion, a fundamental mistake. 在我看来,允许构建和依赖管理工具来管理特定于IDE的文件是一个根本性的错误。 See my explanation in this answer . 这个答案中看到我的解释。

Instead, install Buildship and use it to import your Gradle-based project into Eclipse. 而是安装Buildship并将其用于将基于Gradle的项目导入Eclipse。 Let Eclipse plug-ins do Eclipse stuff and build tools do builds. 让Eclipse插件完成Eclipse的工作,让构建工具完成构建。

I ended up fixing this issue by adding the following whenMerged code. 通过添加以下whenMerged代码,最终解决了此问题。

eclipse {
  classpath {
    defaultOutputDir = file('classes')

      file {                
        whenMerged { classpath ->
          classpath.entries.findAll { entry -> entry.kind == 'lib' }*.exported = true                    
      }

    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM