Search in sources :

Example 1 with DocumentationRegistry

use of org.gradle.api.internal.DocumentationRegistry in project gradle by gradle.

the class PublicationErrorChecker method checkForUnpublishableAttributes.

/**
 * Checks that the given component does not have any attributes that are not allowed to be published.
 *
 * @param component the component to check
 * @param documentationRegistry for creating helpful links in error messages upon failing the check
 * @throws PublishException if the component uses attributes invalid for publication
 */
public static void checkForUnpublishableAttributes(SoftwareComponentInternal component, DocumentationRegistry documentationRegistry) {
    for (final UsageContext usageContext : component.getUsages()) {
        Optional<Attribute<?>> category = usageContext.getAttributes().keySet().stream().filter(a -> Category.CATEGORY_ATTRIBUTE.getName().equals(a.getName())).findFirst();
        category.ifPresent(c -> {
            Object value = usageContext.getAttributes().getAttribute(c);
            if (value != null && Category.VERIFICATION.equals(value.toString())) {
                throw new PublishException("Cannot publish module metadata for component '" + component.getName() + "' which would include a variant '" + usageContext.getName() + "' that contains a '" + Category.CATEGORY_ATTRIBUTE.getName() + "' attribute with a value of '" + Category.VERIFICATION + "'.  This attribute is reserved for test verification output and is not publishable.  See: " + documentationRegistry.getDocumentationFor("variant_attributes.html", "sec:verification_category"));
            }
        });
    }
}
Also used : SoftwareComponentInternal(org.gradle.api.internal.component.SoftwareComponentInternal) Attribute(org.gradle.api.attributes.Attribute) Category(org.gradle.api.attributes.Category) Optional(java.util.Optional) DocumentationRegistry(org.gradle.api.internal.DocumentationRegistry) UsageContext(org.gradle.api.internal.component.UsageContext) PublishException(org.gradle.api.artifacts.PublishException) UsageContext(org.gradle.api.internal.component.UsageContext) Attribute(org.gradle.api.attributes.Attribute) PublishException(org.gradle.api.artifacts.PublishException)

Example 2 with DocumentationRegistry

use of org.gradle.api.internal.DocumentationRegistry in project gradle by gradle.

the class DefaultFileOperations method createSimple.

public static DefaultFileOperations createSimple(FileResolver fileResolver, FileCollectionFactory fileTreeFactory, ServiceRegistry services) {
    Instantiator instantiator = services.get(Instantiator.class);
    ObjectFactory objectFactory = services.get(ObjectFactory.class);
    FileSystem fileSystem = services.get(FileSystem.class);
    DirectoryFileTreeFactory directoryFileTreeFactory = services.get(DirectoryFileTreeFactory.class);
    StreamHasher streamHasher = services.get(StreamHasher.class);
    FileHasher fileHasher = services.get(FileHasher.class);
    ApiTextResourceAdapter.Factory textResourceAdapterFactory = services.get(ApiTextResourceAdapter.Factory.class);
    Factory<PatternSet> patternSetFactory = services.getFactory(PatternSet.class);
    Deleter deleter = services.get(Deleter.class);
    DocumentationRegistry documentationRegistry = services.get(DocumentationRegistry.class);
    ProviderFactory providers = services.get(ProviderFactory.class);
    DefaultResourceHandler.Factory resourceHandlerFactory = DefaultResourceHandler.Factory.from(fileResolver, fileSystem, null, textResourceAdapterFactory);
    return new DefaultFileOperations(fileResolver, null, instantiator, directoryFileTreeFactory, streamHasher, fileHasher, resourceHandlerFactory, fileTreeFactory, objectFactory, fileSystem, patternSetFactory, deleter, documentationRegistry, providers);
}
Also used : Deleter(org.gradle.internal.file.Deleter) Instantiator(org.gradle.internal.reflect.Instantiator) StreamHasher(org.gradle.internal.hash.StreamHasher) FileHasher(org.gradle.internal.hash.FileHasher) ObjectFactory(org.gradle.api.model.ObjectFactory) DirectoryFileTreeFactory(org.gradle.api.internal.file.collections.DirectoryFileTreeFactory) DefaultResourceHandler(org.gradle.api.internal.resources.DefaultResourceHandler) FileSystem(org.gradle.internal.nativeintegration.filesystem.FileSystem) ProviderFactory(org.gradle.api.provider.ProviderFactory) DocumentationRegistry(org.gradle.api.internal.DocumentationRegistry) ApiTextResourceAdapter(org.gradle.api.internal.resources.ApiTextResourceAdapter) PatternSet(org.gradle.api.tasks.util.PatternSet)

Aggregations

DocumentationRegistry (org.gradle.api.internal.DocumentationRegistry)2 Optional (java.util.Optional)1 PublishException (org.gradle.api.artifacts.PublishException)1 Attribute (org.gradle.api.attributes.Attribute)1 Category (org.gradle.api.attributes.Category)1 SoftwareComponentInternal (org.gradle.api.internal.component.SoftwareComponentInternal)1 UsageContext (org.gradle.api.internal.component.UsageContext)1 DirectoryFileTreeFactory (org.gradle.api.internal.file.collections.DirectoryFileTreeFactory)1 ApiTextResourceAdapter (org.gradle.api.internal.resources.ApiTextResourceAdapter)1 DefaultResourceHandler (org.gradle.api.internal.resources.DefaultResourceHandler)1 ObjectFactory (org.gradle.api.model.ObjectFactory)1 ProviderFactory (org.gradle.api.provider.ProviderFactory)1 PatternSet (org.gradle.api.tasks.util.PatternSet)1 Deleter (org.gradle.internal.file.Deleter)1 FileHasher (org.gradle.internal.hash.FileHasher)1 StreamHasher (org.gradle.internal.hash.StreamHasher)1 FileSystem (org.gradle.internal.nativeintegration.filesystem.FileSystem)1 Instantiator (org.gradle.internal.reflect.Instantiator)1