org.gradle.api.JavaVersion Java Examples

The following examples show how to use org.gradle.api.JavaVersion. 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: AwbAndroidJavaCompile.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Override
protected void compile(IncrementalTaskInputs inputs) {
    getLogger().info(
            "Compiling with source level {} and target level {}.",
            getSourceCompatibility(),
            getTargetCompatibility());
    if (isPostN()) {
        if (!JavaVersion.current().isJava8Compatible()) {
            throw new RuntimeException("compileSdkVersion '" + compileSdkVersion + "' requires "
                    + "JDK 1.8 or later to compile.");
        }
    }

    if (awbBundle.isDataBindEnabled() && !analyticsed) {
        processAnalytics();
        analyticsed = true;
    }

    // Create directory for output of annotation processor.
    FileUtils.mkdirs(annotationProcessorOutputFolder);

    mInstantRunBuildContext.startRecording(InstantRunBuildContext.TaskType.JAVAC);
    compile();
    mInstantRunBuildContext.stopRecording(InstantRunBuildContext.TaskType.JAVAC);
}
 
Example #2
Source File: JvmVersionValidator.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
static JavaVersion parseJavaVersionCommandOutput(BufferedReader reader) {
    try {
        String versionStr = reader.readLine();
        while (versionStr != null) {
            Matcher matcher = Pattern.compile("(?:java|openjdk) version \"(.+?)\"").matcher(versionStr);
            if (matcher.matches()) {
                return JavaVersion.toVersion(matcher.group(1));
            }
            versionStr = reader.readLine();
        }
    } catch (IOException e) {
        throw new org.gradle.api.UncheckedIOException(e);
    }

    throw new RuntimeException("Could not determine Java version.");
}
 
Example #3
Source File: ClojureCommonPlugin.java    From clojurephant with Apache License 2.0 6 votes vote down vote up
private void configureDependencyConstraints(Project project) {
  project.getDependencies().getModules().module("org.clojure:tools.nrepl", module -> {
    ComponentModuleMetadataDetails details = (ComponentModuleMetadataDetails) module;
    details.replacedBy("nrepl:nrepl", "nREPL was moved out of Clojure Contrib to its own project.");
  });

  if (JavaVersion.current().isJava9Compatible()) {
    project.getDependencies().constraints(constraints -> {
      constraints.add("devImplementation", "org.clojure:java.classpath:0.3.0", constraint -> {
        constraint.because("Java 9 has a different classloader architecture. 0.3.0 adds support for this.");
      });
      constraints.add("devRuntimeOnly", "org.clojure:java.classpath:0.3.0", constraint -> {
        constraint.because("Java 9 has a different classloader architecture. 0.3.0 adds support for this.");
      });
    });
  }
}
 
Example #4
Source File: AvailableJavaHomes.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public List<JvmInstallation> findJvms() {
    Set<File> javaHomes = new HashSet<File>();
    List<JvmInstallation> jvms = new ArrayList<JvmInstallation>();
    for (File file : new File(SystemProperties.getUserHome()).listFiles()) {
        Matcher matcher = JDK_DIR.matcher(file.getName());
        if (!matcher.matches()) {
            continue;
        }
        File javaHome = fileCanonicalizer.canonicalize(file);
        if (!javaHomes.add(javaHome)) {
            continue;
        }
        if (!new File(file, "bin/javac").isFile()) {
            continue;
        }
        String version = matcher.group(1);
        jvms.add(new JvmInstallation(JavaVersion.toVersion(version), version, file, true, JvmInstallation.Arch.Unknown));
    }
    return jvms;
}
 
Example #5
Source File: WindowsOracleJvmLocator.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void findJvms(WindowsRegistry windowsRegistry, String sdkSubkey, Collection<JvmInstallation> jvms, boolean jdk, JvmInstallation.Arch arch) {
    List<String> versions;
    try {
        versions = windowsRegistry.getSubkeys(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, sdkSubkey);
    } catch (MissingRegistryEntryException e) {
        // Ignore
        return;
    }

    for (String version : versions) {
        if (version.matches("\\d+\\.\\d+")) {
            continue;
        }
        String javaHome = windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, sdkSubkey + '\\' + version, "JavaHome");
        jvms.add(new JvmInstallation(JavaVersion.toVersion(version), version, new File(javaHome), jdk, arch));
    }
}
 
Example #6
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 #7
Source File: Jvm.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @param os the OS
 * @param suppliedJavaBase initial location to discover from. May be jdk or jre.
 */
Jvm(OperatingSystem os, File suppliedJavaBase) {
    this.os = os;
    if (suppliedJavaBase == null) {
        //discover based on what's in the sys. property
        try {
            this.javaBase = new File(System.getProperty("java.home")).getCanonicalFile();
        } catch (IOException e) {
            throw new UncheckedException(e);
        }
        this.javaHome = findJavaHome(javaBase);
        this.javaVersion = JavaVersion.current();
        this.userSupplied = false;
    } else {
        //precisely use what the user wants and validate strictly further on
        this.javaBase = suppliedJavaBase;
        this.javaHome = suppliedJavaBase;
        this.userSupplied = true;
        this.javaVersion = null;
    }
}
 
Example #8
Source File: AvailableJavaHomes.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public List<JvmInstallation> findJvms() {
    Set<File> javaHomes = new HashSet<File>();
    List<JvmInstallation> jvms = new ArrayList<JvmInstallation>();
    for (File file : new File(SystemProperties.getUserHome()).listFiles()) {
        Matcher matcher = JDK_DIR.matcher(file.getName());
        if (!matcher.matches()) {
            continue;
        }
        File javaHome = fileCanonicalizer.canonicalize(file);
        if (!javaHomes.add(javaHome)) {
            continue;
        }
        if (!new File(file, "bin/javac").isFile()) {
            continue;
        }
        String version = matcher.group(1);
        jvms.add(new JvmInstallation(JavaVersion.toVersion(version), version, file, true, JvmInstallation.Arch.Unknown));
    }
    return jvms;
}
 
Example #9
Source File: DefaultModularityExtension.java    From gradle-modules-plugin with MIT License 6 votes vote down vote up
private void setJavaRelease(JavaCompile javaCompile, int javaRelease) {
    String currentJavaVersion = JavaVersion.current().toString();
    if (!javaCompile.getSourceCompatibility().equals(currentJavaVersion)) {
        throw new IllegalStateException("sourceCompatibility should not be set together with --release option");
    }
    if (!javaCompile.getTargetCompatibility().equals(currentJavaVersion)) {
        throw new IllegalStateException("targetCompatibility should not be set together with --release option");
    }

    List<String> compilerArgs = javaCompile.getOptions().getCompilerArgs();
    if (compilerArgs.contains("--release")) {
        throw new IllegalStateException("--release option is already set in compiler args");
    }

    compilerArgs.add("--release");
    compilerArgs.add(String.valueOf(javaRelease));
}
 
Example #10
Source File: Jdt.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void store(Properties properties) {
    properties.put("org.eclipse.jdt.core.compiler.compliance", sourceCompatibility.toString());
    properties.put("org.eclipse.jdt.core.compiler.source", sourceCompatibility.toString());

    if (sourceCompatibility.compareTo(JavaVersion.VERSION_1_3) <= 0) {
        properties.put("org.eclipse.jdt.core.compiler.problem.assertIdentifier", "ignore");
        properties.put("org.eclipse.jdt.core.compiler.problem.enumIdentifier", "ignore");
    } else if (sourceCompatibility == JavaVersion.VERSION_1_4) {
        properties.put("org.eclipse.jdt.core.compiler.problem.assertIdentifier", "error");
        properties.put("org.eclipse.jdt.core.compiler.problem.enumIdentifier", "warning");
    } else {
        properties.put("org.eclipse.jdt.core.compiler.problem.assertIdentifier", "error");
        properties.put("org.eclipse.jdt.core.compiler.problem.enumIdentifier", "error");
    }

    properties.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", targetCompatibility.toString());
}
 
Example #11
Source File: JvmVersionValidator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
static JavaVersion parseJavaVersionCommandOutput(BufferedReader reader) {
    try {
        String versionStr = reader.readLine();
        while (versionStr != null) {
            Matcher matcher = Pattern.compile("(?:java|openjdk) version \"(.+?)\"").matcher(versionStr);
            if (matcher.matches()) {
                return JavaVersion.toVersion(matcher.group(1));
            }
            versionStr = reader.readLine();
        }
    } catch (IOException e) {
        throw new org.gradle.api.UncheckedIOException(e);
    }

    throw new RuntimeException("Could not determine Java version.");
}
 
Example #12
Source File: CreateInjectDexes.java    From Injector with Apache License 2.0 6 votes vote down vote up
@Inject
public CreateInjectDexes(InjectorExtension extension,
                         String projectPackageName,
                         String variantName,
                         String buildDirectory,
                         Set<? extends AndroidArchiveLibrary> androidArchiveLibraries,
                         Set<? extends ResolvedArtifact> jarFiles,
                         int minApiLevel,
                         JavaVersion sourceCompatibilityVersion,
                         JavaVersion targetCompatibilityVersion) {
	this.sourceCompatibilityVersion = sourceCompatibilityVersion;
	this.targetCompatibilityVersion = targetCompatibilityVersion;
	this.minApiLevel = minApiLevel;
	this.variantName = variantName;
	this.projectPackageName = projectPackageName;
	this.buildDirectory = buildDirectory;
	this.androidArchiveLibraries = new HashSet<>(androidArchiveLibraries);
	this.jarFiles = new HashSet<>(jarFiles);
	this.extension = extension;
}
 
Example #13
Source File: FindBugsClasspathValidator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void validateClasspath(Iterable<String> fileNamesOnClasspath) {
    VersionNumber v = getFindbugsVersion(fileNamesOnClasspath);
    boolean java6orLess = javaVersion.compareTo(JavaVersion.VERSION_1_7) < 0;
    boolean findbugs3orMore = v.getMajor() > 2;
    if (java6orLess && findbugs3orMore) {
        throw new FindBugsVersionTooHighException("The version of FindBugs (" + v + ") inferred from FindBugs classpath is too high to work with currently used Java version (" + javaVersion + ")."
                + " Please use lower version of FindBugs or use newer version of Java. Inspected FindBugs classpath: " + fileNamesOnClasspath);
    }
    boolean java8orMore = javaVersion.compareTo(JavaVersion.VERSION_1_7) > 0;
    boolean findbugs2orLess = v.getMajor() < 3;
    if (java8orMore && findbugs2orLess) {
        throw new FindBugsVersionTooLowException("The version of FindBugs (" + v + ") inferred from FindBugs classpath is too low to work with currently used Java version (" + javaVersion + ")."
                + " Please use higher version of FindBugs. Inspected FindBugs classpath: " + fileNamesOnClasspath);
    }
}
 
Example #14
Source File: AvailableJavaHomes.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Locates a JDK installation for the given version.
 *
 * @return null if not found.
 */
@Nullable
public static JavaInfo getJdk(JavaVersion version) {
    for (JvmInstallation candidate : getJvms()) {
        if (candidate.getJavaVersion().equals(version) && candidate.isJdk()) {
            return Jvm.forHome(candidate.getJavaHome());
        }
    }
    return null;
}
 
Example #15
Source File: ResolveJavadocLinks.java    From gradle-plugins with MIT License 5 votes vote down vote up
private String getJavaSeLink() {
    JavaVersion javaVersion = JavaVersion.current();

    JavaToolChain toolChain = javadoc.getToolChain();
    if (toolChain instanceof JavaToolChainInternal) {
        javaVersion = ((JavaToolChainInternal) toolChain).getJavaVersion();
    }

    if (javaVersion.isJava11Compatible()) {
        return "https://docs.oracle.com/en/java/javase/" + javaVersion.getMajorVersion() + "/docs/api/";
    }
    else {
        return "https://docs.oracle.com/javase/" + javaVersion.getMajorVersion() + "/docs/api/";
    }
}
 
Example #16
Source File: JvmInstallation.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JvmInstallation(JavaVersion javaVersion, String version, File javaHome, boolean jdk, Arch arch) {
    this.javaVersion = javaVersion;
    this.version = VersionNumber.withPatchNumber().parse(version);
    this.javaHome = javaHome;
    this.jdk = jdk;
    this.arch = arch;
}
 
Example #17
Source File: TestNGTestFramework.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestNGTestFramework(Test testTask, DefaultTestFilter filter, Instantiator instantiator) {
    this.testTask = testTask;
    this.filter = filter;
    options = instantiator.newInstance(TestNGOptions.class, testTask.getProject().getProjectDir());
    options.setAnnotationsOnSourceCompatibility(JavaVersion.toVersion(testTask.getProject().property("sourceCompatibility")));
    conventionMapOutputDirectory(options, testTask.getReports().getHtml());
    detector = new TestNGDetector(new ClassFileExtractionManager(testTask.getTemporaryDirFactory()));
}
 
Example #18
Source File: FindBugsClasspathValidator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void validateClasspath(Iterable<String> fileNamesOnClasspath) {
    VersionNumber v = getFindbugsVersion(fileNamesOnClasspath);
    boolean java6orLess = javaVersion.compareTo(JavaVersion.VERSION_1_7) < 0;
    boolean findbugs3orMore = v.getMajor() > 2;
    if (java6orLess && findbugs3orMore) {
        throw new FindBugsVersionTooHighException("The version of FindBugs (" + v + ") inferred from FindBugs classpath is too high to work with currently used Java version (" + javaVersion + ")."
                + " Please use lower version of FindBugs or use newer version of Java. Inspected FindBugs classpath: " + fileNamesOnClasspath);
    }
    boolean java8orMore = javaVersion.compareTo(JavaVersion.VERSION_1_7) > 0;
    boolean findbugs2orLess = v.getMajor() < 3;
    if (java8orMore && findbugs2orLess) {
        throw new FindBugsVersionTooLowException("The version of FindBugs (" + v + ") inferred from FindBugs classpath is too low to work with currently used Java version (" + javaVersion + ")."
                + " Please use higher version of FindBugs. Inspected FindBugs classpath: " + fileNamesOnClasspath);
    }
}
 
Example #19
Source File: AvailableJavaHomes.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public List<JvmInstallation> findJvms() {
    List<JvmInstallation> jvms = new ArrayList<JvmInstallation>();
    if (OperatingSystem.current().isLinux()) {
        jvms = addJvm(jvms, JavaVersion.VERSION_1_5, "1.5.0", new File("/opt/jdk/sun-jdk-5"), true, JvmInstallation.Arch.i386);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_6, "1.6.0", new File("/opt/jdk/sun-jdk-6"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_6, "1.6.0", new File("/opt/jdk/ibm-jdk-6"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_7, "1.7.0", new File("/opt/jdk/oracle-jdk-7"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_8, "1.8.0", new File("/opt/jdk/oracle-jdk-8"), true, JvmInstallation.Arch.x86_64);
    }
    return CollectionUtils.filter(jvms, new Spec<JvmInstallation>() {
        public boolean isSatisfiedBy(JvmInstallation element) {
            return element.getJavaHome().isDirectory();
        }
    });
}
 
Example #20
Source File: ResolveJavadocLinks.java    From gradle-plugins with MIT License 5 votes vote down vote up
private String getJavaSeLink() {
    JavaVersion javaVersion = JavaVersion.current();

    JavaToolChain toolChain = javadoc.getToolChain();
    if (toolChain instanceof JavaToolChainInternal) {
        javaVersion = ((JavaToolChainInternal) toolChain).getJavaVersion();
    }

    if (javaVersion.isJava11Compatible()) {
        return "https://docs.oracle.com/en/java/javase/" + javaVersion.getMajorVersion() + "/docs/api/";
    }
    else {
        return "https://docs.oracle.com/javase/" + javaVersion.getMajorVersion() + "/docs/api/";
    }
}
 
Example #21
Source File: AvailableJavaHomes.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Locates a JDK installation for the given version.
 *
 * @return null if not found.
 */
@Nullable
public static JavaInfo getJdk(JavaVersion version) {
    for (JvmInstallation candidate : getJvms()) {
        if (candidate.getJavaVersion().equals(version) && candidate.isJdk()) {
            return Jvm.forHome(candidate.getJavaHome());
        }
    }
    return null;
}
 
Example #22
Source File: CompileOptions.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Convert all possible supported way of specifying a Java version to {@link JavaVersion}
 *
 * @param version the user provided java version.
 * @return {@link JavaVersion}
 * @throws RuntimeException if it cannot be converted.
 */
@NonNull
private static JavaVersion convert(@NonNull Object version) {
    // for backward version reasons, we support setting strings like 'Version_1_6'
    if (version instanceof String) {
        final String versionString = (String) version;
        if (versionString.toUpperCase(Locale.ENGLISH).startsWith(VERSION_PREFIX)) {
            version = versionString.substring(VERSION_PREFIX.length()).replace('_', '.');
        }
    }
    return JavaVersion.toVersion(version);
}
 
Example #23
Source File: AbstractCompilesUtil.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Determines the java language level to use and sets it on the given task and
 * {@link CompileOptions}. The latter is to propagate the information to Studio.
 */
public static void configureLanguageLevel(
        AbstractCompile compileTask,
        final CompileOptions compileOptions,
        String compileSdkVersion) {
    final AndroidVersion hash = AndroidTargetHash.getVersionFromHash(compileSdkVersion);
    Integer compileSdkLevel = (hash == null ? null : hash.getApiLevel());

    JavaVersion javaVersionToUse;
    if (compileSdkLevel == null || (0 <= compileSdkLevel && compileSdkLevel <= 20)) {
        javaVersionToUse = JavaVersion.VERSION_1_6;
    } else {
        javaVersionToUse = JavaVersion.VERSION_1_7;
    }

    JavaVersion jdkVersion =
            JavaVersion.toVersion(System.getProperty("java.specification.version"));
    if (jdkVersion.compareTo(javaVersionToUse) < 0) {
        compileTask.getLogger().warn(
                "Default language level for compileSdkVersion '{}' is " +
                        "{}, but the JDK used is {}, so the JDK language level will be used.",
                compileSdkVersion,
                javaVersionToUse,
                jdkVersion);
        javaVersionToUse = jdkVersion;
    }

    compileOptions.setDefaultJavaVersion(javaVersionToUse);

    compileTask.setSourceCompatibility(compileOptions.getSourceCompatibility().toString());
    compileTask.setTargetCompatibility(compileOptions.getTargetCompatibility().toString());
}
 
Example #24
Source File: TestNGTestFramework.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestNGTestFramework(Test testTask, DefaultTestFilter filter, Instantiator instantiator) {
    this.testTask = testTask;
    this.filter = filter;
    options = instantiator.newInstance(TestNGOptions.class, testTask.getProject().getProjectDir());
    options.setAnnotationsOnSourceCompatibility(JavaVersion.toVersion(testTask.getProject().property("sourceCompatibility")));
    conventionMapOutputDirectory(options, testTask.getReports().getHtml());
    detector = new TestNGDetector(new ClassFileExtractionManager(testTask.getTemporaryDirFactory()));
}
 
Example #25
Source File: AvailableJavaHomes.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public List<JvmInstallation> findJvms() {
    List<JvmInstallation> jvms = new ArrayList<JvmInstallation>();
    if (OperatingSystem.current().isLinux()) {
        jvms = addJvm(jvms, JavaVersion.VERSION_1_5, "1.5.0", new File("/opt/jdk/sun-jdk-5"), true, JvmInstallation.Arch.i386);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_6, "1.6.0", new File("/opt/jdk/sun-jdk-6"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_6, "1.6.0", new File("/opt/jdk/ibm-jdk-6"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_7, "1.7.0", new File("/opt/jdk/oracle-jdk-7"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_8, "1.8.0", new File("/opt/jdk/oracle-jdk-8"), true, JvmInstallation.Arch.x86_64);
    }
    return CollectionUtils.filter(jvms, new Spec<JvmInstallation>() {
        public boolean isSatisfiedBy(JvmInstallation element) {
            return element.getJavaHome().isDirectory();
        }
    });
}
 
Example #26
Source File: TestNGTestFramework.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestNGTestFramework(Test testTask, DefaultTestFilter filter, Instantiator instantiator) {
    this.testTask = testTask;
    this.filter = filter;
    options = instantiator.newInstance(TestNGOptions.class, testTask.getProject().getProjectDir());
    options.setAnnotationsOnSourceCompatibility(JavaVersion.toVersion(testTask.getProject().property("sourceCompatibility")));
    conventionMapOutputDirectory(options, testTask.getReports().getHtml());
    detector = new TestNGDetector(new ClassFileExtractionManager(testTask.getTemporaryDirFactory()));
}
 
Example #27
Source File: DaemonGradleExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected List<String> getGradleOpts() {
    if (isNoDefaultJvmArgs()) {
        return super.getGradleOpts();
    } else {
        // Workaround for http://issues.gradle.org/browse/GRADLE-2629
        // Instead of just adding these as standalone opts, we need to add to
        // -Dorg.gradle.jvmArgs in order for them to be effectual
        List<String> jvmArgs = new ArrayList<String>(4);
        jvmArgs.add("-XX:MaxPermSize=320m");
        jvmArgs.add("-XX:+HeapDumpOnOutOfMemoryError");
        jvmArgs.add("-XX:HeapDumpPath=" + buildContext.getGradleUserHomeDir().getAbsolutePath());
        if (JavaVersion.current().isJava5()) {
            jvmArgs.add("-XX:+CMSPermGenSweepingEnabled");
            jvmArgs.add("-Dcom.sun.management.jmxremote");
        }

        String quotedArgs = join(" ", collect(jvmArgs, new Transformer<String, String>() {
            public String transform(String input) {
                return String.format("'%s'", input);
            }
        }));

        List<String> gradleOpts = new ArrayList<String>(super.getGradleOpts());
        gradleOpts.add("-Dorg.gradle.jvmArgs=" +  quotedArgs);
        return gradleOpts;
    }
}
 
Example #28
Source File: PlayExtension.java    From playframework with Apache License 2.0 5 votes vote down vote up
public PlayExtension(ObjectFactory objectFactory) {
    this.platform = objectFactory.newInstance(PlayPlatform.class, objectFactory);
    this.platform.getPlayVersion().convention(DEFAULT_PLAY_VERSION);
    this.platform.getJavaVersion().convention(JavaVersion.current());
    this.platform.getScalaVersion().convention(platform.getPlayVersion().map(playVersion -> PlayMajorVersion.forPlayVersion(playVersion).getDefaultScalaPlatform()));
    this.injectedRoutesGenerator = objectFactory.property(Boolean.class);
    injectedRoutesGenerator.convention(platform.getPlayVersion().map(playVersion -> !PlayMajorVersion.forPlayVersion(playVersion).hasSupportForStaticRoutesGenerator()));
}
 
Example #29
Source File: InProcessJavaCompilerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Compiler<JavaCompileSpec> create(CompileOptions options) {
    if (JavaVersion.current().isJava6Compatible()) {
        return createJdk6Compiler();
    }
    if (SUN_COMPILER_AVAILABLE) {
        return new SunCompilerFactory().create();
    }
    throw new RuntimeException("Cannot find a Java compiler API. Please let us know which JDK/platform you are using. To work around this problem, try 'compileJava.options.useAnt=true'.");
}
 
Example #30
Source File: TestNGTestFramework.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestNGTestFramework(Test testTask, DefaultTestFilter filter, Instantiator instantiator) {
    this.testTask = testTask;
    this.filter = filter;
    options = instantiator.newInstance(TestNGOptions.class, testTask.getProject().getProjectDir());
    options.setAnnotationsOnSourceCompatibility(JavaVersion.toVersion(testTask.getProject().property("sourceCompatibility")));
    conventionMapOutputDirectory(options, testTask.getReports().getHtml());
    detector = new TestNGDetector(new ClassFileExtractionManager(testTask.getTemporaryDirFactory()));
}