Java Code Examples for org.gradle.jvm.platform.JavaPlatform

The following examples show how to use org.gradle.jvm.platform.JavaPlatform. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void execute(JvmLibrarySpec jvmLibrary) {
    List<String> targetPlatforms = jvmLibrary.getTargetPlatforms();
    // TODO:DAZ We should have a generic (JVM + Native) way to get the 'best' platform to build when no target is defined.
    // This logic needs to inspect the available platforms and find the closest one matching the current platform
    if (targetPlatforms.isEmpty()) {
        targetPlatforms = Collections.singletonList(new DefaultJavaPlatform(JavaVersion.current()).getName());
    }
    List<JavaPlatform> selectedPlatforms = platforms.select(JavaPlatform.class, targetPlatforms);
    for (JavaPlatform platform: selectedPlatforms) {
        JavaToolChain toolChain = toolChains.getForPlatform(platform);
        BinaryNamingSchemeBuilder componentBuilder = namingSchemeBuilder
                .withComponentName(jvmLibrary.getName())
                .withTypeString("jar");
        if (selectedPlatforms.size() > 1) { //Only add variant dimension for multiple jdk targets to avoid breaking the default naming scheme
            componentBuilder = componentBuilder.withVariantDimension(platform.getName());
        }
        BinaryNamingScheme namingScheme = componentBuilder.build(); //TODO freekh: move out?
        factory.createJarBinaries(jvmLibrary, namingScheme, toolChain, platform); //TODO: createJarBinaries is mutable! We should not be doing this - execute could return a list instead
    }
}
 
Example 2
public void execute(JvmLibrarySpec jvmLibrary) {
    List<String> targetPlatforms = jvmLibrary.getTargetPlatforms();
    // TODO:DAZ We should have a generic (JVM + Native) way to get the 'best' platform to build when no target is defined.
    // This logic needs to inspect the available platforms and find the closest one matching the current platform
    if (targetPlatforms.isEmpty()) {
        targetPlatforms = Collections.singletonList(new DefaultJavaPlatform(JavaVersion.current()).getName());
    }
    List<JavaPlatform> selectedPlatforms = platforms.select(JavaPlatform.class, targetPlatforms);
    for (JavaPlatform platform: selectedPlatforms) {
        JavaToolChain toolChain = toolChains.getForPlatform(platform);
        BinaryNamingSchemeBuilder componentBuilder = namingSchemeBuilder
                .withComponentName(jvmLibrary.getName())
                .withTypeString("jar");
        if (selectedPlatforms.size() > 1) { //Only add variant dimension for multiple jdk targets to avoid breaking the default naming scheme
            componentBuilder = componentBuilder.withVariantDimension(platform.getName());
        }
        BinaryNamingScheme namingScheme = componentBuilder.build(); //TODO freekh: move out?
        factory.createJarBinaries(jvmLibrary, namingScheme, toolChain, platform); //TODO: createJarBinaries is mutable! We should not be doing this - execute could return a list instead
    }
}
 
Example 3
@Mutate
public void registerJavaPlatformType(PlatformContainer platforms, ServiceRegistry serviceRegistry) {
    final Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    platforms.registerFactory(JavaPlatform.class, new NamedDomainObjectFactory<JavaPlatform>() {
        public JavaPlatform create(String name) {
            return instantiator.newInstance(DefaultJavaPlatform.class, name);
        }
    });
}
 
Example 4
public ToolProvider select(JavaPlatform targetPlatform) {
    // TODO:DAZ Remove all of the calls to this method with null platform
    if (targetPlatform != null && targetPlatform.getTargetCompatibility().compareTo(javaVersion) > 0) {
        return new UnavailableToolProvider(targetPlatform);
    }
    return new JavaToolProvider();
}
 
Example 5
@Mutate
public void registerJavaPlatformType(PlatformContainer platforms, ServiceRegistry serviceRegistry) {
    final Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    platforms.registerFactory(JavaPlatform.class, new NamedDomainObjectFactory<JavaPlatform>() {
        public JavaPlatform create(String name) {
            return instantiator.newInstance(DefaultJavaPlatform.class, name);
        }
    });
}
 
Example 6
public ToolProvider select(JavaPlatform targetPlatform) {
    // TODO:DAZ Remove all of the calls to this method with null platform
    if (targetPlatform != null && targetPlatform.getTargetCompatibility().compareTo(javaVersion) > 0) {
        return new UnavailableToolProvider(targetPlatform);
    }
    return new JavaToolProvider();
}
 
Example 7
@Override
public ToolProvider select(JavaPlatform targetPlatform) {
  if (targetPlatform != null
      && targetPlatform.getTargetCompatibility().compareTo(javaVersion) > 0) {
    return new UnavailableToolProvider(targetPlatform);
  }
  return new JavaToolProvider();
}
 
Example 8
public JavaToolChain getForPlatform(JavaPlatform targetPlatform) {
    return toolChain;
}
 
Example 9
public void createJarBinaries(JvmLibrarySpec jvmLibrary, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    DefaultJarBinarySpec jarBinary = instantiator.newInstance(DefaultJarBinarySpec.class, jvmLibrary, namingScheme, toolChain, platform);
    setupDefaults(jarBinary);
    jarBinary.source(jvmLibrary.getSource());
    jvmLibrary.getBinaries().add(jarBinary);
}
 
Example 10
public DefaultJarBinarySpec(JvmLibrarySpec library, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    this.library = library;
    this.namingScheme = namingScheme;
    this.toolChain = toolChain;
    this.platform = platform;
}
 
Example 11
public JavaPlatform getTargetPlatform() {
    return platform;
}
 
Example 12
protected JavaPlatform getPlatform() {
    return null;
}
 
Example 13
private UnavailableToolProvider(JavaPlatform targetPlatform) {
    this.targetPlatform = targetPlatform;
}
 
Example 14
public JavaPlatform getPlatform() {
    return platform;
}
 
Example 15
public void setPlatform(JavaPlatform platform) {
    this.platform = platform;
}
 
Example 16
public DefaultClassDirectoryBinarySpec(String name, JavaToolChain toolChain, JavaPlatform platform) {
    this.name = name;
    this.toolChain = toolChain;
    this.platform = platform;
    this.namingScheme = new ClassDirectoryBinaryNamingScheme(removeClassesSuffix(name));
}
 
Example 17
public JavaPlatform getTargetPlatform() {
    return platform;
}
 
Example 18
Source Project: javaide   Source File: JavaCompile.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Nested
protected JavaPlatform getPlatform() {
    return new DefaultJavaPlatform(JavaVersion.toVersion(getTargetCompatibility()));
}
 
Example 19
public JavaToolChain getForPlatform(JavaPlatform targetPlatform) {
    return toolChain;
}
 
Example 20
public void createJarBinaries(JvmLibrarySpec jvmLibrary, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    DefaultJarBinarySpec jarBinary = instantiator.newInstance(DefaultJarBinarySpec.class, jvmLibrary, namingScheme, toolChain, platform);
    setupDefaults(jarBinary);
    jarBinary.source(jvmLibrary.getSource());
    jvmLibrary.getBinaries().add(jarBinary);
}
 
Example 21
public DefaultJarBinarySpec(JvmLibrarySpec library, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    this.library = library;
    this.namingScheme = namingScheme;
    this.toolChain = toolChain;
    this.platform = platform;
}
 
Example 22
public JavaPlatform getTargetPlatform() {
    return platform;
}
 
Example 23
protected JavaPlatform getPlatform() {
    return null;
}
 
Example 24
private UnavailableToolProvider(JavaPlatform targetPlatform) {
    this.targetPlatform = targetPlatform;
}
 
Example 25
public JavaPlatform getPlatform() {
    return platform;
}
 
Example 26
public void setPlatform(JavaPlatform platform) {
    this.platform = platform;
}
 
Example 27
public DefaultClassDirectoryBinarySpec(String name, JavaToolChain toolChain, JavaPlatform platform) {
    this.name = name;
    this.toolChain = toolChain;
    this.platform = platform;
    this.namingScheme = new ClassDirectoryBinaryNamingScheme(removeClassesSuffix(name));
}
 
Example 28
public JavaPlatform getTargetPlatform() {
    return platform;
}
 
Example 29
private UnavailableToolProvider(JavaPlatform targetPlatform) {
  this.targetPlatform = targetPlatform;
}
 
Example 30
/**
 * The target platform for this binary.
 */
JavaPlatform getTargetPlatform();