Search in sources :

Example 1 with MissingResourceException

use of org.gradle.api.resources.MissingResourceException in project gradle by gradle.

the class MavenMetadataLoader method parseMavenMetadataInfo.

private void parseMavenMetadataInfo(final ExternalResourceName metadataLocation, final MavenMetadata metadata) throws IOException {
    ExternalResource resource = cacheAwareExternalResourceAccessor.getResource(metadataLocation, null, new CacheAwareExternalResourceAccessor.ResourceFileStore() {

        @Override
        public LocallyAvailableResource moveIntoCache(File downloadedResource) {
            String key = metadataLocation.toString();
            return resourcesFileStore.move(key, downloadedResource);
        }
    }, null);
    if (resource == null) {
        throw new MissingResourceException(metadataLocation.getUri(), String.format("Maven meta-data not available at %s", metadataLocation));
    }
    parseMavenMetadataInto(resource, metadata);
}
Also used : LocallyAvailableResource(org.gradle.internal.resource.local.LocallyAvailableResource) MissingResourceException(org.gradle.api.resources.MissingResourceException) ExternalResource(org.gradle.internal.resource.ExternalResource) CacheAwareExternalResourceAccessor(org.gradle.internal.resource.transfer.CacheAwareExternalResourceAccessor) File(java.io.File)

Example 2 with MissingResourceException

use of org.gradle.api.resources.MissingResourceException in project gradle by gradle.

the class MavenVersionLister method listVersions.

public void listVersions(ModuleIdentifier module, List<ResourcePattern> patterns, BuildableModuleVersionListingResolveResult result) {
    final Set<ExternalResourceName> searched = Sets.newHashSet();
    List<String> versions = Lists.newArrayList();
    boolean hasResult = false;
    for (ResourcePattern pattern : patterns) {
        ExternalResourceName metadataLocation = pattern.toModulePath(module).resolve("maven-metadata.xml");
        if (searched.add(metadataLocation)) {
            result.attempted(metadataLocation);
            try {
                MavenMetadata mavenMetaData = mavenMetadataLoader.load(metadataLocation);
                versions.addAll(mavenMetaData.versions);
                hasResult = true;
            } catch (MissingResourceException e) {
            // Continue
            }
        }
    }
    if (hasResult) {
        result.listed(versions);
    }
}
Also used : ExternalResourceName(org.gradle.internal.resource.ExternalResourceName) ResourcePattern(org.gradle.api.internal.artifacts.repositories.resolver.ResourcePattern) MissingResourceException(org.gradle.api.resources.MissingResourceException)

Example 3 with MissingResourceException

use of org.gradle.api.resources.MissingResourceException in project gradle by gradle.

the class BuildLayoutFactory method getLayoutFor.

/**
 * Determines the layout of the build, given a current directory and some other configuration.
 */
public BuildLayout getLayoutFor(BuildLayoutConfiguration configuration) {
    if (configuration.isUseEmptySettings()) {
        return buildLayoutFrom(configuration, null);
    }
    File explicitSettingsFile = configuration.getSettingsFile();
    if (explicitSettingsFile != null) {
        if (!explicitSettingsFile.isFile()) {
            throw new MissingResourceException(explicitSettingsFile.toURI(), String.format("Could not read settings file '%s' as it does not exist.", explicitSettingsFile.getAbsolutePath()));
        }
        return buildLayoutFrom(configuration, explicitSettingsFile);
    }
    File currentDir = configuration.getCurrentDir();
    boolean searchUpwards = configuration.isSearchUpwards();
    return getLayoutFor(currentDir, searchUpwards ? null : currentDir.getParentFile());
}
Also used : MissingResourceException(org.gradle.api.resources.MissingResourceException) File(java.io.File)

Aggregations

MissingResourceException (org.gradle.api.resources.MissingResourceException)3 File (java.io.File)2 ResourcePattern (org.gradle.api.internal.artifacts.repositories.resolver.ResourcePattern)1 ExternalResource (org.gradle.internal.resource.ExternalResource)1 ExternalResourceName (org.gradle.internal.resource.ExternalResourceName)1 LocallyAvailableResource (org.gradle.internal.resource.local.LocallyAvailableResource)1 CacheAwareExternalResourceAccessor (org.gradle.internal.resource.transfer.CacheAwareExternalResourceAccessor)1