Ben Madore
10/05/2022, 8:36 PMimplementations(libs.mylibrary.foo)
disallow: implementation("com.myorg.mylibrary:foo:1.2.3")
Tevin Jeffrey
10/10/2022, 11:03 PMefemoney
10/13/2022, 2:15 AMtoolchainManagement.jvm
extension function and imo its kinda weird to have an API that is available but fails the build by default. More and more plugin authors are encouraged to write and publish settings plugins but the experience of using these with the kotlin DSL is quite bad.Javi
10/14/2022, 10:43 PMVladimir Sitnikov
10/19/2022, 12:05 PMdoLast
”Martin
11/04/2022, 11:36 AMcom.example.FooExtension
) instead of importing it at the top of the file (import com.example.FooExtension
). Is it possible to tweak this?Taylor Smith
11/04/2022, 5:24 PMproject.findProperty()
does not work in the subproject
scope.
Same code works fine when applied directly to the subprojects, but not when using the subprojects
block and applying it to the rootProject
subprojects {
apply(plugin="com.google.cloud.tools.jib")
apply(plugin="maven-publish")
apply(plugin="com.jfrog.artifactory")
artifactory {
setContextUrl("<https://my.jfrog.io/company/>")
publish {
repository {
setProperty("repoKey", "mvn-local")
setProperty("maven", true)
// Set these in your $HOME/.gradle/gradle.properties:
setProperty("username", project.findProperty("ARTIFACTORY_USER"))
setProperty("password", project.findProperty("ARTIFACTORY_PASSWORD"))
defaults(delegateClosureOf<groovy.lang.GroovyObject> {
invokeMethod("publications", "mavenJava")
setProperty("publishPom", true)
setProperty("publishArtifacts", true)
})
}
}
resolve {
setProperty("repoKey", "mvn-local")
}
}
CristianGM
11/10/2022, 5:00 PMScript compilation
time)Rooz
11/10/2022, 10:06 PMPaul Merlin
11/17/2022, 3:49 PM.gradle.kts
editor. Code completion is fast! 🚀
This work by the Kotlin Team changes the UX so much ❤️
https://blog.jetbrains.com/idea/2022/11/intellij-idea-2022-3-beta-2/#Improved_IDE_performance_for_KotlinClaude Brisson
11/18/2022, 2:31 PM./gradlew -i :skorm-jdbc:publishToMavenLocal
[...]
> Task :skorm-jdbc:publishToMavenLocal
Skipping task ':skorm-jdbc:publishToMavenLocal' as it has no actions.
I'm using 7.5.1.Slackbot
11/18/2022, 2:34 PMAmanda
11/29/2022, 10:26 PMŁukasz Wasylkowski
12/05/2022, 11:00 AMTaylor Smith
12/15/2022, 10:17 PMPierre Ayfri
12/30/2022, 9:16 AMkotlin {
jvmToolchain(17)
}
And this
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
?ScalaWilliam
01/08/2023, 1:24 PM/project/Definitions.scala
, you can reference the objects/values defined in that file from the main build file /build.sbt
. How can this be done in Gradle-Kotlin?nissa faheem
01/17/2023, 10:08 AMorg/jetbrains/kotlin/gradle/tasks/KotlinCompileorg.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:prepareDebugKotlinCompileTask'. Caused by: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/gradle/tasks/KotlinCompile at com.android.build.gradle.tasks.PrepareKotlinCompileTask.doTaskAction(PrepareKotlinCompileTask.kt:65) at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(AndroidVariantTask.kt:74) at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(AndroidVariantTask.kt:34) at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:91) at com.android.build.gradle.internal.tasks.NonIncrementalTask.taskAction(NonIncrementalTask.kt:5 org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:399) at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:94) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52) at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:356) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343) at Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.gradle.tasks.KotlinCompile (edited)
Farshid Fakhri
01/21/2023, 1:10 AMJohn
02/01/2023, 7:09 PMpublic inline fun <T : org.gradle.api.artifacts.ModuleDependency> org.gradle.api.artifacts.dsl.DependencyHandler.add(configuration: kotlin.String, dependency: T, dependencyConfiguration: T.() -> kotlin.Unit): T { /* compiled code */ }
public inline fun org.gradle.api.artifacts.dsl.DependencyHandler.add(configuration: kotlin.String, dependencyNotation: kotlin.String, dependencyConfiguration: org.gradle.api.artifacts.ExternalModuleDependency.() -> kotlin.Unit): org.gradle.api.artifacts.ExternalModuleDependency { /* compiled code */ }
🧵Mark Maxey
02/10/2023, 10:57 PMval dependencyArtifact = Action<DependencyArtifact> { name = "artifact-name" }
project.dependencies { add("implementation", "group:artifact:1.2.3") { artifact(dependencyArtifact) } }
but I can't quite find the syntax for things that take a `Closure`:
val bintray = BintrayExtension(project) // I constructed it like this purely as an example knowing this isn't the way you'd do it in real life.
val bintrayPackageConfig = Closure<BintrayExtension.PackageConfig> { repo = "repossessed" } // WRONG! How do I populate a type specific Closure?
bintray.pkg(closureOf<BintrayExtension.PackageConfig> { repo = "repossessed" })
bintray.pkg(bintrayPackageConfig)
Note I'm not using either closureOf<T> {}
using delegateClosureOf<T> {}
. Since I haven't tried to run it yet, perhaps my first Action
example only compiles but doesn't work at runtime. The second Closure
example doesn't compile because the Closure
doesn't know what a repo
is.
It doesn't give me confidence when I see documentation like this:
There sometimes isn’t a good way to tell, from looking at the source code, which version to use. Usually, if you get awithNullPointerException
, usingclosureOf<T> {}
will resolve the problem.delegateClosureOf<T> {}
Igor Wojda
02/13/2023, 4:16 PMintegrationTest
. I am unable to access the CommandProcessor
class defined in the main
source set inside integrationTest
source set.
My goal is to use code from main
source set (but not test
source set) and use prod classes to run some tests.
What am I missing here?
build.gradle.kts:
plugins {
kotlin("jvm") version "1.8.0"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("reflect"))
implementation("io.insert-koin:koin-test-junit5:3.3.3")
testImplementation(kotlin("test-junit5"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
testImplementation("io.mockk:mockk:1.13.2")
testImplementation("org.amshove.kluent:kluent:1.72")
}
val integrationTest: SourceSet by sourceSets.creating
configurations[integrationTest.implementationConfigurationName].extendsFrom(configurations.testImplementation.get())
configurations[integrationTest.runtimeOnlyConfigurationName].extendsFrom(configurations.testRuntimeOnly.get())
tasks.test {
useJUnitPlatform()
}
val integrationTestTask = tasks.register<Test>("integrationTest") {
description = "Runs integration tests."
group = "verification"
useJUnitPlatform()
testClassesDirs = integrationTest.output.classesDirs
classpath = configurations[integrationTest.runtimeClasspathConfigurationName] + integrationTest.output
}
Benjamin Muschko
02/13/2023, 4:53 PMpshakhov
02/14/2023, 7:57 AMproject.relativePath
or resolve
, or any way like project.subprojects
(some another entity like subprojects)?John
02/15/2023, 1:20 AM/**
* A version of maybeCreate that allows you to pass a configuration lambda that will only run when the task is created
*/
inline fun <reified U : Task> TaskContainer.maybeCreate(name: String, noinline config: U.() -> Unit): U {
val existing: Task? = findByName(name)
return if (existing != null) {
Transformers.cast<U, Any>(U::class.java).transform(existing)
} else {
create(name, U::class.java, config)
}
}
Igor Wojda
02/17/2023, 9:58 PMdetektBase
task that is used to run detekt
. Based on the autoCorrect
param this task either run checks or run checks and applies auto correct.
tasks.register("detektBase", Detekt::class) {
val autoCorrectParam = project.hasProperty("autoCorrect")
description = "Custom detekt for to check all modules"
autoCorrect = autoCorrectParam
//bunch of other detekt config params
}
How can I split this into two separate tasks?
tasks.register("detektCheck", Detekt::class) {
//call detektBase with autoCorrectParam false
}
tasks.register("detektApply", Detekt::class) {
//call detektBase with autoCorrectParam true
}
Shalom Ben-Zvi Kazaz
02/18/2023, 6:55 PMimport org.apache.tools.ant.filters.ReplaceTokens
processResources {
with copySpec {
from 'src/main/resources'
include 'application.properties'
project.properties.findAll().each {
prop ->
if (prop.value != null) {
filter(ReplaceTokens, tokens: [ (prop.key): prop.value])
filter(ReplaceTokens, tokens: [ ('project.' + prop.key): prop.value])
}
}
}
}
Luc-Antoine Girardin
02/24/2023, 7:34 PM.properties
file (say for example custom.properties
) from settings.gradle.kts
, and use those properties in a module's build.gradle.kts
?Kalpesh Chandora
02/27/2023, 7:00 AMBenoît
03/13/2023, 12:57 PMA problem occurred configuring root project 'wire'.
> Could not determine the dependencies of null.
> Could not resolve all dependencies for configuration ':classpath'.
> Dependencies can not be declared against the `testCompileClasspath` configuration.
Using the debugger I found the failure:
org.gradle.internal.resolve.ArtifactNotFoundException: Could not find org.gradle.kotlin.kotlin-dsl.gradle.plugin-4.0.6.jar (org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:4.0.6).
The coordinates don’t look right to me, why is the name including the group again?
I started getting this error having bumped a few dependency versions including gradle from 7.4
to 8.0.2
I’m not setting explicitely this dependency anyway and I’m a bit stuck. Would anyone know what is up?Benoît
03/13/2023, 12:57 PMA problem occurred configuring root project 'wire'.
> Could not determine the dependencies of null.
> Could not resolve all dependencies for configuration ':classpath'.
> Dependencies can not be declared against the `testCompileClasspath` configuration.
Using the debugger I found the failure:
org.gradle.internal.resolve.ArtifactNotFoundException: Could not find org.gradle.kotlin.kotlin-dsl.gradle.plugin-4.0.6.jar (org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:4.0.6).
The coordinates don’t look right to me, why is the name including the group again?
I started getting this error having bumped a few dependency versions including gradle from 7.4
to 8.0.2
I’m not setting explicitely this dependency anyway and I’m a bit stuck. Would anyone know what is up?Vampire
03/13/2023, 1:03 PMplugins { ... }
block to an actual code artifact. That is perfectly fine and will also be found if you have the Gradle Plugin Portal or any other repository where it is present as plugin repository.
The error
on the other hand means that you try to declare a dependency forDependencies can not be declared against the `testCompileClasspath` configuration.
testCompileClasspath
which you shouldn't do and is checked with Gradle 8 now.
You should declare it against testImplementation
, testApi
, or testCompileOnly
instead. For kotlin-dsl
most probably testCompileOnly
.Benoît
03/13/2023, 1:04 PMtestCompileClasspath
in my project and I cannot find where it’s setbuildSrc
it seems. I’ll see if I can get rid of it as I don’t use it for nowVampire
03/13/2023, 1:06 PMBenoît
03/13/2023, 2:35 PM