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());
}
}
}
});
}
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);
}
Aggregations