Search in sources :

Example 1 with OpaqueComponentIdentifier

use of org.gradle.internal.component.local.model.OpaqueComponentIdentifier in project gradle by gradle.

the class DependencyClassPathNotationConverter method maybeCreateUnderLock.

private SelfResolvingDependency maybeCreateUnderLock(final DependencyFactory.ClassPathNotation notation) {
    SelfResolvingDependency dependency = internCache.get(notation);
    if (dependency == null) {
        final Collection<File> classpath = classPathRegistry.getClassPath(notation.name()).getAsFiles();
        boolean runningFromInstallation = currentGradleInstallation.getInstallation() != null;
        FileCollectionInternal fileCollectionInternal;
        if (runningFromInstallation && notation.equals(GRADLE_API)) {
            fileCollectionInternal = new GeneratedFileCollection(notation.displayName) {

                @Override
                FileCollection generateFileCollection() {
                    try {
                        internCacheWriteLock.lock();
                        return gradleApiFileCollection(classpath);
                    } finally {
                        internCacheWriteLock.unlock();
                    }
                }
            };
        } else if (runningFromInstallation && notation.equals(GRADLE_TEST_KIT)) {
            fileCollectionInternal = new GeneratedFileCollection(notation.displayName) {

                @Override
                FileCollection generateFileCollection() {
                    try {
                        internCacheWriteLock.lock();
                        return gradleTestKitFileCollection(classpath);
                    } finally {
                        internCacheWriteLock.unlock();
                    }
                }
            };
        } else {
            fileCollectionInternal = fileResolver.resolveFiles(classpath);
        }
        dependency = instantiator.newInstance(DefaultSelfResolvingDependency.class, new OpaqueComponentIdentifier(notation.displayName), fileCollectionInternal);
        internCache.put(notation, dependency);
    }
    return dependency;
}
Also used : DefaultSelfResolvingDependency(org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency) SelfResolvingDependency(org.gradle.api.artifacts.SelfResolvingDependency) FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal) FileCollection(org.gradle.api.file.FileCollection) CompositeFileCollection(org.gradle.api.internal.file.CompositeFileCollection) OpaqueComponentIdentifier(org.gradle.internal.component.local.model.OpaqueComponentIdentifier) File(java.io.File) DefaultSelfResolvingDependency(org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency)

Example 2 with OpaqueComponentIdentifier

use of org.gradle.internal.component.local.model.OpaqueComponentIdentifier in project gradle by gradle.

the class DependencyClassPathNotationConverter method create.

private SelfResolvingDependency create(final DependencyFactory.ClassPathNotation notation) {
    boolean runningFromInstallation = currentGradleInstallation.getInstallation() != null;
    FileCollectionInternal fileCollectionInternal;
    if (runningFromInstallation && notation.equals(GRADLE_API)) {
        fileCollectionInternal = fileCollectionFactory.create(new GeneratedFileCollection(notation.displayName) {

            @Override
            Set<File> generateFileCollection() {
                return gradleApiFileCollection(getClassPath(notation));
            }
        });
    } else if (runningFromInstallation && notation.equals(GRADLE_TEST_KIT)) {
        fileCollectionInternal = fileCollectionFactory.create(new GeneratedFileCollection(notation.displayName) {

            @Override
            Set<File> generateFileCollection() {
                return gradleTestKitFileCollection(getClassPath(notation));
            }
        });
    } else {
        fileCollectionInternal = fileCollectionFactory.resolving(getClassPath(notation));
    }
    SelfResolvingDependency dependency = instantiator.newInstance(DefaultSelfResolvingDependency.class, new OpaqueComponentIdentifier(notation), fileCollectionInternal);
    SelfResolvingDependency alreadyPresent = internCache.putIfAbsent(notation, dependency);
    return alreadyPresent != null ? alreadyPresent : dependency;
}
Also used : MinimalFileSet(org.gradle.api.internal.file.collections.MinimalFileSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) DefaultSelfResolvingDependency(org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency) SelfResolvingDependency(org.gradle.api.artifacts.SelfResolvingDependency) FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal) OpaqueComponentIdentifier(org.gradle.internal.component.local.model.OpaqueComponentIdentifier) File(java.io.File)

Aggregations

File (java.io.File)2 SelfResolvingDependency (org.gradle.api.artifacts.SelfResolvingDependency)2 DefaultSelfResolvingDependency (org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency)2 FileCollectionInternal (org.gradle.api.internal.file.FileCollectionInternal)2 OpaqueComponentIdentifier (org.gradle.internal.component.local.model.OpaqueComponentIdentifier)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Set (java.util.Set)1 FileCollection (org.gradle.api.file.FileCollection)1 CompositeFileCollection (org.gradle.api.internal.file.CompositeFileCollection)1 MinimalFileSet (org.gradle.api.internal.file.collections.MinimalFileSet)1