首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Buildship一直覆盖.classpath

Buildship一直覆盖.classpath
EN

Stack Overflow用户
提问于 2018-03-02 12:09:39
回答 2查看 1.5K关注 0票数 3

我正在使用Gradle和Eclipse与Buildship插件。

Buildship为Eclipse创建要使用的.classpath文件。由于类加载的原因,我需要一个类路径条目(com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER)出现在org.eclipse.buildship.core.gradleclasspathcontainer条目之后。

因此,我的.classpath文件的相关部分应该如下所示( GWT_CONTAINER位于底部)。

代码语言:javascript
复制
<classpath>
 <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
 <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer" />
 <classpathentry kind="con" path="com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER"/>
</classpath>

Buildship总是在最后一个位置有gradleclasspathcontainer。因此,我试图在我的build.gradle (摘录)中这样更改排序:

代码语言:javascript
复制
eclipse {
    classpath { 
        file {
            beforeMerged { classpath ->
                def gwtClasspath = classpath.entries.find { entry -> entry.path == 'com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER' }
                classpath.entries.remove gwtClasspath
                classpath.entries << gwtClasspath
            }
        }
    }

使用./gradlew eclipseClasspath时,将正确创建.classpath文件。但是,一旦Buildship运行,文件就会再次被错误的顺序覆盖。

我也尝试使用whenMerged而不是beforeMerged,但这并没有改变任何事情。

下面是由Buildship启动的Gradle输出(例如,单击Eclipse属性上的Gradle ->刷新):

代码语言:javascript
复制
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.5/userguide/command_line_interface.html#sec:command_line_warnings

CONFIGURE SUCCESSFUL in 0s
:cleanEclipseWtpComponent
:cleanEclipseWtpFacet
:cleanEclipseWtp
:eclipseWtpComponent
:eclipseWtpFacet
:eclipseWtp

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 0s
4 actionable tasks: 4 executed

看起来Buildship甚至没有执行eclipseClasspath任务,但是确实通过其他方式创建了.classpath文件。

我怎样才能得到建设,以履行我的愿望,使类路径排序我的方式?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-03-19 17:55:54

我找到了分级论坛的解决方案

Buildship不使用eclipseClasspath任务,而是通过自己的方式读取配置并创建.classpath。如果尚未定义Gradle类路径,则将其追加到类路径的末尾。这是在执行whenMerged部分之后发生的。因此,解决方案是手动添加Gradle类路径:

代码语言:javascript
复制
eclipse {
   classpath {
        containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
   }
}
票数 2
EN

Stack Overflow用户

发布于 2018-03-02 13:26:30

也许withXml钩子的工作方式会有所不同

代码语言:javascript
复制
eclipse.classpath.file {
    withXml { provider ->
        def entry = provider.asNode().classpath.classpathentry.find { it.path == 'com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER' }
        println "Found $entry"
        def parent = entry.parent()
        parent.remove(entry)
        parent.append(entry)
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49068870

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档