czuckie
12/09/2022, 2:17 PMallprojects {
...
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
languageVersion = "1.9"
}
}
...
}
And IntelliJ lets me use data object
as expected, however when I go to compile or run anything I get:
The binary version of its metadata is 1.9.0, expected version is 1.7.1.
This is in a spring-boot project if any of the compiler plugins might not play nicely with 1.9Android75
12/11/2022, 8:28 AMJosh Eldridge
12/13/2022, 12:13 AM1.7.10
to 1.7.20
but the stack trace hasn't been super helpful into hunting down exactly why the CI can't find 1.7.20
attaching stack trace in thread:mudasar187
12/13/2022, 12:41 PMshadowJar
withType<ShadowJar> {
archiveFileName.set("app.jar")
manifest {
attributes["Main-Class"] = "no.nav.sokos.prosjektnavn.BootstrapKt"
}
}
But it appears two jars? One with app.jar
and one with name of the project projectName.jar
, why two jars?
If i remove archiveFileName.set("app.jar")
the i get projectName.jar
and projectName-all.jar
. How can I make my Gradle config so I only have one jar with name app.jar
?Zac Sweers
12/17/2022, 8:30 PMJan
12/18/2022, 11:21 PMGavin Ray
12/19/2022, 7:22 PMorg.jetbrains.kotlin.plugin.allopen
◦ https://mvnrepository.com/artifact/org.jetbrains.kotlin.plugin.allopen
• org.jetbrains.kotlin:kotlin-allopen
◦ https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-allopenspierce7
12/19/2022, 7:34 PMbuild.gradle.kts
changes in the app.
I made a gradle plugin using Kotlin over the weekend, and I was surprised to see things like extensions created via reflection, and things like the project
still being `@Inject`ed into the constructor. Isn't using reflection to create abstract classes and reflection based dependency injection part of the problem why resolving the project configuration takes so long?
Is there any hope for performance in the next few years, as we will surely surpass 200 multiplatform Kotlin modules (which are perhaps heavier than a normal module due to their many configurations?), or do we need to start considering breaking up things into separate repositories?mudasar187
12/19/2022, 7:46 PMbuild.gradle.kts
? Any idea how I can check which dependencies i can get rid of that are not in use. There a lot of dependencies and it would be great to do a scan and just remove which one not in use.Guilherme Delgado
12/20/2022, 3:12 PMlocal.properties
(or other file) instead of gradle.properties
(root or project) when looking for credentials to publish to maven? My question comes from here, vanniktech gradle-plugin (which fetches credentials here).Gavin Ray
12/20/2022, 6:01 PMtasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.useK2 = true // 1
compilerOptions {
useK2.set(true) // 2
}
}
martmists
12/21/2022, 2:58 AMapply<KotlinMultiplatformPluginWrapper>()
I get the error
Caused by: org.gradle.api.internal.AbstractMutationGuard$IllegalMutationException: Project#afterEvaluate(Action) on project '...' cannot be executed in the current context.
at org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginKt.whenEvaluated(KotlinMultiplatformPlugin.kt:236)
What should I do to fix this?mudasar187
12/21/2022, 11:04 AMbuild.gradle.kts
with jacoco plugin.
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
plugins {
kotlin("jvm") version "1.7.22"
kotlin("plugin.serialization") version "1.7.22"
id("org.openapi.generator") version "6.2.1"
id("io.ktor.plugin") version "2.2.1"
jacoco
}
group = "no.nav.sokos"
java.sourceCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
maven { url = uri("<https://maven.pkg.jetbrains.space/public/p/ktor/eap>") }
}
val ktorVersion = "2.2.1"
val junitJupiterVersion = "5.9.1"
val logbackVersion = "1.4.5"
val logstashVersion = "7.2"
val jacksonVersion = "2.14.1"
val prometheusVersion = "1.10.2"
val kotlinLoggingVersion = "3.0.4"
val janionVersion = "3.1.9"
val natpryceVersion = "1.6.10.0"
val kotestVersion = "5.5.4"
dependencies {
// Ktor server
implementation("io.ktor:ktor-server-core-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-call-logging-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-call-id-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-status-pages:$ktorVersion")
implementation("io.ktor:ktor-server-content-negotiation-jvm:$ktorVersion")
// Ktor client
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-client-core-jvm:$ktorVersion")
implementation("io.ktor:ktor-client-apache-jvm:$ktorVersion")
implementation("io.ktor:ktor-serialization-jackson-jvm:$ktorVersion")
// Security
implementation("io.ktor:ktor-server-auth-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-auth-jwt-jvm:$ktorVersion")
// Jackson
implementation("io.ktor:ktor-serialization-jackson:$ktorVersion")
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion")
// Monitorering
implementation("io.ktor:ktor-server-metrics-micrometer-jvm:$ktorVersion")
implementation("io.micrometer:micrometer-registry-prometheus:$prometheusVersion")
// Logging
implementation("io.github.microutils:kotlin-logging-jvm:$kotlinLoggingVersion")
runtimeOnly("org.codehaus.janino:janino:$janionVersion")
runtimeOnly("ch.qos.logback:logback-classic:$logbackVersion")
runtimeOnly("net.logstash.logback:logstash-logback-encoder:$logstashVersion")
// Config
implementation("com.natpryce:konfig:$natpryceVersion")
// Test
testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
}
sourceSets {
main {
java {
srcDirs("$buildDir/generated/src/main/kotlin")
}
}
}
application {
mainClass.set("no.nav.sokos.skattekort.person.ApplicationKt")
}
tasks {
withType<GenerateTask> {
generatorName.set("kotlin")
generateModelDocumentation.set(false)
inputSpec.set("$rootDir/specs/sokos-skattekort-person-v1-swagger.json")
outputDir.set("$buildDir/generated")
globalProperties.set(
mapOf(
"models" to ""
)
)
configOptions.set(
mapOf(
"library" to "jvm-ktor",
"serializationLibrary" to "jackson"
)
)
}
withType().named("buildFatJar") {
ktor {
fatJar {
archiveFileName.set("app.jar")
}
}
}
withType().named("jar") {
enabled = false
}
withType<KotlinCompile> {
dependsOn("openApiGenerate")
kotlinOptions.jvmTarget = "17"
}
withType<Test> {
useJUnitPlatform()
testLogging {
exceptionFormat = FULL
events("passed", "skipped", "failed")
}
// For å øke hastigheten på build kan vi benytte disse metodene
maxParallelForks = Runtime.getRuntime().availableProcessors() / 2
reports.forEach { report -> report.required.value(false) }
finalizedBy("jacocoTestReport")
}
withType<JacocoReport> {
dependsOn(":test")
reports {
xml.required.set(false)
csv.required.set(false)
html.required.set(true)
html.outputLocation.set(layout.buildDirectory.dir("jacoco"))
}
}
withType<Wrapper> {
gradleVersion = "7.6"
}
}
When i run my tests it generate a output html. When i open this file i see this error:
Why cant I see the source file with the code?dephinera
12/21/2022, 1:44 PMext.flavorConfig = {
flavorDimensions(*dimensions)
productFlavors {
with flavors
}
sourceSets {
with sources
}
}
so far in groovy I used it like: with flavorConfig
. How would that look like in Kotlin?Amanda Martin
12/22/2022, 2:02 PMSteve Ramage
12/22/2022, 8:07 PMclasses.dependsOn += otherTask
But I'm struggling to figure out what the new version of that should be.
tasks.named("classes").dependsOn.add(tasks.named("otherTask"))
Complains with "Unresolved reference "depends on"Jhonatan Sabadi
12/23/2022, 2:17 PMtask updateLint(type: Delete) {
fileTree(rootDir).each {
if (it.name == "lint-baseline.xml") {
delete it
}
}
dependsOn("lint --parallel -Dlint.baselines.continue=true")
}
ManApart
12/23/2022, 7:46 PMSourceSet with name 'jvmTestIntegration' not found.
It's strange because it worked before (and works again if I revert) the bump from kotlin 1.6 to 1.7.
I saw in the "what's new in 1.7" that sourcesets and compiling both changed a bit, but I'm unable to understand how I could have broken things or what I need to do to fix it.
FWIW jvmTestIntegration
is meant to be a second test directory that contains slower running tests.
Any tips or pointing in the right direction would be much appreciated. 🙂
compilations {
val main by getting
val jvmTestIntegration by compilations.creating { //Breaks here
defaultSourceSet {
dependencies {
implementation(main.compileDependencyFiles + main.output.classesDirs)
implementation(kotlin("test-junit"))
}
}
tasks.register<Test>("test-integration") {
group = "verification"
description = "Runs the integration tests."
classpath = compileDependencyFiles + runtimeDependencyFiles + output.allOutputs
testClassesDirs = output.classesDirs
}
}
Ido Flax
12/24/2022, 2:18 PMenableFeaturePreview("VERSION_CATALOGS")
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from("<http://com.me:me-version-catalog:0.0.1-SNAPSHOT|com.me:me-version-catalog:0.0.1-SNAPSHOT>")
}
}
}
Now i want to access it in my binary plugin code but i don’t have access to libs.something
Can you give any advice? or perhaps add a use example in the PR?
ThanksDaniel Perez
12/24/2022, 5:45 PMA and B are modules in a the same Gradle project.
A is a regular module
B exposes a plugin with ID "my.gradle.plugin"
I would like to have the following
A -> B(Plugin)
I know normally you'd use the plugins
block and use the id()
method, but I'm not sure how to configure it from another module like you would with a library in the dependencies
block with project()
eygraber
12/26/2022, 5:47 PMplugins
block in gradle.kts
instead of compiling it. I can't remember where I saw that. Anyone know where that is?Adeel Malik
12/27/2022, 12:59 PMcheckStaging
that checks lint
and ktLintCheck
and after that run all unit tests for the modules.
The problem is that even though ktLintCheck
fails, the task keeps running and then fails after 8-11 minutes. I want the task to fail as soon as ktLintCheck failed. Any idea, how to do that?
task cleanAll(dependsOn: [':lib_mvp:clean', ':lib_service:clean', ':Dream:clean'])
task checkStaging(dependsOn: ['cleanAll',
':lib_mvp:lintDebug', ':lib_service:lintStagingDebug', ':Dream:lintStagingDebug',
':lib_mvp:ktlintCheck', ':lib_service:ktlintCheck', ':Dream:ktlintCheck',
':lib_mvp:testDebugUnitTest', ':lib_service:testStagingDebugUnitTest', ':Dream:testStagingDebugUnitTest'])
checkStaging.mustRunAfter cleanAll
Note: it’s build.gradle file which is in groovy.hfhbd
12/28/2022, 1:29 PMThe root project is not yet available for build
called in registerProjectStructureMetadata
spierce7
12/28/2022, 3:54 PMNacho Ruiz Martin
12/28/2022, 6:42 PMbuildSrc
precompiled scripts?
I’m getting Unresolved reference: projects
.
Thanks! 🙇james
12/29/2022, 12:23 AM.jar
I have? I know I can substitute using project(":patched-project")
but I’m trying to avoid having to pull in the entire other project because it’s huge, creates CI implications, and the patch is a temporary solution
when I try to swap implementation("the.original:dependency")
with implementation("libs/patched.jar")
that creates a whole world of other problems because the dependencies-of-dependency don’t come into the project, so I get a ton of `NoClassDefFoundError`s, and if I build them into the .jar
that creates duplicate class errors, so I am wondering if there’s some trick I can use with dependency substitution to solve this problem, or is there a simpler way that I don’t know about?spierce7
12/29/2022, 5:54 AMorg.gradle.configureondemand=true
, but now I have an issue when building my app. I create a task, and have that task depend on a task from another project. That task doesn't exist yet.
val myTask: Task = tasks.create("myTask") {
val projectB = project(":projectB")
dependsOn(projectB.tasks["jsBrowserProductionWebpack"])
doLast {
...
}
}
What is the correct way to work around this?rrva
12/29/2022, 9:15 AMthanksforallthefish
12/29/2022, 9:35 AMAn exception occurred applying plugin request [id: 'org.gradle.kotlin.kotlin-dsl', version: '3.2.7']
> Failed to apply plugin class 'org.gradle.kotlin.dsl.plugins.base.KotlinDslBasePlugin'.
> Could not create an instance of type org.gradle.kotlin.dsl.plugins.dsl.KotlinDslPluginOptions.
> 'java.lang.Object org.gradle.internal.deprecation.DeprecationMessageBuilder$DeprecateProperty$WithDeprecationTimeline.withUserManual(java.lang.String, java.lang.String)'
is? using gradle 7.6 and
plugins {
id "org.gradle.kotlin.kotlin-dsl" version "3.2.7"
id "java-gradle-plugin"
}
if I downgrade to 3.2.6 it worksIdo Flax
12/29/2022, 5:53 PM