GenerateJavaTask does not show up in netflix dgs package - kotlin

What am I missing in build.gradle.kts file?
import com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask
plugins {id("com.netflix.dgs.codegen") version "5.4.0"}
dependencies {implementation("com.netflix.graphql.dgs.codegen:graphql-dgs-codegen-gradle:5.4.0")}
and getting error when calling GenerateJavaTask
tasks.withType<com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask> {
generateClient = true
packageName = "com.house.api.generated"
}
error (which are pointing to above lines):
Unresolved reference: GenerateJavaTask
Unresolved reference: GenerateJavaTask
Type mismatch: inferred type is () -> Unit but Class<TypeVariable(S)!> was expected
Unresolved reference: generateClient
Unresolved reference: packageName

Related

How to import com.eclipsesource.v8.NodeJS in kotlin?

in build.gradle i add dependencies:
implementation 'com.eclipsesource.j2v8:j2v8_node:8.1.0'
implementation 'com.eclipsesource.j2v8:j2v8:6.2.1'
Than i try use in MainActivity.kt code:
val nodeJS = NodeJS.createNodeJS()
For this i add import com.eclipsesource.v8.NodeJS
But i see an error: unresolved reference: eclipsesource.
I checked the project structure and the dependencies exist:
Why am i getting an error?

Kotlin native platform posix compilation without gradle

I am trying to compile a basic Kotlin/Native program with just the kotlinc-native CLI compiler rather than a full Gradle build. However, I cannot get the platform.posix library to work, despite compiling on linux for linux.
The source code I am using is:
import platform.posix.exit
fun main() {
println("Should exit with status 10")
exit(10)
}
When compiled with the following build.gradle.kts it works fine:
plugins {
kotlin("multiplatform") version "1.6.10"
}
repositories {
mavenCentral()
}
kotlin {
linuxX64("native") {
binaries {
executable()
}
}
}
However, when compiled from the command-line with:
kotlinc-native test.kt
I get:
test.kt:1:8: error: unresolved reference: platform
import platform.posix.exit
^
test.kt:4:5: error: unresolved reference: exit
exit(10)
^
Anyone know how to get Kotlin/Native compilation working fully without using Gradle? Or is there some magic that Gradle does that makes it work?
Thanks.

Unresolved reference: accompanist

I am simply trying to generate apk of my android jetpack compose project. But It is throwing error as Unresolved reference: accompanist. While building and debugging, I didn't face any error. Error is only when generating the signed bundle.
error: Unresolved reference: accompanist
I have added dependencies as
debugImplementation "com.google.accompanist:accompanist-insets:0.23.1"
debugImplementation "com.google.accompanist:accompanist-systemuicontroller:0.23.1"
using compose version as 1.1.1
and usage is:
val systemUiController = rememberSystemUiController()
SideEffect {
systemUiController.setStatusBarColor(
color = ColorPalette.surface
)
}
Any help would be appreciate.

unresolved supertypes: javax.sql.DataSource

I am seeing the following error when trying to compile using gradle.
Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.zaxxer.hikari.HikariDataSource, unresolved supertypes: javax.sql.DataSource
Adding -Xextended-compiler-checks argument might provide additional information.
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
//kotlin("jvm") version "1.6.0"
}
group = "com.jasin"
version = "0.0.1"
dependencies {
//api(files("libs/jdbc-stdext-2.0.jar"))
implementation("org.ktorm:ktorm-core:3.4.1")
implementation("org.ktorm:ktorm-support-mysql:3.4.1")
implementation("mysql:mysql-connector-java:8.0.25")
implementation("com.zaxxer:HikariCP:5.0.1")
implementation("org.slf4j:slf4j-api:1.7.36")
implementation("org.slf4j:slf4j-simple:1.7.36")
testImplementation(kotlin("test"))
}
tasks.test {
useJUnit()
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "11"
}
If I uncomment the following line
//api(files("libs/jdbc-stdext-2.0.jar"))
I get the following type errors
module jdbc.stdext reads package javax.sql from both jdbc.stdext and java.sql
If I recomment this line and try to build again(without cleaning the project), it works. As soon as I clean the project the error reappears. What is exactly going on here and how can I fix this? Any help would be appreciated.
edit: I should add that this is a multi-module project and it wasn't till I tried to define module-info.java files in separate modules that this error appeared. But the error is specific to one module, the module that I use to access my database that uses connection pooling with hikaricp.
module-info.java file
module com.cobis.db {
requires kotlin.stdlib;
requires com.zaxxer.hikari;
requires ktorm.core;
exports com.cobis.db;
exports com.cobis.db.entities;
exports com.cobis.db.utilities;
}

Compiling my Kotlin tests inside of git bash

I am trying to run my code in git bash so that I don't have to run it in Intellij. It runs smoothly inside of Intellij but is giving me issues when I try and compile it inside of gitbash.
Here is the body of code that I am able to run inside of Intellij. The code runs and the test passes when I run it in Intellij.
import org.junit.jupiter.api.*
import testCases.TestCases
import testCases.BaseUser
#TestInstance(TestInstance.Lifecycle.PER_CLASS)
#TestMethodOrder(MethodOrderer.OrderAnnotation::class)
class AllTests : BaseUser() {
#BeforeAll
#Throws(Exception::class)
fun initAll() {
this.initialize()
}
#Test
#Order(1)
fun runAllTests(){
try{
TestCases()
}catch(ex: Exception){
Assertions.fail<Any>()
}
}
}
I am trying to run and compile it by doing this inside of git bash:
kotlinc AllTests.kt -include-runtime -d tests.jar
I keep seeing multiple errors and am unsure how to resolve them:
AllTests.kt:1:12: error: unresolved reference: junit
import org.junit.jupiter.api.*
^
AllTests.kt:2:8: error: unresolved reference: testCases
import testCases.*
^
AllTests.kt:5:2: error: unresolved reference: TestInstance
#TestInstance(TestInstance.Lifecycle.PER_CLASS)
^
AllTests.kt:5:15: error: unresolved reference: TestInstance
#TestInstance(TestInstance.Lifecycle.PER_CLASS)
^
AllTests.kt:6:2: error: unresolved reference: TestMethodOrder
#TestMethodOrder(MethodOrderer.OrderAnnotation::class)
^
AllTests.kt:6:18: error: unresolved reference: MethodOrderer
#TestMethodOrder(MethodOrderer.OrderAnnotation::class)
^
AllTests.kt:7:18: error: unresolved reference: BaseUser
class AllTests : BaseUser() {
^
AllTests.kt:9:6: error: unresolved reference: BeforeAll
#BeforeAll
^
AllTests.kt:12:14: error: unresolved reference: initialize
this.initialize()
^
AllTests.kt:15:6: error: unresolved reference: Test
#Test
^
AllTests.kt:16:6: error: unresolved reference: Order
#Order(1)
^
AllTests.kt:20:13: error: unresolved reference: TestCases()
TestCases()
^
AllTests.kt:33:13: error: unresolved reference: Assertions
Assertions.fail<Any>()
^
It runs in IntelliJ because IntelliJ knows where the jar file for junit is located, so it includes that on the path for running the test. You need to do the same.
You can do it with the -classpath option
kotlinc AllTests.kt -include-runtime -classpath /path/to/junit.jar:/path/to/other.jar -d tests.jar
If you are on windows, separate your jars with ; instead of :.