This message was deleted.
# community-support
s
This message was deleted.
v
I have no idea about artifactory. But from what I see from a very quick look, the plugin adds a task called
artifactoryPublish
that you are configuring there. This should also fail in Groovy DSL if there is no such task as soon as this build script is evaluated. Can you provide an MCVE where you show what exactly you have with the Groovy DSL?
s
Thanks for catching that. I updated the code above. The groovy dsl is wrapped with a if condition that becomes true on CI builds.
v
Ah, ok then it should be something like
Copy code
tasks
    .withType<ArtiractoryPublishOrWhatTheTypeOfTheTaskIs>
    .matching { it.name == "artifatoryPublish" }
    .configureEach {
        publications(...)
    }
where you can even omit the
isCI
check, as it is only done if a task with that name and of that type is found. Do not omit anything like not doing the type-check and directly matching on the name or you will totally break task configuration avoidance as all tasks going through
matching
have to be realized. Like it is written at least only tasks of the specified type are always realized if present.
s
But don't I need the plugin imported for the script to compile here
tasks.withType<ArtifactoryTask>
Shouldn't I have to import the ArtifactoryTask here?
v
Yes
You need it in the class path, but you don't need to apply it
If you even must not have it in the class path (pretty stupid arbitrary restriction imho if that's the case), you could resort to using
withGroovyBuilder
for example, or writing that logic in a Groovy file that you
apply from
. But actually that'a a sacrifice imho. One of the big pros of the Kotlin DSL is, that it is typesafe and provides proper IDE support.