org.gradle.jvm.platform.JavaPlatform Java Examples

The following examples show how to use org.gradle.jvm.platform.JavaPlatform. 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
Source File: JvmLibrarySpecInitializer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Source File: JvmLibrarySpecInitializer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Source File: DefaultJavaToolChain.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #4
Source File: JvmComponentPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #5
Source File: DefaultJavaToolChain.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #6
Source File: JvmComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #7
Source File: ErrorProneToolChain.java    From gradle-errorprone-plugin-v0.0.x with Apache License 2.0 5 votes vote down vote up
@Override
public ToolProvider select(JavaPlatform targetPlatform) {
  if (targetPlatform != null
      && targetPlatform.getTargetCompatibility().compareTo(javaVersion) > 0) {
    return new UnavailableToolProvider(targetPlatform);
  }
  return new JavaToolProvider();
}
 
Example #8
Source File: PlatformJavaCompile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setPlatform(JavaPlatform platform) {
    this.platform = platform;
}
 
Example #9
Source File: DefaultClassDirectoryBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultClassDirectoryBinarySpec(String name, JavaToolChain toolChain, JavaPlatform platform) {
    this.name = name;
    this.toolChain = toolChain;
    this.platform = platform;
    this.namingScheme = new ClassDirectoryBinaryNamingScheme(removeClassesSuffix(name));
}
 
Example #10
Source File: PlatformJavaCompile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaPlatform getPlatform() {
    return platform;
}
 
Example #11
Source File: DefaultJavaToolChainRegistry.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaToolChain getForPlatform(JavaPlatform targetPlatform) {
    return toolChain;
}
 
Example #12
Source File: DefaultJavaToolChain.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private UnavailableToolProvider(JavaPlatform targetPlatform) {
    this.targetPlatform = targetPlatform;
}
 
Example #13
Source File: DefaultClassDirectoryBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaPlatform getTargetPlatform() {
    return platform;
}
 
Example #14
Source File: JavaCompile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected JavaPlatform getPlatform() {
    return null;
}
 
Example #15
Source File: DefaultJarBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaPlatform getTargetPlatform() {
    return platform;
}
 
Example #16
Source File: DefaultJarBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJarBinarySpec(JvmLibrarySpec library, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    this.library = library;
    this.namingScheme = namingScheme;
    this.toolChain = toolChain;
    this.platform = platform;
}
 
Example #17
Source File: DefaultJarBinariesFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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 #18
Source File: ErrorProneToolChain.java    From gradle-errorprone-plugin-v0.0.x with Apache License 2.0 4 votes vote down vote up
private UnavailableToolProvider(JavaPlatform targetPlatform) {
  this.targetPlatform = targetPlatform;
}
 
Example #19
Source File: DefaultJavaToolChainRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaToolChain getForPlatform(JavaPlatform targetPlatform) {
    return toolChain;
}
 
Example #20
Source File: JavaCompile.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Nested
protected JavaPlatform getPlatform() {
    return new DefaultJavaPlatform(JavaVersion.toVersion(getTargetCompatibility()));
}
 
Example #21
Source File: DefaultClassDirectoryBinarySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaPlatform getTargetPlatform() {
    return platform;
}
 
Example #22
Source File: DefaultClassDirectoryBinarySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultClassDirectoryBinarySpec(String name, JavaToolChain toolChain, JavaPlatform platform) {
    this.name = name;
    this.toolChain = toolChain;
    this.platform = platform;
    this.namingScheme = new ClassDirectoryBinaryNamingScheme(removeClassesSuffix(name));
}
 
Example #23
Source File: PlatformJavaCompile.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setPlatform(JavaPlatform platform) {
    this.platform = platform;
}
 
Example #24
Source File: PlatformJavaCompile.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaPlatform getPlatform() {
    return platform;
}
 
Example #25
Source File: DefaultJavaToolChain.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private UnavailableToolProvider(JavaPlatform targetPlatform) {
    this.targetPlatform = targetPlatform;
}
 
Example #26
Source File: JavaCompile.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected JavaPlatform getPlatform() {
    return null;
}
 
Example #27
Source File: DefaultJarBinarySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JavaPlatform getTargetPlatform() {
    return platform;
}
 
Example #28
Source File: DefaultJarBinarySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultJarBinarySpec(JvmLibrarySpec library, BinaryNamingScheme namingScheme, JavaToolChain toolChain, JavaPlatform platform) {
    this.library = library;
    this.namingScheme = namingScheme;
    this.toolChain = toolChain;
    this.platform = platform;
}
 
Example #29
Source File: DefaultJarBinariesFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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 #30
Source File: JvmBinarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * The target platform for this binary.
 */
JavaPlatform getTargetPlatform();