gradle sync -> wrong dependencies in module

Answered

Hi,

 

I've got an android project with the following modules:

- App

- AndroidLib

- JavaLib

The App depends on the AndroidLib which depends on the JavaLib. Everything works as intended when running the app, compiling, etc.

But one thing is driving me nuts: When syncing gradle with intelliJ, the dependencies of the JavaLib does included the compile output of the module itself. Also this entry will be there between 4 and 8 times.

Example:



This obviously only happens when I sync gradle without removing the "build" folder. The folder itself is automatically marked as "excluded" in intelliJ.

Here is my gradle file for this module:

buildscript {
ext.kotlin_version = '1.1.4-2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

apply plugin: 'java'
apply plugin: 'kotlin'

sourceCompatibility = 1.7

repositories {
mavenCentral()
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

dependencies {
testCompile 'junit:junit:4.12'
compile fileTree(include: '*.jar', dir: '../libs')
compile 'org.jetbrains:annotations:13.0'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.6"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.6"
}
}

I'm using gradle 3.3. When using a newer version the kotlin dependency gets marked as "runtime" instead of "compile" - but that's another topic I think.

Any idea what could cause this issue or how to resolve it?

My first thought was that the "*.jar" compile dependency was the issue, but even after removing it the issue persisted.

Also here is the output of the "dependencies" task:

compile - Dependencies for source set 'main'.
+--- org.jetbrains:annotations:13.0
\--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4-2
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4-2
\--- org.jetbrains:annotations:13.0

compileClasspath - Compile classpath for source set 'main'.
+--- org.jetbrains:annotations:13.0
\--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4-2
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4-2
\--- org.jetbrains:annotations:13.0

compileOnly - Compile dependencies for source set 'main'.
+--- org.jetbrains:annotations:13.0
\--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4-2
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4-2
\--- org.jetbrains:annotations:13.0

0
1 comment

You should report an issue at https://youtrack.jetbrains.com/issues/KT with some sample project that illustrates the problem. Thank you.

0

Please sign in to leave a comment.