Search in sources :

Example 1 with LibraryBinaryIdentifier

use of org.gradle.api.artifacts.component.LibraryBinaryIdentifier 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 2 with LibraryBinaryIdentifier

use of org.gradle.api.artifacts.component.LibraryBinaryIdentifier in project gradle by gradle.

the class JvmTestSuiteBasePlugin method createResolveContext.

private static JvmLibraryResolveContext createResolveContext(JvmTestSuiteBinarySpecInternal testBinary, ModelSchema<? extends JvmTestSuiteBinarySpec> schema, ImmutableModuleIdentifierFactory moduleIdentifierFactory) {
    // TODO:Cedric find out why if we use the same ID directly, it fails resolution by trying to get the artifacts
    // from the resolving metadata instead of the resolved metadata
    LibraryBinaryIdentifier id = testBinary.getId();
    LibraryBinaryIdentifier thisId = new DefaultLibraryBinaryIdentifier(id.getProjectPath(), id.getLibraryName() + "Test", id.getVariant());
    return new JvmLibraryResolveContext(thisId, DefaultVariantsMetaData.extractFrom(testBinary, schema), runtimeDependencies(testBinary), UsageKind.RUNTIME, testBinary.getDisplayName(), moduleIdentifierFactory);
}
Also used : DefaultLibraryBinaryIdentifier(org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier) LibraryBinaryIdentifier(org.gradle.api.artifacts.component.LibraryBinaryIdentifier) DefaultLibraryBinaryIdentifier(org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier) JvmLibraryResolveContext(org.gradle.jvm.internal.resolve.JvmLibraryResolveContext)

Example 3 with LibraryBinaryIdentifier

use of org.gradle.api.artifacts.component.LibraryBinaryIdentifier in project gradle by gradle.

the class JvmTestSuiteRules method createJvmTestSuiteBinary.

private static <T extends JvmTestSuiteBinarySpec> void createJvmTestSuiteBinary(final ModelMap<BinarySpec> testBinaries, Class<T> testSuiteBinaryClass, final JvmTestSuiteSpec testSuite, final JvmBinarySpec testedBinary, final JavaToolChainRegistry toolChains, PlatformResolvers platformResolver) {
    final List<JavaPlatform> javaPlatforms = resolvePlatforms(platformResolver);
    final JavaPlatform platform = testedBinary != null ? testedBinary.getTargetPlatform() : javaPlatforms.get(0);
    final BinaryNamingScheme namingScheme = namingSchemeFor(testSuite, testedBinary, javaPlatforms, platform);
    testBinaries.create(namingScheme.getBinaryName(), testSuiteBinaryClass, new Action<T>() {

        @Override
        public void execute(T binary) {
            JvmTestSuiteBinarySpecInternal testBinary = (JvmTestSuiteBinarySpecInternal) binary;
            testBinary.setNamingScheme(namingScheme);
            testBinary.setTargetPlatform(platform);
            testBinary.setToolChain(toolChains.getForPlatform(platform));
            testBinary.setTestedBinary(testedBinary);
            addTestSuiteDependencies(testBinary);
            configureCompileClasspath(testBinary);
        }

        private boolean addTestSuiteDependencies(JvmTestSuiteBinarySpecInternal testBinary) {
            return testBinary.getDependencies().addAll(testSuite.getDependencies().getDependencies());
        }

        private void configureCompileClasspath(JvmTestSuiteBinarySpecInternal testSuiteBinary) {
            if (testedBinary != null) {
                Collection<DependencySpec> dependencies = testSuiteBinary.getDependencies();
                BinarySpecInternal binary = (BinarySpecInternal) testedBinary;
                LibraryBinaryIdentifier id = binary.getId();
                dependencies.add(DefaultLibraryBinaryDependencySpec.of(id));
                if (testedBinary instanceof JarBinarySpecInternal) {
                    dependencies.addAll(((JarBinarySpecInternal) testedBinary).getApiDependencies());
                }
            }
        }
    });
}
Also used : JarBinarySpecInternal(org.gradle.jvm.internal.JarBinarySpecInternal) DefaultJavaPlatform(org.gradle.jvm.platform.internal.DefaultJavaPlatform) JavaPlatform(org.gradle.jvm.platform.JavaPlatform) JarBinarySpecInternal(org.gradle.jvm.internal.JarBinarySpecInternal) Collection(java.util.Collection) LibraryBinaryIdentifier(org.gradle.api.artifacts.component.LibraryBinaryIdentifier)

Example 4 with LibraryBinaryIdentifier

use of org.gradle.api.artifacts.component.LibraryBinaryIdentifier in project gradle by gradle.

the class ComponentIdentifierSerializer method write.

public void write(Encoder encoder, ComponentIdentifier value) throws IOException {
    if (value == null) {
        throw new IllegalArgumentException("Provided component identifier may not be null");
    }
    Implementation implementation = resolveImplementation(value);
    encoder.writeByte(implementation.getId());
    if (implementation == Implementation.MODULE) {
        ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) value;
        encoder.writeString(moduleComponentIdentifier.getGroup());
        encoder.writeString(moduleComponentIdentifier.getModule());
        encoder.writeString(moduleComponentIdentifier.getVersion());
    } else if (implementation == Implementation.BUILD) {
        ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) value;
        BuildIdentifier build = projectComponentIdentifier.getBuild();
        buildIdentifierSerializer.write(encoder, build);
        encoder.writeString(projectComponentIdentifier.getProjectPath());
    } else if (implementation == Implementation.LIBRARY) {
        LibraryBinaryIdentifier libraryIdentifier = (LibraryBinaryIdentifier) value;
        encoder.writeString(libraryIdentifier.getProjectPath());
        encoder.writeString(libraryIdentifier.getLibraryName());
        encoder.writeString(libraryIdentifier.getVariant());
    } else {
        throw new IllegalStateException("Unsupported implementation type: " + implementation);
    }
}
Also used : ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) LibraryBinaryIdentifier(org.gradle.api.artifacts.component.LibraryBinaryIdentifier) DefaultLibraryBinaryIdentifier(org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) DefaultProjectComponentIdentifier(org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)

Example 5 with LibraryBinaryIdentifier

use of org.gradle.api.artifacts.component.LibraryBinaryIdentifier in project gradle by gradle.

the class JvmVariantSelector method selectVariants.

@Override
public Collection<? extends BinarySpec> selectVariants(VariantComponent componentSpec, @Nullable String requestedVariant) {
    // We know that Jvm binaries are BinarySpec instances
    Collection<BinarySpec> allBinaries = Lists.newArrayList();
    for (Binary binary : componentSpec.getVariants()) {
        allBinaries.add((BinarySpec) binary);
    }
    if (requestedVariant != null) {
        // Choose explicit variant
        for (Binary binarySpec : allBinaries) {
            BinarySpecInternal binary = (BinarySpecInternal) binarySpec;
            LibraryBinaryIdentifier id = binary.getId();
            if (Objects.equal(requestedVariant, id.getVariant())) {
                return Collections.singleton(binary);
            }
        }
        return Collections.emptySet();
    }
    return variantsMatcher.filterBinaries(variantsMetaData, allBinaries);
}
Also used : BinarySpecInternal(org.gradle.platform.base.internal.BinarySpecInternal) LibraryBinaryIdentifier(org.gradle.api.artifacts.component.LibraryBinaryIdentifier) BinarySpec(org.gradle.platform.base.BinarySpec) Binary(org.gradle.platform.base.Binary)

Aggregations

LibraryBinaryIdentifier (org.gradle.api.artifacts.component.LibraryBinaryIdentifier)6 DefaultLibraryBinaryIdentifier (org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier)3 Collection (java.util.Collection)1 BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)1 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)1 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)1 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)1 DefaultProjectComponentIdentifier (org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)1 JvmBinarySpec (org.gradle.jvm.JvmBinarySpec)1 JarBinarySpecInternal (org.gradle.jvm.internal.JarBinarySpecInternal)1 JvmBinarySpecInternal (org.gradle.jvm.internal.JvmBinarySpecInternal)1 JvmLibraryResolveContext (org.gradle.jvm.internal.resolve.JvmLibraryResolveContext)1 JavaPlatform (org.gradle.jvm.platform.JavaPlatform)1 DefaultJavaPlatform (org.gradle.jvm.platform.internal.DefaultJavaPlatform)1 Binary (org.gradle.platform.base.Binary)1 BinarySpec (org.gradle.platform.base.BinarySpec)1 DependencySpec (org.gradle.platform.base.DependencySpec)1 BinarySpecInternal (org.gradle.platform.base.internal.BinarySpecInternal)1 DefaultLibraryBinaryDependencySpec (org.gradle.platform.base.internal.DefaultLibraryBinaryDependencySpec)1 DependentBinariesResolvedResult (org.gradle.platform.base.internal.dependents.DependentBinariesResolvedResult)1