Hi Adam,

as stated in the forum [1], we  partly generate Java code using JAXB. Based on 
Java package names we then create different jars, each of which is published as 
Ivy artifact. If the process generates no classes for a certain Java package 
name, we don't want to create the (empty) jar and consequently don't want to 
add it as an Ivy artifact.

If the code wasn't generated I agree that it would be easy to add a 
configuration-time condition (check whether a corresponding source sub-folder 
exists). In this case however the package(s) for which Java classes are 
generated are hidden in JAXB-configuration files (.xjb). Parsing these files 
during configuration time would essentially double a part of the code 
generation process, the part that calculates the packages - which seems a bad 
idea for reasons of consistency. (Just to give you the right impression - we 
have a few hundreds of projects to be built, following the same conventions. So 
figuring this out manually is also not really an option.) I hope you can see 
our requirements behind this.

Also I'm pretty sure that  there are similar other uses to an execution-time 
condition for publications like there are for tasks (e.g. depending on the 
output of other tasks).

Best regards,
Tim Enderling

[1] 
http://forums.gradle.org/gradle/topics/should_disabling_a_task_automatically_remove_any_artifact_it_might_publish

From: Adam Murdoch [mailto:adam.murd...@gradleware.com]
Sent: Montag, 12. August 2013 22:34
To: dev@gradle.codehaus.org
Subject: Re: [gradle-dev] Dynamically enabling publications.


I'm not convinced about this change. Why can't you just use an if statement?

publishing {
     publications {
        somePublication(IvyPublication) {
            if (someCondition) { artefact ... }
        }
     }
}

--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com



Reply via email to