Search in sources :

Example 1 with IvyExcludeRule

use of org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule 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 IvyExcludeRule

use of org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule in project gradle by gradle.

the class IvyDescriptorFileGenerator method writeDependencies.

private void writeDependencies(OptionalAttributeXmlWriter xmlWriter) throws IOException {
    xmlWriter.startElement("dependencies");
    for (IvyDependencyInternal dependency : dependencies) {
        String org = dependency.getOrganisation();
        String module = dependency.getModule();
        String projectPath = dependency.getProjectPath();
        ModuleVersionIdentifier resolvedVersion = versionMappingStrategy.findStrategyForVariant(dependency.getAttributes()).maybeResolveVersion(org, module, projectPath);
        if (resolvedVersion != null) {
            org = resolvedVersion.getGroup();
            module = resolvedVersion.getName();
        }
        xmlWriter.startElement("dependency").attribute("org", org).attribute("name", module).attribute("rev", resolvedVersion != null ? resolvedVersion.getVersion() : dependency.getRevision()).attribute("conf", dependency.getConfMapping());
        if (resolvedVersion != null && isDynamicVersion(dependency.getRevision())) {
            xmlWriter.attribute("revConstraint", dependency.getRevision());
        }
        if (!dependency.isTransitive()) {
            xmlWriter.attribute("transitive", "false");
        }
        for (DependencyArtifact dependencyArtifact : dependency.getArtifacts()) {
            printDependencyArtifact(dependencyArtifact, xmlWriter);
        }
        for (ExcludeRule excludeRule : dependency.getExcludeRules()) {
            writeDependencyExclude(excludeRule, xmlWriter);
        }
        xmlWriter.endElement();
    }
    for (IvyExcludeRule excludeRule : globalExcludes) {
        writeGlobalExclude(excludeRule, xmlWriter);
    }
    xmlWriter.endElement();
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) IvyDependencyInternal(org.gradle.api.publish.ivy.internal.dependency.IvyDependencyInternal) DependencyArtifact(org.gradle.api.artifacts.DependencyArtifact) ExcludeRule(org.gradle.api.artifacts.ExcludeRule) IvyExcludeRule(org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule) IvyExcludeRule(org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule)

Aggregations

IvyDependencyInternal (org.gradle.api.publish.ivy.internal.dependency.IvyDependencyInternal)2 IvyExcludeRule (org.gradle.api.publish.ivy.internal.dependency.IvyExcludeRule)2 DependencyArtifact (org.gradle.api.artifacts.DependencyArtifact)1 ExcludeRule (org.gradle.api.artifacts.ExcludeRule)1 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)1 IvyArtifact (org.gradle.api.publish.ivy.IvyArtifact)1 IvyConfiguration (org.gradle.api.publish.ivy.IvyConfiguration)1 IvyModuleDescriptorAuthor (org.gradle.api.publish.ivy.IvyModuleDescriptorAuthor)1 IvyModuleDescriptorLicense (org.gradle.api.publish.ivy.IvyModuleDescriptorLicense)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