So, as a n00b I thought to add some testing stuff to a project with
buildscript {
ext.kotlin_version = '1.2.71'
// yaddayadda....
}
dependencies {
compile "org.json:json:20180813"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
// more yadda....
}
Issuing ./gradlew build
throws the following in my face:
> Could not find method testCompile() for arguments [org.jetbrains.kotlin:kotlin-test:1.2.71] on object type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I’m baffled…
Post the entire script and in the meantime you may try to run in console from the project root directory gradlew build
and post the output as well
Well, here’s the build.gradle
contents at the moment:
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:1.3.0-rc-146"
}
}
apply plugin: 'org.jetbrains.kotlin.platform.native'
repositories {
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
mavenCentral()
}
dependencies {
compile "org.json:json:20180813"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
// testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
// testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}
components.main {
outputKinds = [EXECUTABLE]
version = "0.0.0.2"
dependencies {
cinterop('libcurl-interop') {
defFile 'src/main/c_interop/libcurl.def'
target('linux_x64') {
includeDirs.headerFilterOnly '/usr/include', '/usr/include/x86_64-linux-gnu'
}
}
}
}
And console output from project root:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/anikaiful/Dropbox/Projects/kotlin/edsms/build.gradle' line: 33
* What went wrong:
A problem occurred evaluating root project 'edsms'.
> Could not find method testCompile() for arguments [org.jetbrains.kotlin:kotlin-test:1.2.71] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
testCompile and compile are the old gradle method names. You should use testImplementation and implementation. However you are mixing as plugin kotlin 1.2.71 with 1.3.0-rc… Use one version, as mixing will violate all kinds of assumptions.
Ah, compile → implementation. That sorted that, thanks
But if I try use e.g. ... -native-gradle-plugin:$kotlin_version
I get a sorry error that Could not find org...plugin:1.2.71
, followed by a litany of searched sites, whereas 1.3.0-rc-146
is found just fine.
You probably want to use 1.3.0-rc-190 across (no reason not to use the latest prerelease), or use the old multiplatform plugins for native (especially on native there has been a lot of work in the new ones so if you can stick with pre-release that is probably better).
Much appreciated suggestion - did that and no more errors. For some reason I didn’t realise that version upgrade was as simple as changing the ext.kotlin_version in the script… thought it meant version which you already have, and not something that gradle will fetch for you if you don’t have.