Project unable to find gradle shadow plugin - gradle

I have a project that builds a lib. I want to make a fat jar for packaging.
I followed instructions in the gradle-shadow-plugin docs
Here is my build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
gradlePluginPortal()
maven {
url = "https://packages.confluent.io/maven"
}
}
dependencies {
classpath 'gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.1.2'
}
}
plugins {
id 'java' // so that we can use 'implementation', 'testImplementation' for dependencies
}
apply plugin: 'com.github.johnrengelman.shadow'
repositories {
jcenter()
mavenCentral()
maven {
url = "https://packages.confluent.io/maven"
}
maven {
url = "https://jitpack.io"
}
}
dependencies {
// Kafka
implementation group: 'org.apache.kafka', name: 'connect-api', version: '3.3.1'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.1'
implementation 'com.github.jcustenborder.kafka.connect:connect-utils:0.7.173'
implementation 'com.github.jcustenborder.kafka.connect:kafka-connect-transform-common:0.1.0.14'
//test
testImplementation(platform('org.junit:junit-bom:5.9.0'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation("io.mockk:mockk:1.9.2")
}
sourceSets {
main {
java {
srcDirs = ["src/main/java"]
}
resources {
srcDirs = ["src/main/avro", "src/main/resources"]
}
}
test {
java {
srcDirs = ["src/test/java"]
}
}
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
plugins.withId("com.github.johnrengelman.shadow"){
//this block requires the java plugin to be applied first.
plugins.withId("java"){
shadowJar {
//We are overriding the default jar to be the shadow jar
classifier = null
exclude 'META-INF'
exclude 'META-INF/*.INF'
exclude 'META-INF/license/*'
}
jar {
manifest {
attributes(
'Built-By' : System.properties['user.name'],
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
)
}
}
tasks.build.dependsOn tasks.shadowJar
tasks.shadowJar.mustRunAfter tasks.jar
}
}
When I do a .gradlew clean build I am getting the following error.
* What went wrong:
A problem occurred configuring root project 'remove-json-value'.
> Could not resolve all files for configuration ':classpath'.
> Could not find gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.1.2.
Searched in the following locations:
- https://jcenter.bintray.com/gradle/plugin/com/github/jengelman/gradle/plugins/shadow/7.1.2/shadow-7.1.2.pom
- https://repo.maven.apache.org/maven2/gradle/plugin/com/github/jengelman/gradle/plugins/shadow/7.1.2/shadow-7.1.2.pom
- https://plugins.gradle.org/m2/gradle/plugin/com/github/jengelman/gradle/plugins/shadow/7.1.2/shadow-7.1.2.pom
- https://packages.confluent.io/maven/gradle/plugin/com/github/jengelman/gradle/plugins/shadow/7.1.2/shadow-7.1.2.pom
Required by:
project :
I search SO and found this answer. However, adding jcenter to the buildscript -> repositories section does not seem to solve it.
This is my environment:
$ ./gradlew -version
------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------
Build time: 2022-11-25 13:35:10 UTC
Revision: daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8
Kotlin: 1.7.10
Groovy: 3.0.13
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 1.8.0_181 (Oracle Corporation 25.181-b13)
OS: Mac OS X 10.16 x86_64
Any ideas what I am doing wrong?

At the time of writing this answer, the shadow plugin's latest version is 2.0.3, not 7.1.2.
Try the following:
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.3'
}
The 7.0.x version refers to a different "shadow" dependency, the 2.0.x belongs to the one you specified.

This is a bug in the current quickstart docs.
Details here
The correct classpath that works is:
classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'

Related

`gradlew eclipse` not pulling specific package

i am upgrading the Spring Boot version for one of the team's smaller projects, & it seems that Gradle is not able to download this specific package org.jfrog.artifactory.client:artifactory-java-client-services:2.13.0 from our company's Artifactory website
here is the build.gradle:
buildscript {
ext {
springBootVersion = '2.6.9'
}
repositories {
maven {
url "https://artifactory.trusted.visa.com/mavenrepo/"
credentials {
username = project.artifactory_username
password = project.artifactory_apikey
}
}
}
dependencies {
classpath 'org.ajoberstar:grgit:1.7.2'
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'org.springframework.boot'
if (project.hasProperty("projVersion")) {
version = project.projVersion
} else {
version = "0.0-SNAPSHOT"
}
group = 'CoreConfigBackend'
// In this section you declare where to find the dependencies of your project
repositories {
maven {
url "https://artifactory.trusted.visa.com/visacommonssecurity-maven-virtual/"
credentials {
username = project.artifactory_username
password = project.artifactory_apikey
}
}
maven {
url "https://artifactory.trusted.visa.com/mavenrepo/"
credentials {
username = project.artifactory_username
password = project.artifactory_apikey
}
}
maven {
url "https://artifactory.trusted.visa.com/coreconfig_commons-snapshots/"
credentials {
username = project.artifactory_username
password = project.artifactory_apikey
}
}
}
configurations {
all*.exclude module : 'spring-boot-starter-logging'
}
dependencies {
if (project.hasProperty("local")) {
compile project(':CommonUtility')
} else {
compile(group: 'CoreConfigBackend', name: 'CommonUtility', version: version){ changing = true }
}
compile('org.springframework.boot:spring-boot-starter-web:2.6.9')
compile('org.springframework:spring-tx:5.3.22')
compile 'org.springframework.boot:spring-boot-starter-jdbc:2.6.9'
compile('com.github.ulisesbocchio:jasypt-spring-boot:2.1.0')
compile 'org.springframework.boot:spring-boot-starter-data-mongodb:2.6.9'
compile ("commons-lang:commons-lang:2.6")
compile 'com.fasterxml.jackson.core:jackson-core:2.9.4'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.4'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.4'
compile 'org.jfrog.artifactory.client:artifactory-java-client-services:2.13.0'
// Log4j 2
compile ('org.apache.logging.log4j:log4j-core:2.17.1')
compile ('org.apache.logging.log4j:log4j-api:2.17.1')
compile ('org.apache.logging.log4j:log4j-slf4j-impl:2.17.1')
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
bootJar {
exclude ("application.properties")
exclude ("database.properties")
exclude ("artifactory.properties")
}
task setupProject {
doFirst {
File dir = new File("$buildDir/../../../coreconfig_commons")
if(!dir.exists()) {
def grgit = org.ajoberstar.grgit.Grgit.clone(dir: "$buildDir/../../../coreconfig_commons", uri: "https://stash.trusted.visa.com:7990/scm/cor1dca/coreconfig_commons.git")
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
& the contents of the gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
i run the command gradlew eclipse -Plocal -Partifactory_username='username' -Partifactory_apikey='password' in the command line to pull the packages.
Oddly, it's only this artifactory-java-client-services package that is missing, not sure why but somehow Gradle can't retrieve this package?
When i import the project into Eclipse, there is an Eclipse Error message saying that the artifactory-java-client-services package is missing.
Even this missing package warning is displayed in the command line after running the gradle command.
i checked our company's Artifactory website & i can see the package listed there
After running the gradlew eclipse -Plocal -Partifactory_username='username' -Partifactory_apikey='password' command in the command line, this is the output:
> Task :eclipseClasspath
Could not resolve: org.jfrog.artifactory.client:artifactory-java-client-services:2.13.0
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 33s
10 actionable tasks: 10 executed
This is my gradle version, after running gradlew -v:
gradlew -v
------------------------------------------------------------
Gradle 6.8
------------------------------------------------------------
Build time: 2021-01-08 16:38:46 UTC
Revision: b7e82460c5373e194fb478a998c4fcfe7da53a7e
Kotlin: 1.4.20
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 1.8.0_361 (Oracle Corporation 25.361-b31)
OS: Windows 10 10.0 amd64

Unable to publish a gradle Jar artifact to a sonatype repository

I am following instructions in the Sonatype documentation for publishing a gradle project.
I have the following gradle version.
$ ./gradlew --version
------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------
Build time: 2022-11-25 13:35:10 UTC
Revision: daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8
Kotlin: 1.7.10
Groovy: 3.0.13
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 1.8.0_181 (Oracle Corporation 25.181-b13)
OS: Mac OS X 10.16 x86_64
When I try to use the uploadArchives task as given in their example, I get the following error:
$ ./gradlew uploadArchives
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/ferozed/stash/libs/mask-json-field-transform/build.gradle' line: 167
* What went wrong:
A problem occurred evaluating root project 'mask-json-field-transform'.
> Could not find method uploadArchives() for arguments [build_6yphclnk6m8p3rtmq5h7m56li$_run_closure12#19fbeecd] on root project 'mask-json-field-transform' of type org.gradle.api.Project.
This is my build.gradle file
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
}
}
plugins {
id 'java' // so that we can use 'implementation', 'testImplementation' for dependencies
id 'maven-publish'
id 'signing'
}
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'com.github.johnrengelman.shadow'
repositories {
jcenter()
mavenCentral()
maven {
url = "https://packages.confluent.io/maven"
}
maven {
url = "https://jitpack.io"
}
}
group = 'io.github.ferozed.kafka.connect'
version = '0.1'
dependencies {
// Kafka
implementation group: 'org.apache.kafka', name: 'connect-api', version: '3.3.1'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.1'
implementation 'com.github.jcustenborder.kafka.connect:connect-utils:0.7.173'
implementation 'com.github.jcustenborder.kafka.connect:kafka-connect-transform-common:0.1.0.14'
//test
testImplementation(platform('org.junit:junit-bom:5.9.0'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation("io.mockk:mockk:1.9.2")
}
sourceSets {
main {
java {
srcDirs = ["src/main/java"]
}
resources {
srcDirs = ["src/main/avro", "src/main/resources"]
}
}
test {
java {
srcDirs = ["src/test/java"]
}
}
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
plugins.withId("com.github.johnrengelman.shadow"){
//this block requires the java plugin to be applied first.
plugins.withId("java"){
shadowJar {
//We are overriding the default jar to be the shadow jar
classifier = null
exclude 'META-INF'
exclude 'META-INF/*.INF'
exclude 'META-INF/license/*'
}
jar {
manifest {
attributes(
'Built-By' : System.properties['user.name'],
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
)
}
}
tasks.build.dependsOn tasks.shadowJar
tasks.shadowJar.mustRunAfter tasks.jar
tasks.shadowJar.mustRunAfter tasks.javadocJar
tasks.shadowJar.mustRunAfter tasks.sourcesJar
}
}
publishing {
publications {
mavenJava(MavenPublication) {
pom {
name = 'Mask Json Field Transform'
description = 'A kafka connect transform to remove the value of a sensitive field in a json document.'
url = 'https://github.com/ferozed/mask-json-field-transform'
properties = [
myProp: "value",
"prop.with.dots": "anotherValue"
]
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'ferozes'
name = 'Feroze Daud'
email = 'ferozed.oss#gmail.com'
}
}
scm {
connection = 'scm:git:git#github.com:ferozed/mask-json-field-transform.git'
developerConnection = 'scm:git:git#github.com:ferozed/mask-json-field-transform.git'
url = 'https://github.com/ferozed/mask-json-field-transform'
}
}
}
}
}
signing {
sign configurations.archives
sign publishing.publications.mavenJava
}
tasks.signArchives.dependsOn tasks.shadowJar
artifacts {
archives javadocJar, sourcesJar
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { deployment -> signing.signPom(deployment) }
repository(url: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://s01.oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'Example Application'
packaging 'jar'
// optionally artifactId can be defined here
description 'A kafka connect transform to remove the value of a sensitive field in a json document.'
url 'https://github.com/ferozed/mask-json-field-transform'
scm {
connection 'scm:svn:http://foo.googlecode.com/svn/trunk/'
developerConnection 'scm:svn:https://foo.googlecode.com/svn/trunk/'
url 'https://github.com/ferozed/mask-json-field-transform'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'ferozed'
name 'Feroze Daud'
email 'feroz#gmail.com'
}
}
}
}
}
}
What am I doing wrong?
First and foremost, you may not need to 'fix the error' so to speak, in that it appears the problematic code MAY be able to be outright deleted. However...
To fix the error...
Could not find method uploadArchives() for arguments [build_6yphclnk6m8p3rtmq5h7m56li$_run_closure12#19fbeecd] on root project 'mask-json-field-transform' of type org.gradle.api.Project.
This is telling us that uploadArchives is not valid. See immediately below.
I believe you may need to use the maven plugin to access this functionality.
https://github.com/siddeshbg/gradle-uploadArchives/blob/master/README.md
to do this, add:
id 'maven'
to your plugins{}
block.
The above example explains that the maven plugin is responsible for doing this
The Maven plugin adds support for deploying artifacts to Maven repositories
It is worth considering also that the author of the above repository claims:
This is the legacy publishing mechanism, should not be used in newer
builds
Now... on to the better solution, forgetting the maven plugin, in favor of the maven-publish plugin you're already using...
I do not personally work with Maven often enough to know what other mechanisms one should use, but Google suggests that perhaps the maven-publish plugin you're using might do this WITHOUT the 'uploadArchives{}' portion of your code that is causing the error.
See:
https://docs.gradle.org/current/userguide/publishing_maven.html
Per this page, it would seem the entire uploadArchives block is unnecessary

Getting unsupported major.minor version error when packaging tornadofx app

I've been developing a Tornadofx app for a couple months now. It runs just fine within the IDE (intellij ultimate, win 10), but now that I need to create an actual executable jar for other people to run it, I cannot seem to get it to work.
I'm using the openfx gradle plugin to automatically gather the javafx dependencies and provide the application/run task, which I've been utilizing during development. The documentation there also has you include org.beryx.jlink as a plugin for this final packaging process. This being a tornadofx app, I've written the entire thing in Kotlin. The problem I'm having now is that when I run the jlink, jlinkZip, or jpackage tasks (which I'm assuming would provide me with a distributable build), I'm receiving the error "Unsupported major.minor version 56.0."
I did some digging, thought, "maybe I need to update my jdk from 12 to 14" so I installed openjdk14 and now the error is "Unsupported major.minor version 58.0." So, clearly the problem is that my jdk is too updated...? I'm not sure. However, I don't know what version of the jdk I need to get this to build. I'm just not sure where to go from here. Some other research I've done has stated that jlink doesn't work with kotlin, but that the 'org.beryx.jlink' gradle plugin is "Badass jlink" and can work with Kotlin.
For further background, I have multiple sub-modules and a separately built internal core library, so there are a lot of pieces to build and put together. However, each submodule build.gradle looks something like this:
apply from: "$rootDir/kotlin-module.gradle"
apply from: "$rootDir/local-repositories.gradle" // helps resolve the local version of the core module.
dependencies {
implementation "<--anonymized core module-->"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
testImplementation 'io.cucumber:cucumber-java8:5.5.0'
testImplementation 'io.cucumber:cucumber-junit:5.5.0'
implementation project(":application")
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.61"
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty', '--add-plugin', 'html:build/cucumber/html-report', '--glue', '<-- root package name -->', 'src/test/resources/features', '--strict']
}
}
}
while the kotlin-module.gradle file looks like this:
apply plugin: 'kotlin'
group '<-- anonymized group name -->'
version '0.1.0'
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
}
compileKotlin {
kotlinOptions.jvmTarget = "13" // version issue here?
}
compileTestKotlin {
kotlinOptions.jvmTarget = "13" // version issue here?
}
test {
useJUnitPlatform()
}
The actual submodule that includes javafx and tornadofx looks like this:
plugins {
id 'java'
id 'application'
id 'org.jetbrains.kotlin.jvm'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'org.beryx.jlink' version '2.12.0'
id 'edu.sc.seis.launch4j' version '2.4.6'
id 'no.tornado.fxlauncher' version '1.0.20'
}
apply from: "$rootDir/kotlin-module.gradle"
apply from: "$rootDir/local-repositories.gradle"
repositories {
jcenter()
}
dependencies {
implementation "<--anonymized core module-->"
implementation project(":application")
implementation project(":data")
implementation project(":gui")
implementation "no.tornado:tornadofx:1.7.19"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-javafx:1.3.3"
testImplementation 'io.cucumber:cucumber-java8:5.5.0'
testImplementation 'io.cucumber:cucumber-junit:5.5.0'
implementation "de.jensd:fontawesomefx-commons:11.0"
implementation "de.jensd:fontawesomefx-controls:11.0"
implementation "de.jensd:fontawesomefx-fontawesome:4.7.0-11"
implementation "de.jensd:fontawesomefx-materialicons:2.2.0-11"
implementation "de.jensd:fontawesomefx-emojione:2.2.7-11"
}
javafx {
version = "14"
modules = [ 'javafx.controls', 'javafx.fxml'/*, 'javafx.web', 'javafx.swing'*/ ]
}
jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = '<-- name of root module -->'
}
}
mainClassName = '<-- package.path.to.kotlin.class.extending.tornadofx.Application -->'
launch4j {
mainClassName = '<-- package.path.to.kotlin.class.extending.tornadofx.Application -->'
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty', '--glue', '<-- root package name -->', 'src/test/resources/features', '--strict']
}
}
}
And finally, the parent build.gradle file:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.70'
}
group '<-- anonymized group name -->'
version '0.1.0'
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
}
compileKotlin {
kotlinOptions.jvmTarget = "13" // version issue here?
}
compileTestKotlin {
kotlinOptions.jvmTarget = "13" // version issue here?
}
test {
useJUnitPlatform()
}
I'm really hoping someone has some insight into what else I can do to get this to build. This is really confusing to me because I've been building it and running it within the IDE no problem this entire time.
Gradle 6.3 is the latest release (as of this comment) and is also the first release to support Java 14. Simply upgrade your Gradle wrapper:
./gradlew wrapper --gradle-version=6.3
https://docs.gradle.org/6.3/release-notes.html
I noticed that org.beryx.jlink plugin only works with Java 11, and with Java 14 I got this error:
Execution failed for task ':createMergedModule'.
> Unsupported major.minor version 58.0
And so to make it work I ran java 11 jlink. In my build.gradle (gradle-6.3) I used this:
jlink {
javaHome = '/usr/lib/jvm/jdk-11.0.6+10'
......
}
and specified this for jpackage to pick up the java 14 version:
jpackage {
jpackageHome = '/usr/lib/jvm/jdk-14+36'
......
}
Also used this version:
plugins {
id "org.beryx.jlink" version "2.17.4"
}
Hope this helps.

How do I configure KoTest with Gradle in a LibGdx project? Currently can't build because StringSpec is not recognised

I have a standard LibGdx project setup by the LibGdx tool, only targeting desktop. It uses Gradle (Groovy DSL) to manage dependencies and tasks. I've converted the core module to Kotlin, and I'm trying to add a Kotlin test module using Kotest.
I've followed the Kotest instructions for Gradle on their GitHub but the compile is failing because StringSpec isn't reocgnised (Unresolved reference: StringSpec). I think LibGdx's default Gradle setup may be a little outdated or use older syntax/structure, and perhaps it's conflicting with Kotest's instructions intended for newer versions of Gradle?
For now I've removed any test and am just trying to get it to recognise StringSpec and compile. I've not even reached the stage of getting IntelliJ to recognise and run the tests. Here's what I have so far:
core.tests/tests/com/me/game/AcceptanceTests.kt
package com.jansky.myproject
class AcceptanceTests : StringSpec() {
}
core.tests/gradle.build
version '1.0'
sourceCompatibility = 1.7
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "tests/" ]
tasks.withType(Test) {
useJUnitPlatform()
}
eclipse.project.name = appName + "-core.tests"
./build.gradle (ie the root buildfile)
buildscript {
ext.kotlinVersion = '1.3.71'
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "game"
gdxVersion = '1.9.10'
roboVMVersion = '2.3.8'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "kotlin"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.ashley:ashley:1.7.3"
compile group: 'io.github.libktx', name: 'ktx-ashley', version: '1.9.10-b4'
}
}
project(":core") {
apply plugin: "kotlin"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile "com.badlogicgames.ashley:ashley:1.7.3"
compile group: 'io.github.libktx', name: 'ktx-ashley', version: '1.9.10-b4'
}
}
project(":core.tests") {
apply plugin: "kotlin"
test {
useJUnitPlatform()
}
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile "com.badlogicgames.ashley:ashley:1.7.3"
compile group: 'io.github.libktx', name: 'ktx-ashley', version: '1.9.10-b4'
implementation 'io.kotest:kotest-runner-junit5:4.0.2'
implementation 'io.kotest:kotest-assertions-core:4.0.2'
}
}
settings.gradle
include 'desktop', 'core', 'core.tests'
Gradle-wrapper.properties
#Sat Apr 04 15:53:20 BST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
I don't have much JVM experience, so I'm at a bit of a loss. Hopefully I've missed something that's obvious to someone that knows Gradle better. Any ideas?

Two versions of module javafx.base in gradle/JavaFX project

My team is working on a java project. (git repo # https://github.com/RaiderRobotix/Scouting-Client-FX). We are trying to package it using jlink. The following is displayed when running the jlink task (gradlew jlink). I'm using gradle 6.1.1, with jdk 11 on macOS. If you'd like to see our module-info.java, please check the repo. I didn't want to make this question too lengthy.
BTW, I have multiple JDK's on my machine (8,11). Building the project works, but running it with gradlew run does not (I think its an unrelated issue with lombok).
Full error: Error: Two versions of module javafx.base found in ./build/jlinkbase/jlinkjars (Infinite Recharge Client-v4.0.0-alpha.jar and javafx-base-11-mac.jar)
build.gradle
plugins {
id 'java'
id 'idea'
id "org.openjfx.javafxplugin" version "0.0.8"
id 'org.beryx.jlink' version '2.17.2'
id "com.github.johnrengelman.shadow" version "5.2.0"
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
id 'com.github.gmazzo.buildconfig' version '1.6.2'
}
group = "com.github.RaiderRobotix"
version = "v4.0.0-alpha"
repositories {
maven { url 'https://jitpack.io' }
jcenter()
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
jar {
manifest {
attributes (
'Implementation-Title': 'Raider Robotix Scouting Client',
'Implementation-Version': project.version,
'Main-Class': 'org.usfirst.frc.team25.scouting.client.ui.Main'
)
}
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
}
dependencies {
implementation 'com.github.RaiderRobotix:Scouting-Models:29617b7dcc'
implementation 'com.github.RaiderRobotix:blue-alliance-api-java-library:3.0.0'
implementation 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
implementation 'com.google.code.gson:gson:2.+'
implementation 'commons-io:commons-io:2.+'
implementation 'org.apache.commons:commons-math3:3.+'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.61"
}
buildConfig {
packageName "com.raiderrobotix"
buildConfigField 'String', 'TBA_API_KEY', project['TBA_API_KEY']
// The escaped quotes here are NEEDED. The plugin copies the TEXT LITERAL given to it. The quotes are part of this.
buildConfigField 'String', 'VERSION', "\"$version\""
}
javafx {
version = "11"
modules = [
'javafx.base',
'javafx.graphics',
'javafx.controls',
'javafx.fxml',
]
}
jlink {
launcher {
name = 'Scouting Client'
}
}
application {
mainClassName = 'org.raiderrobotix.scouting.client/org.raiderrobotix.scouting.client.ui.Main'
}
wrapper {
gradleVersion = '6.1.1'
}
compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
I had a similar issue, my specific error during jlink was:
Error: Two versions of module javafx.base found in C:\Users\tareh\code\cleopetra\build\jlinkbase\jlinkjars (javafx-base-11.0.2-win.jar and javafx-base-11.0.2-linux.jar)
Execution failed for task ':jlink'.
I got some inspiration from https://github.com/openjfx/javafx-gradle-plugin/issues/65 and changed one of my dependencies in build.gradle:
dependencies {
// Get rid of this
// compile group: 'org.controlsfx', name: 'controlsfx', version: '11.0.3'
// Use this instead
implementation('org.controlsfx:controlsfx:11.0.3') {
exclude group: 'org.openjfx'
}
}
After I did that, the jlink error went away, and also I noticed the linux jars which had been listed in my IntelliJ module dependencies had disappeared (I'm on Windows).
This doesn't address your specific problem, but hopefully this will be helpful to others.
In my case I had to comment jar block in build.gradle to perform jlink command. I guess that problem is related to how plugin 'org.beryx.jlink' resolves modules when jar block is appear.

Resources