Search in sources :

Example 1 with IvyModuleDescriptorAuthor

use of org.gradle.api.publish.ivy.IvyModuleDescriptorAuthor in project gradle by gradle.

the class GenerateIvyDescriptor method doGenerate.

@TaskAction
public void doGenerate() {
    IvyModuleDescriptorSpecInternal descriptorInternal = toIvyModuleDescriptorInternal(getDescriptor());
    IvyDescriptorFileGenerator ivyGenerator = new IvyDescriptorFileGenerator(descriptorInternal.getProjectIdentity(), descriptorInternal.writeGradleMetadataMarker(), descriptorInternal.getVersionMappingStrategy());
    ivyGenerator.setStatus(descriptorInternal.getStatus());
    ivyGenerator.setBranch(descriptorInternal.getBranch());
    ivyGenerator.setExtraInfo(descriptorInternal.getExtraInfo().asMap());
    for (IvyModuleDescriptorAuthor ivyAuthor : descriptorInternal.getAuthors()) {
        ivyGenerator.addAuthor(ivyAuthor);
    }
    for (IvyModuleDescriptorLicense ivyLicense : descriptorInternal.getLicenses()) {
        ivyGenerator.addLicense(ivyLicense);
    }
    ivyGenerator.setDescription(descriptorInternal.getDescription());
    for (IvyConfiguration ivyConfiguration : descriptorInternal.getConfigurations()) {
        ivyGenerator.addConfiguration(ivyConfiguration);
    }
    for (IvyArtifact ivyArtifact : descriptorInternal.getArtifacts()) {
        ivyGenerator.addArtifact(ivyArtifact);
    }
    for (IvyDependencyInternal ivyDependency : descriptorInternal.getDependencies()) {
        ivyGenerator.addDependency(ivyDependency);
    }
    for (IvyExcludeRule excludeRule : descriptorInternal.getGlobalExcludes()) {
        ivyGenerator.addGlobalExclude(excludeRule);
    }
    ivyGenerator.withXml(descriptorInternal.getXmlAction()).writeTo(getDestination());
}
Also used : IvyDescriptorFileGenerator(org.gradle.api.publish.ivy.internal.publisher.IvyDescriptorFileGenerator) IvyDependencyInternal(org.gradle.api.publish.ivy.internal.dependency.IvyDependencyInternal) IvyModuleDescriptorSpecInternal(org.gradle.api.publish.ivy.internal.publication.IvyModuleDescriptorSpecInternal) IvyModuleDescriptorAuthor(org.gradle.api.publish.ivy.IvyModuleDescriptorAuthor) IvyModuleDescriptorLicense(org.gradle.api.publish.ivy.IvyModuleDescriptorLicense) IvyConfiguration(org.gradle.api.publish.ivy.IvyConfiguration) IvyArtifact(org.gradle.api.publish.ivy.IvyArtifact) IvyExcludeRule(org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with IvyModuleDescriptorAuthor

use of org.gradle.api.publish.ivy.IvyModuleDescriptorAuthor in project gradle by gradle.

the class IvyDescriptorFileGenerator method writeDescriptor.

private void writeDescriptor(final Writer writer) throws IOException {
    OptionalAttributeXmlWriter xmlWriter = new OptionalAttributeXmlWriter(writer, "  ", IVY_FILE_ENCODING);
    xmlWriter.startElement("ivy-module").attribute("version", "2.0");
    if (usesClassifier()) {
        xmlWriter.attribute("xmlns:m", "http://ant.apache.org/ivy/maven");
    }
    xmlWriter.startElement("info").attribute("organisation", projectIdentity.getOrganisation()).attribute("module", projectIdentity.getModule()).attribute("branch", branch).attribute("revision", projectIdentity.getRevision()).attribute("status", status).attribute("publication", ivyDateFormat.format(new Date()));
    for (IvyModuleDescriptorLicense license : licenses) {
        xmlWriter.startElement("license").attribute("name", license.getName().getOrNull()).attribute("url", license.getUrl().getOrNull()).endElement();
    }
    for (IvyModuleDescriptorAuthor author : authors) {
        xmlWriter.startElement("ivyauthor").attribute("name", author.getName().getOrNull()).attribute("url", author.getUrl().getOrNull()).endElement();
    }
    if (description != null) {
        xmlWriter.startElement("description").attribute("homepage", description.getHomepage().getOrNull()).characters(description.getText().getOrElse("")).endElement();
    }
    if (extraInfo != null) {
        for (Map.Entry<QName, String> entry : extraInfo.entrySet()) {
            if (entry.getKey() != null) {
                xmlWriter.startElement("ns:" + entry.getKey().getLocalPart()).attribute("xmlns:ns", entry.getKey().getNamespaceURI()).characters(entry.getValue()).endElement();
            }
        }
    }
    xmlWriter.endElement();
    writeConfigurations(xmlWriter);
    writePublications(xmlWriter);
    writeDependencies(xmlWriter);
    xmlWriter.endElement();
}
Also used : QName(javax.xml.namespace.QName) IvyModuleDescriptorLicense(org.gradle.api.publish.ivy.IvyModuleDescriptorLicense) IvyModuleDescriptorAuthor(org.gradle.api.publish.ivy.IvyModuleDescriptorAuthor) Map(java.util.Map) Date(java.util.Date)

Aggregations

IvyModuleDescriptorAuthor (org.gradle.api.publish.ivy.IvyModuleDescriptorAuthor)2 IvyModuleDescriptorLicense (org.gradle.api.publish.ivy.IvyModuleDescriptorLicense)2 Date (java.util.Date)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1 IvyArtifact (org.gradle.api.publish.ivy.IvyArtifact)1 IvyConfiguration (org.gradle.api.publish.ivy.IvyConfiguration)1 IvyDependencyInternal (org.gradle.api.publish.ivy.internal.dependency.IvyDependencyInternal)1 IvyExcludeRule (org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule)1 IvyModuleDescriptorSpecInternal (org.gradle.api.publish.ivy.internal.publication.IvyModuleDescriptorSpecInternal)1 IvyDescriptorFileGenerator (org.gradle.api.publish.ivy.internal.publisher.IvyDescriptorFileGenerator)1 TaskAction (org.gradle.api.tasks.TaskAction)1