https://kotlinlang.org logo
Title
j

jkbbwr

11/26/2017, 2:49 AM
Current issue
Caused by: org.gradle.cache.CacheOpenException: Could not open cache directory aat8l8gx46xy6a1lqc8xd1ny9 (/home/jakob/.gradle/caches/4.3.1/gradle-kotlin-dsl/aat8l8gx46xy6a1lqc8xd1ny9).
	at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:61)
	at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:32)
	at org.gradle.cache.internal.DefaultCacheFactory.doOpen(DefaultCacheFactory.java:90)
	at org.gradle.cache.internal.DefaultCacheFactory.open(DefaultCacheFactory.java:64)
	at org.gradle.cache.internal.DefaultCacheRepository$PersistentCacheBuilder.open(DefaultCacheRepository.java:123)
	at org.gradle.kotlin.dsl.cache.ScriptCache.cacheDirFor(ScriptCache.kt:51)
	at org.gradle.kotlin.dsl.cache.ScriptCache.cacheDirFor$default(ScriptCache.kt:43)
	at org.gradle.kotlin.dsl.provider.CachingKotlinCompiler.cacheDirFor(CachingKotlinCompiler.kt:170)
	at org.gradle.kotlin.dsl.provider.CachingKotlinCompiler.compileScript(CachingKotlinCompiler.kt:131)
	at org.gradle.kotlin.dsl.provider.CachingKotlinCompiler.compileBuildScript(CachingKotlinCompiler.kt:111)
	at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler.compileScriptFile(KotlinBuildScriptCompiler.kt:239)
	at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler.executeScriptBodyOn(KotlinBuildScriptCompiler.kt:111)
	at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler.prepareAndExecuteScriptBodyOn(KotlinBuildScriptCompiler.kt:105)
	at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler.access$prepareAndExecuteScriptBodyOn(KotlinBuildScriptCompiler.kt:48)
	at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler$compileTopLevelScript$1.invoke(KotlinBuildScriptCompiler.kt:88)
	at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler$compileTopLevelScript$1.invoke(KotlinBuildScriptCompiler.kt:48)
	at org.gradle.kotlin.dsl.provider.KotlinScriptPlugin.apply(KotlinScriptPlugin.kt:48)
	at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:61)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
	at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:58)
	at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:41)
	at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
	at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:64)
	... 84 more
c

Czar

11/26/2017, 8:42 AM
Some time ago this bugged me for some time, turned out I had some mistake in my build file. Can you share yours, so we could check?
j

jkbbwr

11/26/2017, 12:14 PM
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = "io.codehop"
version = "1.0-SNAPSHOT"

buildscript {
    var kotlin_version: String by extra
    kotlin_version = "1.2.0-rc-39"

    repositories {
        maven {
            setUrl("<http://dl.bintray.com/kotlin/kotlin-eap-1.2>")
        }
        mavenCentral()
    }
    
    dependencies {
        classpath(kotlinModule("gradle-plugin", kotlin_version))
    }
    
}

apply {
    plugin("java")
    plugin("kotlin")
}

val kotlin_version: String by extra

repositories {
    maven {
        setUrl("<http://dl.bintray.com/kotlin/kotlin-eap-1.2>")
    }
    mavenCentral()
}

dependencies {
    compile(kotlinModule("stdlib-jdk8", kotlin_version))
    testCompile("junit", "junit", "4.12")
}

configure<JavaPluginConvention> {
    sourceCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "1.8"
}
c

Czar

11/26/2017, 12:31 PM
maven {
    setUrl("<http://dl.bintray.com/kotlin/kotlin-eap-1.2>")
}
both in buildscript and in project repositories should be
maven(url = "<http://dl.bintray.com/kotlin/kotlin-eap-1.2>)
kotlinModule("gradle-plugin", kotlin_version)
both in buildscript and project dependencies should be
kotlin("gradle-plugin", kotlin_version)
And just for cosmetics
kotlinOptions.jvmTarget = "1.8"
->
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
j

jkbbwr

11/26/2017, 12:31 PM
Idea generates the wrong stuff then
c

Czar

11/26/2017, 12:32 PM
Yep, unfortunately.
j

jkbbwr

11/26/2017, 12:33 PM
Still getting cache error on refrehs
It can't even recognise the import
e: /home/jakob/projects/personal/webfx/build.gradle.kts:1:12: Unresolved reference: jetbrains
e: /home/jakob/projects/personal/webfx/build.gradle.kts:34:5: Unresolved reference: compile
e: /home/jakob/projects/personal/webfx/build.gradle.kts:35:5: Unresolved reference: testCompile
e: /home/jakob/projects/personal/webfx/build.gradle.kts:41:16: Unresolved reference: KotlinCompile
c

Czar

11/26/2017, 12:39 PM
I'll whip up a test project, and get back to you in couple of minutes
okey-dory, do you use default gradle wrapper?
j

jkbbwr

11/26/2017, 12:57 PM
im using system local gradle, because otherwise gradle doesn't work at all
c

Czar

11/26/2017, 12:57 PM
version?
j

jkbbwr

11/26/2017, 12:57 PM
------------------------------------------------------------
Gradle 4.3.1
------------------------------------------------------------

Build time:   2017-11-08 08:59:45 UTC
Revision:     e4f4804807ef7c2829da51877861ff06e07e006d

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          9.0.1 (Oracle Corporation 9.0.1+11)
OS:           Linux 4.13.12-1-ARCH amd64
c

Czar

11/26/2017, 1:00 PM
with gradle 4.3.1 this works for me:
import org.gradle.api.JavaVersion.VERSION_1_8
import org.gradle.api.tasks.wrapper.Wrapper
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile


buildscript {
	val kotlinVersion by extra { "1.2.0-rc-39" }
	repositories {
		maven(url = "<http://dl.bintray.com/kotlin/kotlin-eap-1.2>")
		jcenter()
	}
	dependencies {
		classpath(kotlin("gradle-plugin", kotlinVersion))
	}
}

plugins {
	java
}

apply {
	plugin("kotlin")
}

group = "io.codehop"
version = "1.0-SNAPSHOT"

val kotlinVersion: String by extra

repositories {
	maven(url = "<http://dl.bintray.com/kotlin/kotlin-eap-1.2>")
	jcenter()
}

dependencies {
	compile(kotlin("stdlib-jdk8", kotlinVersion))
	testCompile("junit", "junit", "4.12")
}

configure<JavaPluginConvention> {
	sourceCompatibility = VERSION_1_8
}

tasks.withType<KotlinCompile> {
	kotlinOptions.jvmTarget = VERSION_1_8.toString()
}

task<Wrapper>("wrapper") {
	gradleVersion = "4.3.1"
	distributionType = Wrapper.DistributionType.ALL
}
both with standalone gradle and also with
gradlew
after running
gradle wrapper
j

jkbbwr

11/26/2017, 1:02 PM
Lol it worked but only after running it on the command line first
Do you know how to enable kapt?
c

Czar

11/26/2017, 1:04 PM
Yeah, IntelliJ isn't that good with kotlin-dsl yet
No, sorry, I haven't had a project where I'd need it so far 🙂
j

jkbbwr

11/26/2017, 1:08 PM
Do you have anymore input on the normal gradle issue below?
Ohhh so close. Getting cache issues again