[英]Sudden loss of dependencies in Eclipse Gradle project
我正在使用 Java 8 和 Gradle 包裝器 4.6 在 Eclipse Oxygen 中處理 Gradle 項目。
當我嘗試添加新的依賴項compile 'com.googlecode.json-simple:json-simple:1.1.1'
並刷新項目時,所有“項目和外部依賴項”文件夾都消失得無影無蹤,這使我的項目停止運行來自 Eclipse(雖然它可以通過 Gradle Run 任務運行)。
刪除新添加的依賴項並不能拯救我。 gradlew cleanEclipse & gradlew eclipse
沒有刷新項目無數次。
我還嘗試在重新導入時清除緩存並強制項目重建,但沒有顯示“項目和外部依賴項”。
我應該怎么做才能恢復舊的依賴項?
這是我的build.gradle
// 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 中的一個問題。
我也遇到了“項目和外部依賴項”文件夾消失的問題。 它顯示為“org.eclipse.buildship.core.gradleclasspathcontainer”。
如果您沒有看到該行,則需要將其添加到 .classpath 文件中。
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer" />
對我有用的修復是關閉 Eclipse,然后運行
gradlew cleanEclipse eclipse
然后打開 Eclipse 並將 Gradle 性質添加到項目中。
我在重構項目名稱的時候也遇到過這個問題。
以下步驟解決了我的問題:
eclipse
插件添加到build.gradle
build.gradle
,選擇gradle
然后選擇refresh gradle project
只有refresh gradle project
對我沒有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.