use of org.gradle.api.artifacts.type.ArtifactTypeDefinition in project gradle by gradle.
the class DefaultArtifactTypeRegistry method visitArtifactTypes.
@Override
public void visitArtifactTypes(Consumer<? super ImmutableAttributes> action) {
Set<ImmutableAttributes> seen = new HashSet<>();
if (artifactTypeDefinitions != null) {
for (ArtifactTypeDefinition artifactTypeDefinition : artifactTypeDefinitions) {
ImmutableAttributes attributes = ((AttributeContainerInternal) artifactTypeDefinition.getAttributes()).asImmutable();
attributes = attributesFactory.concat(attributesFactory.of(ARTIFACT_TYPE_ATTRIBUTE, artifactTypeDefinition.getName()), attributes);
if (seen.add(attributes)) {
action.accept(attributes);
}
}
}
for (ArtifactTransformRegistration transform : transformRegistry.getTransforms()) {
AttributeContainerInternal sourceAttributes = transform.getFrom();
String format = sourceAttributes.getAttribute(ARTIFACT_TYPE_ATTRIBUTE);
// Some format that is not already registered
if (format != null) {
ImmutableAttributes attributes = sourceAttributes.asImmutable();
if (seen.add(attributes)) {
action.accept(attributes);
}
}
}
}
use of org.gradle.api.artifacts.type.ArtifactTypeDefinition in project crate by crate.
the class JdkDownloadPlugin method apply.
@Override
public void apply(Project project) {
project.getDependencies().getArtifactTypes().maybeCreate(ArtifactTypeDefinition.ZIP_TYPE);
project.getDependencies().registerTransform(UnzipTransform.class, transformSpec -> {
transformSpec.getFrom().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.ZIP_TYPE);
transformSpec.getTo().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE);
});
ArtifactTypeDefinition tarArtifactTypeDefinition = project.getDependencies().getArtifactTypes().maybeCreate("tar.gz");
project.getDependencies().registerTransform(SymbolicLinkPreservingUntarTransform.class, transformSpec -> {
transformSpec.getFrom().attribute(ArtifactAttributes.ARTIFACT_FORMAT, tarArtifactTypeDefinition.getName());
transformSpec.getTo().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE);
});
NamedDomainObjectContainer<Jdk> jdksContainer = project.container(Jdk.class, name -> {
Configuration configuration = project.getConfigurations().create("jdk_" + name);
configuration.setCanBeConsumed(false);
configuration.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE);
Jdk jdk = new Jdk(name, configuration, project.getObjects());
configuration.defaultDependencies(dependencies -> {
jdk.finalizeValues();
setupRepository(project, jdk);
dependencies.add(project.getDependencies().create(dependencyNotation(jdk)));
});
return jdk;
});
project.getExtensions().add(EXTENSION_NAME, jdksContainer);
}
Aggregations