Search in sources :

Example 1 with JavaPlatform

use of org.gradle.jvm.platform.JavaPlatform 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 JavaPlatform

use of org.gradle.jvm.platform.JavaPlatform in project gradle by gradle.

the class PlayPlatformResolver method resolve.

private PlayPlatform resolve(String name, String playVersion, String scalaVersion, String javaVersion) {
    PlayMajorVersion playMajorVersion = PlayMajorVersion.forPlayVersion(playVersion);
    JavaPlatform javaPlatform = getJavaPlatform(javaVersion);
    ScalaPlatform scalaPlatform = getScalaPlatform(playMajorVersion, scalaVersion);
    return new DefaultPlayPlatform(name, playVersion, scalaPlatform, javaPlatform);
}
Also used : DefaultJavaPlatform(org.gradle.jvm.platform.internal.DefaultJavaPlatform) JavaPlatform(org.gradle.jvm.platform.JavaPlatform) ScalaPlatform(org.gradle.language.scala.ScalaPlatform) DefaultScalaPlatform(org.gradle.language.scala.internal.DefaultScalaPlatform) PlayMajorVersion(org.gradle.play.internal.platform.PlayMajorVersion)

Aggregations

JavaPlatform (org.gradle.jvm.platform.JavaPlatform)2 DefaultJavaPlatform (org.gradle.jvm.platform.internal.DefaultJavaPlatform)2 Collection (java.util.Collection)1 LibraryBinaryIdentifier (org.gradle.api.artifacts.component.LibraryBinaryIdentifier)1 JarBinarySpecInternal (org.gradle.jvm.internal.JarBinarySpecInternal)1 ScalaPlatform (org.gradle.language.scala.ScalaPlatform)1 DefaultScalaPlatform (org.gradle.language.scala.internal.DefaultScalaPlatform)1 PlayMajorVersion (org.gradle.play.internal.platform.PlayMajorVersion)1