This message was deleted.
# community-support
s
This message was deleted.
v
if (condition) { register artifact }
?
m
I’m using groovy. In my plugin I have
Copy code
void apply(Project project) {
   //... register tasks etc

   project.artifacts.add('archives', new File("path-to-file.tar.gz")) 
}
Since my condition is based on the user defined extension dsl, I set the default value:
Copy code
extension.source.convention('DEFAULT')
If I wrap
project.artifacts.add(...)
in a condition such as
if (extension.source.get() != 'DEFAULT')
the condition fails. However, I think I solved my issue with
Copy code
project.afterEvaluate {
   if (extension.source.get() != 'DEFAULT') {
     project.artifacts.add('archives', new File("path-to-file.tar.gz")) 
   } 
}
v
Using
afterEvaluate
is never a solution. It sometimes is doing symptom treatment, most often is just a lazy workaround, and always introduces timing and order problems.
Instead make a function in your extension that sets the source and where you can react to the user calling it
m
That’s the understanding I got from my research. I’m not really sure how to solve for my use-case.
Just to clarify, the user would invoke a function from the extension dsl?
v
Yes