Ross Black wrote:
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?


Not really. Could you add a JIRA issue for this?

I can't think of a good work-around, either. Is it possible to figure out at configuration time whether the api jar is needed?


--
Adam Murdoch
Gradle Developer
http://www.gradle.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to