首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Eclipse Gradle项目中的依赖项突然丢失

Eclipse Gradle项目中的依赖项突然丢失
EN

Stack Overflow用户
提问于 2018-05-26 19:39:37
回答 2查看 1.5K关注 0票数 2

我正在使用Java8和Gradle包装器4.6在Eclipse Oxygen中处理一个Gradle项目。

当我尝试添加一个新的依赖项compile 'com.googlecode.json-simple:json-simple:1.1.1'并刷新项目时,所有的“项目和外部依赖项”文件夹都消失了,没有任何痕迹,这将停止我的项目在Eclipse中运行(它可以通过Gradle run任务运行)。

删除新添加的依赖项并不能拯救我。既不是gradlew cleanEclipse & gradlew eclipse,也不是刷新项目无数次。

我还试图在重新导入时清除缓存并强制项目重建,但没有显示"Project and External Dependencies“。

我应该怎么做才能恢复旧的依赖关系?

这是我的build.gradle

代码语言:javascript
运行
复制
// Apply the java plugin to add support for Java
apply plugin: 'java'
// Apply the plugin to be runnable
apply plugin: 'application'
// Apply the eclipse plugin to import project on other machines
apply plugin: 'eclipse'
// JUnit 5
apply plugin: 'org.junit.platform.gradle.plugin'

// Define the entry point
mainClassName = 'meshIneBits.MeshIneBitsMain'
applicationName = 'MeshIneBits'

// In this section you declare where to find the dependencies of your project
repositories {
    // Use 'jcenter' for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

sourceCompatibility = 1.8

// In this section you declare the dependencies for your production and test code
dependencies {
    compile 'org.processing:core:3.3.5'
    compile 'org.jogamp.jogl:jogl-all:2.3.2'
    compile 'org.jogamp.gluegen:gluegen-rt:2.3.2'

    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-linux-amd64"
    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-linux-armv6"
    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-linux-armv6hf"
    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-linux-i586"
    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-macosx-universal"
    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-windows-amd64"
    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-windows-i586"

    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-linux-amd64"
    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-linux-armv6"
    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-linux-armv6hf"
    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-linux-i586"
    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-macosx-universal"
    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-solaris-i586"
    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-windows-amd64"
    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-windows-i586"

    testCompile('org.junit.jupiter:junit-jupiter-api:5.1.0',
            'org.junit.jupiter:junit-jupiter-params:5.1.0')
    testRuntime('org.junit.jupiter:junit-jupiter-engine:5.1.0',
            'org.junit.platform:junit-platform-launcher:1.1.0')
}

eclipse {
    project.natures 'org.eclipse.buildship.core.gradleprojectnature'
    classpath {
        file {
            defaultOutputDir = file('bin/main')
            whenMerged {
                //change output folder for tests
                def testsrc = entries.find { it.path == 'src/test/java' }
                testsrc.output = "bin/test"

                def testres = entries.find { it.path == 'src/test/resources' }
                testres.output = "bin/test"

                // Remove local ref for libs
                entries.removeAll{ it.kind == "lib" }
            }
            containers 'org.eclipse.jdt.junit.JUNIT_CONTAINER/5', 'org.eclipse.buildship.core.gradleclasspathcontainer' }
    }
}

buildscript {
    repositories { mavenCentral() }
    dependencies { classpath 'org.junit.platform:junit-platform-gradle-plugin:1.1.0' }
}

jar {
    baseName = applicationName
    version = '0.2.0'
    manifest { attributes  'Main-Class' : mainClassName }
}

编辑:切换到IntelliJ后,问题解决了(我使用了和项目相同的文件夹)。所以我认为这是Eclipse中的一个问题。

EN

回答 2

Stack Overflow用户

发布于 2019-11-09 05:25:52

我也有这个问题,"Project and External Dependencies“文件夹消失了。而是显示为'org.eclipse.buildship.core.gradleclasspathcontainer'.

如果您没有看到该行,则需要将其添加到.classpath文件中。

代码语言:javascript
运行
复制
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer" />

对我起作用的修复方法是关闭Eclipse,然后运行

代码语言:javascript
运行
复制
gradlew cleanEclipse eclipse

然后打开Eclipse并将Gradle性质添加到项目中。

票数 1
EN

Stack Overflow用户

发布于 2020-05-04 10:19:06

我在重构项目名称时也遇到了这个问题。

以下步骤解决了我的问题:

单击[

  1. ][add eclipse plugin to ]单击[ build.gradle ],选择[ gradle ],然后选择[ refresh gradle project

只是refresh gradle project帮不了我。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50542347

复制
相关文章

相似问题

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