Search in sources :

Example 1 with JarBinarySpecInternal

use of org.gradle.jvm.internal.JarBinarySpecInternal 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 2 with JarBinarySpecInternal

use of org.gradle.jvm.internal.JarBinarySpecInternal 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)

Aggregations

JarBinarySpecInternal (org.gradle.jvm.internal.JarBinarySpecInternal)2 Collection (java.util.Collection)1 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 JvmAssembly (org.gradle.jvm.internal.JvmAssembly)1 WithJvmAssembly (org.gradle.jvm.internal.WithJvmAssembly)1 JavaPlatform (org.gradle.jvm.platform.JavaPlatform)1 DefaultJavaPlatform (org.gradle.jvm.platform.internal.DefaultJavaPlatform)1 DependencySpec (org.gradle.platform.base.DependencySpec)1