Search in sources :

Example 1 with DependencySpec

use of org.gradle.platform.base.DependencySpec in project gradle by gradle.

the class JvmLocalLibraryMetaDataAdapter method createLocalComponentMetaData.

@Override
@SuppressWarnings("unchecked")
public DefaultLibraryLocalComponentMetadata createLocalComponentMetaData(Binary selectedBinary, String projectPath, boolean toAssembly) {
    EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage = new EnumMap<UsageKind, Iterable<DependencySpec>>(UsageKind.class);
    EnumMap<UsageKind, List<PublishArtifact>> artifacts = new EnumMap<UsageKind, List<PublishArtifact>>(UsageKind.class);
    initializeUsages(dependenciesPerUsage, artifacts);
    if (selectedBinary instanceof JarBinarySpecInternal) {
        JarBinarySpecInternal jarBinarySpec = (JarBinarySpecInternal) selectedBinary;
        createJarBinarySpecLocalComponentMetaData(artifacts, jarBinarySpec, dependenciesPerUsage, toAssembly);
    }
    if (selectedBinary instanceof WithJvmAssembly) {
        // a local component that provides a JVM assembly
        JvmAssembly assembly = ((WithJvmAssembly) selectedBinary).getAssembly();
        createJvmAssemblyLocalComponentMetaData(artifacts, assembly, dependenciesPerUsage, toAssembly);
    }
    return createResolvedMetaData((BinarySpecInternal) selectedBinary, projectPath, dependenciesPerUsage, artifacts);
}
Also used : JarBinarySpecInternal(org.gradle.jvm.internal.JarBinarySpecInternal) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) JvmAssembly(org.gradle.jvm.internal.JvmAssembly) DependencySpec(org.gradle.platform.base.DependencySpec) LinkedList(java.util.LinkedList) List(java.util.List) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) DefaultPublishArtifact(org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact) EnumMap(java.util.EnumMap)

Example 2 with DependencySpec

use of org.gradle.platform.base.DependencySpec in project gradle by gradle.

the class DefaultJvmBinarySpec method collectDependencies.

public static List<DependencySpec> collectDependencies(final BinarySpec binary, @Nullable final SourceComponentSpec owner, final Collection<DependencySpec>... specificDependencies) {
    List<DependencySpec> dependencies = Lists.newArrayList();
    if (specificDependencies != null) {
        for (Collection<DependencySpec> deps : specificDependencies) {
            dependencies.addAll(deps);
        }
    }
    Collection<LanguageSourceSet> binarySources = binary.getSources().values();
    Iterable<LanguageSourceSet> sourceSets = owner != null ? Iterables.concat(owner.getSources().values(), binarySources) : binarySources;
    for (LanguageSourceSet sourceSet : sourceSets) {
        if (sourceSet instanceof DependentSourceSet) {
            dependencies.addAll(((DependentSourceSet) sourceSet).getDependencies().getDependencies());
        }
    }
    return dependencies;
}
Also used : DependentSourceSet(org.gradle.language.base.DependentSourceSet) LanguageSourceSet(org.gradle.language.base.LanguageSourceSet) DependencySpec(org.gradle.platform.base.DependencySpec)

Example 3 with DependencySpec

use of org.gradle.platform.base.DependencySpec in project gradle by gradle.

the class JvmTestSuiteBasePlugin method runtimeDependencies.

private static List<DependencySpec> runtimeDependencies(JvmTestSuiteBinarySpecInternal testBinary) {
    List<DependencySpec> dependencies = Lists.newArrayList(testBinary.getDependencies());
    JvmBinarySpec testedBinary = testBinary.getTestedBinary();
    dependencies.add(DefaultLibraryBinaryDependencySpec.of(testBinary.getId()));
    if (testedBinary != null) {
        JvmBinarySpecInternal binary = (JvmBinarySpecInternal) testedBinary;
        LibraryBinaryIdentifier id = binary.getId();
        dependencies.add(DefaultLibraryBinaryDependencySpec.of(id));
    }
    addSourceSetSpecificDependencies(dependencies, testBinary.getSources());
    addSourceSetSpecificDependencies(dependencies, testBinary.getTestSuite().getSources());
    return dependencies;
}
Also used : JvmBinarySpec(org.gradle.jvm.JvmBinarySpec) LibraryBinaryIdentifier(org.gradle.api.artifacts.component.LibraryBinaryIdentifier) DefaultLibraryBinaryIdentifier(org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier) DependencySpec(org.gradle.platform.base.DependencySpec) DefaultLibraryBinaryDependencySpec(org.gradle.platform.base.internal.DefaultLibraryBinaryDependencySpec) JvmBinarySpecInternal(org.gradle.jvm.internal.JvmBinarySpecInternal)

Example 4 with DependencySpec

use of org.gradle.platform.base.DependencySpec in project gradle by gradle.

the class JvmLocalLibraryMetaDataAdapter method createJarBinarySpecLocalComponentMetaData.

@SuppressWarnings("unchecked")
private void createJarBinarySpecLocalComponentMetaData(EnumMap<UsageKind, List<PublishArtifact>> artifacts, JarBinarySpecInternal jarBinarySpec, EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage, boolean toAssembly) {
    JarFile apiJar = jarBinarySpec.getApiJar();
    configureUsageMetadata(UsageKind.API, jarBinarySpec.getApiDependencies(), dependenciesPerUsage);
    JarFile runtimeJar = jarBinarySpec.getRuntimeJar();
    JvmLibrarySpec library = jarBinarySpec.getLibrary();
    configureUsageMetadata(UsageKind.RUNTIME, library != null ? collectDependencies(jarBinarySpec, library, library.getDependencies().getDependencies(), jarBinarySpec.getApiDependencies()) : Collections.<DependencySpec>emptyList(), dependenciesPerUsage);
    if (!toAssembly) {
        addArtifact(UsageKind.API, apiJar, artifacts);
        addArtifact(UsageKind.RUNTIME, runtimeJar, artifacts);
    }
}
Also used : JvmLibrarySpec(org.gradle.jvm.JvmLibrarySpec) DependencySpec(org.gradle.platform.base.DependencySpec) JarFile(org.gradle.jvm.internal.JarFile)

Aggregations

DependencySpec (org.gradle.platform.base.DependencySpec)4 EnumMap (java.util.EnumMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)1 LibraryBinaryIdentifier (org.gradle.api.artifacts.component.LibraryBinaryIdentifier)1 DefaultPublishArtifact (org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact)1 DefaultLibraryBinaryIdentifier (org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier)1 JvmBinarySpec (org.gradle.jvm.JvmBinarySpec)1 JvmLibrarySpec (org.gradle.jvm.JvmLibrarySpec)1 JarBinarySpecInternal (org.gradle.jvm.internal.JarBinarySpecInternal)1 JarFile (org.gradle.jvm.internal.JarFile)1 JvmAssembly (org.gradle.jvm.internal.JvmAssembly)1 JvmBinarySpecInternal (org.gradle.jvm.internal.JvmBinarySpecInternal)1 WithJvmAssembly (org.gradle.jvm.internal.WithJvmAssembly)1 DependentSourceSet (org.gradle.language.base.DependentSourceSet)1 LanguageSourceSet (org.gradle.language.base.LanguageSourceSet)1 DefaultLibraryBinaryDependencySpec (org.gradle.platform.base.internal.DefaultLibraryBinaryDependencySpec)1