In kotlin reference there is this bit: > Starti...
# intellij
c
In kotlin reference there is this bit:
Starting with Kotlin 1.1.2, the dependencies with group
org.jetbrains.kotlin
are by default resolved with the version taken from the applied plugin.
So, when I updated from
1.1.1
to
1.1.2-5
I removed
$kotlinVersion
from my compile dependencies:
compile 'org.jetbrains.kotlin:kotlin-stdlib-jre8'
Unfortunately though for `./gradlew build`: Execution failed for task ':*****:*****:compileKotlin'.
> Could not resolve all dependencies for configuration ':*****:*****:detachedConfiguration5'.
> Could not find org.jetbrains.kotlinkotlin stdlib jre8.
Searched in the following locations:
file:/home/czar/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.pom
file:/home/czar/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.jar
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.pom
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.jar
https://artifactory.********/repository/maven-releases/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.pom
https://artifactory.********/repository/maven-releases/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.jar
Required by:
project :*****:*****
And when I try to refresh the project in IntelliJ, I get very similar error:
>>
Error: Could not find org.jetbrains.kotlinkotlin stdlib jre8. Searched in the following locations: file:/home/czar/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.pom file:/home/czar/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.jar https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.pom https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.jar https://artifactory.*******/repository/maven-releases/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.pom https://artifactory.*******/repository/maven-releases/org/jetbrains/kotlin/kotlin-stdlib-jre8//kotlin-stdlib-jre8-.jar Required by: project ******* > project ******
y
@h0tk3y
👀 1
h
@Czar From your log (
:*****:*****:compileKotlin
) seems like you have subprojects with Kotlin. Do you have the same version of Kotlin Gradle plugin applied to all the subprojects? Please make sure it's 1.1.2+.
c
@h0tk3y yes, it's configured from central location and is the same for all subprojects
Here's simplified version of project structure I have:
Copy code
root project
│
├ sub-project1
│ │
│ ├ sub-sub-project1
│ ╰ sub-sub-project2
│
â•° sub-project2
In
root project
I have following buildscript block:
Copy code
buildscript {
	ext { kotlinVersion = '1.1.2-5' }

	repositories {
		mavenLocal()
		jcenter()
		maven {
			url "<https://plugins.gradle.org/m2/>"
		}
	}

	dependencies {
		classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
	}
}
neither
root project
nor `sub-project`s contain any code themselves instead they serve to compartmentalize application modules all `sub-project`s whose sub-sub-projects need Kotlin I have following:
Copy code
configure(subprojects) {
	group = "******"
	apply plugin: 'kotlin'

	// groovy code should have access to kotlin classes
	tasks.compileGroovy.dependsOn 'copyMainKotlinClasses'
	// and also for tests
	tasks.compileTestGroovy.dependsOn 'copyTestKotlinClasses'

	tasks.findAll { it.name in ['compileKotlin', 'compileTestKotlin'] }.each {
		it.kotlinOptions.jvmTarget = "1.8"
	}
}
And finally in all sub-sub-projects that use Kotlin I have K specific dependencies:
Copy code
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinVersion"
So there is no way for having different versions of kotlin for sub- or sub-sub- projects.
@h0tk3y any more ideas?
h
Well, another thing to check is that the plugin is applied before the dependencies are resolved, because it has to set up the resolution strategy for the default version. It would be good if you could reproduce the problem in a minimal sample project. I could not reproduce it in a multi-project Gradle build.
c
Oh, that makes sense, the plugin is applied on sub-sub-project scanning, so resolution strategy is already set up and it can't influence it. Ok, keeping the variable in the dependency declaration is not a real problem, so this is okay.