2017-11-26 58 views
5

मैं ग्रहण ऑक्सीजन के अंदर अपने ग्रेडल प्रोजेक्ट पर जावा 9 का उपयोग करना चाहता हूं। जब मैं चलाएँ:gradle java9 प्लेटफ़ॉर्म को लक्षित नहीं किया जा सका: टूल श्रृंखला का उपयोग करके 'जावा एसई 9': 'जेडीके 8 (1.8)'

Run as> Gradle Test on GreeterTest.java 

निम्न कोड के साथ:

package hello.test; 

import static org.junit.jupiter.api.Assertions.*;  
import org.junit.jupiter.api.Test;  
import hello.Greeter; 

class GreeterTest { 

    @Test 
    void test() { 
     Greeter greeter = new Greeter(); 
     assertEquals("Hello world", greeter.sayHello()); 
    } 
} 

और वर्ग के साथ मैं के रूप में जांचा:

package hello; 

public class Greeter { 
    public String sayHello() { 
    return "Hello world!"; 
    } 
} 

मैं त्रुटि संदेश मिलता है

मंच को लक्षित नहीं किया जा सका:का उपयोग कर 'जावा एसई 9'उपकरण श्रृंखला: 'जेडीके 8 (1.8)'।

मेरे eclipse.init

-startup ../Eclipse/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar 
--launcher.library /Users/stein/.p2/pool/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_\1.1.550.v20170928-1359 
-product org.eclipse.epp.package.jee.product 
-showsplash org.eclipse.epp.package.common 
--launcher.defaultAction openFile 
--launcher.a/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/jre/bin 
-vmargs 
-Dosgi.requiredJavaVersion=1.9 
[email protected]/eclipse-workspace 
-XX:+UseG1GC 
-XX:+UseStringDeduplication 
--add-modules=ALL-SYSTEM 
-XstartOnFirstThread 
-Dorg.eclipse.swt.internal.carbon.smallFonts 
-Dosgi.requiredJavaVersion=1.9 
-Xms256m 
-Xmx1024m 
--add-modules=ALL-SYSTEM 
-Xdock:icon=../Resources/Eclipse.icns 
-XstartOnFirstThread 
-Dorg.eclipse.swt.internal.carbon.smallFonts 
-Declipse.p2.max.threads=10 
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest 
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ 

I have added JAVA_HOME

I have added the build path

I have change the compile parameter

है

मैंने Build.Gradle में संकलन पैरामीटर सेट किया है।

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

repositories { 
    mavenCentral() 
} 

ext.junit4Version  = '4.12' 
ext.junitVintageVersion = '4.12.2' 
ext.junitPlatformVersion = '1.0.2' 
ext.junitJupiterVersion = '5.0.2' 
ext.log4jVersion   = '2.9.0' 

apply plugin: 'java' 
apply plugin: 'eclipse' 

apply plugin: 'org.junit.platform.gradle.plugin' 

jar { 
    baseName = 'junit5-gradle-consumer' 
    version = '1.0.0-SNAPSHOT' 
} 

compileJava { 
    sourceCompatibility = 9 
    targetCompatibility = 9 
} 

compileTestJava { 
    sourceCompatibility = 9 
    targetCompatibility = 9 
    options.compilerArgs += '-parameters' 
} 

junitPlatform { 
    // platformVersion '1.0.2' 
    filters { 
     engines { 
      // include 'junit-jupiter', 'junit-vintage' 
      // exclude 'custom-engine' 
     } 
     tags { 
      // include 'fast' 
      exclude 'slow' 
     } 
     // includeClassNamePattern '.*Test' 
    } 
    // configurationParameter 'junit.jupiter.conditions.deactivate', '*' 
    // enableStandardTestTask true 
    // reportsDir file('build/test-results/junit-platform') // this is the default 
    logManager 'org.apache.logging.log4j.jul.LogManager' 
} 

dependencies { 
    // JUnit Jupiter API and TestEngine implementation 
    testCompile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}") 
    testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}") 

    // If you also want to support JUnit 3 and JUnit 4 tests 
    testCompile("junit:junit:${junit4Version}") 
    testRuntime("org.junit.vintage:junit-vintage-engine:${junitVintageVersion}") 

    // To avoid compiler warnings about @API annotations in JUnit code 
    //testCompileOnly('org.apiguardian:apiguardian-api:1.0.0') 

    // To use Log4J's LogManager 
    testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}") 
    testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}") 

    // Only needed to run tests in an (IntelliJ) IDE(A) that bundles an older version 
    testRuntime("org.junit.platform:junit-platform- launcher:${junitPlatformVersion}") 
} 

task wrapper(type: Wrapper) { 
    description = 'Generates gradlew[.bat] scripts' 
    gradleVersion = '4.1' 
} 

क्या मैं इस चलाने के लिए प्राप्त करने के लिए क्या करना चाहिए?

+0

'./gradlew क्लीन बिल्ड' के साथ क्ली के बारे में, क्या यह आपके लिए काम करता है? – chenrui

+0

नवीनतम इंटेलिज के साथ, यह मेरे लिए ठीक काम करता प्रतीत होता है। – chenrui

+0

आपके पास मशीन पर जावा 9 एसडीके स्थापित नहीं है और न ही इसे JAVA_HOME + JAVA_PATH –

उत्तर

0

जो मैं देख सकता हूं, वह ग्रैडल संस्करण मुद्दा है। (Gradle and Java 9 compatibility issue)।

आप CLI रेफरी 4.3.1 के लिए आवरण उन्नत करने के लिए, की जरूरत है:

# upgrade Gradle to 4.3.1 
gradle wrapper --gradle-version 4.3.1 # not ./gradlew 

मुझे पता है कि अगर काम करता है।

1

आप शायद

JAVA_HOME=/path/to/jdk9 

MacOSX में करने के लिए ग्रहण में इस्तेमाल एक समान होना चाहिए आपके सिस्टम चर में JAVA_HOME और जावा संस्करण को अद्यतन करने के लिए प्रयास करना चाहिए, कुछ की तरह:

JAVA_HOME = /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin 
0

मैं java_home बदल और उन्नयन Gradle। अब यह काम कर रहा है।

+0

पर सेट किया गया है ग्रहण ऑक्सीजन में खरीदारी प्लग को जावा 9 में अपग्रेड नहीं किया गया है इसलिए मुझे जावा 8 का उपयोग करना होगा –

संबंधित मुद्दे