Hi,

Is there a way to conditionally add an artifact to a configuration, where
the condition is evaluated at runtime?
eg.  I only want to add an artifact if a specific directory exists.

I was hoping the following would work (but it does not):
---
        project.configurations {
            api
        }

        Task apiTask = project.task('apiJar', type: Jar, dependsOn:
'classes') {
            fileSet(dir: project.apiClassesDir)
        }
        apiTask.onlyIf {project.apiClassesDir.exists()}

        project.artifacts {
            api apiTask
        }
---

The apiJar task correctly only generates the jar if the directory exists,
but the artifact handler always expects that the file specified by the
apiJar task exists even if the task has not run.

Is there some other way to achieve this?


Thanks,
Ross

Reply via email to