2017-08-11 9 views
0

を使用して失敗した私は、アクション帳にKotlinの例を通じてつもりです。コンパイルはGradleのとKotlin

group 'kotlin-in-action' 
version '1.0-SNAPSHOT' 

buildscript { 
    ext.kotlin_version = '1.1.2-2' 

    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 
    } 
} 

apply plugin: 'kotlin' 

repositories { 
    mavenCentral() 
} 
apply plugin: 'java' 

dependencies { 
    testCompile 'junit:junit:4.12' 
} 

dependencies { 
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 
    compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 
    compile "junit:junit:4.12" 
    compile 'junit:junit:4.12' 
    compile 'junit:junit:4.12' 
} 

sourceSets { 
    main.kotlin.srcDirs += 'src' 
} 

すべてのスクリプトは、JUnitのを使用する2つのクラスを除いてコンパイルし、次のようのGradleのBUIDスクリプトがあります。

package ch06.ex1_8_1_LateinitializedProperties 

import org.junit.Before 
import org.junit.Test 
import org.junit.Assert 

class MyService { 
    fun performAction(): String = "foo" 
} 

class MyTest { 
    private var myService: MyService? = null 

    @Before fun setUp() { 
     myService = MyService() 
    } 

    @Test fun testAction() { 
     Assert.assertEquals("foo", 
      myService!!.performAction()) 
    } 
} 

コンパイラは、junitを見つけることができないと言います。私はIntelliJでjarファイルを追加しようとしましたが、これは問題を解決していません。私が追加したjarファイルは、junitとhamscrest-coreです。これはすべてのバージョン4.12です。

+0

プロジェクトの構造を表示してください。 –

答えて

0

私はこれを解決してきました。 mavan保管所からJunitとhamcrest-core jarファイルを追加する必要がありました。

関連する問題