org.gradle.api.tasks.compile.CompileOptions Java Examples
The following examples show how to use
org.gradle.api.tasks.compile.CompileOptions.
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: MinimalJavaCompileOptions.java From javaide with GNU General Public License v3.0 | 6 votes |
public MinimalJavaCompileOptions(final CompileOptions compileOptions) { FileCollection sourcepath = compileOptions.getSourcepath(); this.sourcepath = sourcepath == null ? null : ImmutableList.copyOf(sourcepath.getFiles()); this.compilerArgs = Lists.newArrayList(compileOptions.getAllCompilerArgs()); this.encoding = compileOptions.getEncoding(); this.bootClasspath = DeprecationLogger.whileDisabled(new Factory<String>() { @Nullable @Override @SuppressWarnings("deprecation") public String create() { return compileOptions.getBootClasspath(); } }); this.extensionDirs = compileOptions.getExtensionDirs(); this.forkOptions = compileOptions.getForkOptions(); this.debugOptions = compileOptions.getDebugOptions(); this.debug = compileOptions.isDebug(); this.deprecation = compileOptions.isDeprecation(); this.failOnError = compileOptions.isFailOnError(); this.listFiles = compileOptions.isListFiles(); this.verbose = compileOptions.isVerbose(); this.warnings = compileOptions.isWarnings(); this.annotationProcessorGeneratedSourcesDirectory = compileOptions.getAnnotationProcessorGeneratedSourcesDirectory(); }
Example #2
Source File: DefaultJavaCompilerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Compiler<JavaCompileSpec> createTargetCompiler(CompileOptions options, boolean jointCompilation) { if (options.isFork() && options.getForkOptions().getExecutable() != null) { return new CommandLineJavaCompiler(); } Compiler<JavaCompileSpec> compiler = new JdkJavaCompiler(); if (options.isFork() && !jointCompilation) { return new DaemonJavaCompiler(daemonWorkingDir, compiler, compilerDaemonFactory); } return compiler; }
Example #3
Source File: IncrementalCompilationSupport.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void compilationComplete(CompileOptions options, ClassDependencyInfoExtractor extractor, ClassDependencyInfoSerializer serializer, Iterable<JarArchive> jarsOnClasspath) { if (options.isIncremental()) { Clock clock = new Clock(); ClassDependencyInfo info = extractor.extractInfo(""); serializer.writeInfo(info); LOG.lifecycle("Performed class dependency analysis in {}, wrote results into {}", clock.getTime(), serializer); // clock = new Clock(); // jarSnapshotFeeder.storeJarSnapshots(jarsOnClasspath); // LOG.lifecycle("Wrote jar snapshots in {}.", clock.getTime()); } }
Example #4
Source File: GroovyCompilerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
Compiler<GroovyJavaJointCompileSpec> create(final GroovyCompileOptions groovyOptions, final CompileOptions javaOptions) { return DeprecationLogger.whileDisabled(new Factory<Compiler<GroovyJavaJointCompileSpec>>() { public Compiler<GroovyJavaJointCompileSpec> create() { // Some sanity checking of options if (groovyOptions.isUseAnt() && !javaOptions.isUseAnt()) { LOGGER.warn("When groovyOptions.useAnt is enabled, options.useAnt must also be enabled. Ignoring options.useAnt = false."); javaOptions.setUseAnt(true); } else if (!groovyOptions.isUseAnt() && javaOptions.isUseAnt()) { LOGGER.warn("When groovyOptions.useAnt is disabled, options.useAnt must also be disabled. Ignoring options.useAnt = true."); javaOptions.setUseAnt(false); } if (groovyOptions.isUseAnt()) { return new AntGroovyCompiler(antBuilder, classPathRegistry); } javaCompilerFactory.setJointCompilation(true); Compiler<JavaCompileSpec> javaCompiler = javaCompilerFactory.create(javaOptions); Compiler<GroovyJavaJointCompileSpec> groovyCompiler = new ApiGroovyCompiler(javaCompiler); CompilerDaemonFactory daemonFactory; if (groovyOptions.isFork()) { daemonFactory = compilerDaemonManager; } else { daemonFactory = inProcessCompilerDaemonFactory; } groovyCompiler = new DaemonGroovyCompiler(project, groovyCompiler, daemonFactory); return new NormalizingGroovyCompiler(groovyCompiler); } }); }
Example #5
Source File: Jdk6JavaCompiler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private JavaCompiler.CompilationTask createCompileTask(JavaCompileSpec spec) { List<String> options = new JavaCompilerArgumentsBuilder(spec).build(); JavaCompiler compiler = findCompiler(); if(compiler==null){ throw new RuntimeException("Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory."); } CompileOptions compileOptions = spec.getCompileOptions(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, compileOptions.getEncoding() != null ? Charset.forName(compileOptions.getEncoding()) : null); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(spec.getSource()); return compiler.getTask(null, null, null, options, null, compilationUnits); }
Example #6
Source File: DefaultJavaCompilerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public Compiler<JavaCompileSpec> create(CompileOptions options) { fallBackToAntIfNecessary(options); if (options.isUseAnt()) { return new AntJavaCompiler(antBuilderFactory); } Compiler<JavaCompileSpec> result = createTargetCompiler(options); if (!jointCompilation) { result = new NormalizingJavaCompiler(result); } return result; }
Example #7
Source File: DefaultJavaCompilerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void fallBackToAntIfNecessary(CompileOptions options) { if (options.isUseAnt()) { return; } if (options.getCompiler() != null) { LOGGER.warn("Falling back to Ant javac task ('CompileOptions.useAnt = true') because 'CompileOptions.compiler' is set."); options.setUseAnt(true); } }
Example #8
Source File: DefaultJavaCompilerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Compiler<JavaCompileSpec> createTargetCompiler(CompileOptions options) { if (options.isFork() && options.getForkOptions().getExecutable() != null) { return new CommandLineJavaCompiler(createSerializableTempFileProvider(), project.getProjectDir()); } Compiler<JavaCompileSpec> compiler = inProcessCompilerFactory.create(options); if (options.isFork() && !jointCompilation) { return new DaemonJavaCompiler(project, compiler, compilerDaemonManager); } return compiler; }
Example #9
Source File: GroovyCompilerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public Compiler<GroovyJavaJointCompileSpec> newCompiler(GroovyJavaJointCompileSpec spec) { CompileOptions javaOptions = spec.getCompileOptions(); GroovyCompileOptions groovyOptions = spec.getGroovyCompileOptions(); Compiler<JavaCompileSpec> javaCompiler = javaCompilerFactory.createForJointCompilation(javaOptions); Compiler<GroovyJavaJointCompileSpec> groovyCompiler = new ApiGroovyCompiler(javaCompiler); CompilerDaemonFactory daemonFactory; if (groovyOptions.isFork()) { daemonFactory = compilerDaemonFactory; } else { daemonFactory = inProcessCompilerDaemonFactory; } groovyCompiler = new DaemonGroovyCompiler(project.getRootProject().getProjectDir(), groovyCompiler, project.getServices().get(ClassPathRegistry.class), daemonFactory); return new NormalizingGroovyCompiler(groovyCompiler); }
Example #10
Source File: GroovyCompilerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public Compiler<GroovyJavaJointCompileSpec> newCompiler(GroovyJavaJointCompileSpec spec) { CompileOptions javaOptions = spec.getCompileOptions(); GroovyCompileOptions groovyOptions = spec.getGroovyCompileOptions(); Compiler<JavaCompileSpec> javaCompiler = javaCompilerFactory.createForJointCompilation(javaOptions); Compiler<GroovyJavaJointCompileSpec> groovyCompiler = new ApiGroovyCompiler(javaCompiler); CompilerDaemonFactory daemonFactory; if (groovyOptions.isFork()) { daemonFactory = compilerDaemonFactory; } else { daemonFactory = inProcessCompilerDaemonFactory; } groovyCompiler = new DaemonGroovyCompiler(project.getRootProject().getProjectDir(), groovyCompiler, project.getServices().get(ClassPathRegistry.class), daemonFactory); return new NormalizingGroovyCompiler(groovyCompiler); }
Example #11
Source File: JdkJavaCompiler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private JavaCompiler.CompilationTask createCompileTask(JavaCompileSpec spec) { List<String> options = new JavaCompilerArgumentsBuilder(spec).build(); JavaCompiler compiler = findCompiler(); if(compiler==null){ throw new RuntimeException("Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory."); } CompileOptions compileOptions = spec.getCompileOptions(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, compileOptions.getEncoding() != null ? Charset.forName(compileOptions.getEncoding()) : null); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(spec.getSource()); return compiler.getTask(null, null, null, options, null, compilationUnits); }
Example #12
Source File: InProcessJavaCompilerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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 #13
Source File: IncrementalCompilationSupport.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void compilationComplete(CompileOptions options, ClassDependencyInfoExtractor extractor, ClassDependencyInfoSerializer serializer, Iterable<JarArchive> jarsOnClasspath) { if (options.isIncremental()) { Clock clock = new Clock(); ClassDependencyInfo info = extractor.extractInfo(""); serializer.writeInfo(info); LOG.lifecycle("Performed class dependency analysis in {}, wrote results into {}", clock.getTime(), serializer); // clock = new Clock(); // jarSnapshotFeeder.storeJarSnapshots(jarsOnClasspath); // LOG.lifecycle("Wrote jar snapshots in {}.", clock.getTime()); } }
Example #14
Source File: GroovyCompilerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
Compiler<GroovyJavaJointCompileSpec> create(final GroovyCompileOptions groovyOptions, final CompileOptions javaOptions) { return DeprecationLogger.whileDisabled(new Factory<Compiler<GroovyJavaJointCompileSpec>>() { public Compiler<GroovyJavaJointCompileSpec> create() { // Some sanity checking of options if (groovyOptions.isUseAnt() && !javaOptions.isUseAnt()) { LOGGER.warn("When groovyOptions.useAnt is enabled, options.useAnt must also be enabled. Ignoring options.useAnt = false."); javaOptions.setUseAnt(true); } else if (!groovyOptions.isUseAnt() && javaOptions.isUseAnt()) { LOGGER.warn("When groovyOptions.useAnt is disabled, options.useAnt must also be disabled. Ignoring options.useAnt = true."); javaOptions.setUseAnt(false); } if (groovyOptions.isUseAnt()) { return new AntGroovyCompiler(antBuilder, classPathRegistry); } javaCompilerFactory.setJointCompilation(true); Compiler<JavaCompileSpec> javaCompiler = javaCompilerFactory.create(javaOptions); Compiler<GroovyJavaJointCompileSpec> groovyCompiler = new ApiGroovyCompiler(javaCompiler); CompilerDaemonFactory daemonFactory; if (groovyOptions.isFork()) { daemonFactory = compilerDaemonManager; } else { daemonFactory = inProcessCompilerDaemonFactory; } groovyCompiler = new DaemonGroovyCompiler(project, groovyCompiler, daemonFactory); return new NormalizingGroovyCompiler(groovyCompiler); } }); }
Example #15
Source File: Jdk6JavaCompiler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private JavaCompiler.CompilationTask createCompileTask(JavaCompileSpec spec) { List<String> options = new JavaCompilerArgumentsBuilder(spec).build(); JavaCompiler compiler = findCompiler(); if(compiler==null){ throw new RuntimeException("Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory."); } CompileOptions compileOptions = spec.getCompileOptions(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, compileOptions.getEncoding() != null ? Charset.forName(compileOptions.getEncoding()) : null); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(spec.getSource()); return compiler.getTask(null, null, null, options, null, compilationUnits); }
Example #16
Source File: DefaultJavaCompilerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public Compiler<JavaCompileSpec> create(CompileOptions options) { fallBackToAntIfNecessary(options); if (options.isUseAnt()) { return new AntJavaCompiler(antBuilderFactory); } Compiler<JavaCompileSpec> result = createTargetCompiler(options); if (!jointCompilation) { result = new NormalizingJavaCompiler(result); } return result; }
Example #17
Source File: DefaultJavaCompilerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void fallBackToAntIfNecessary(CompileOptions options) { if (options.isUseAnt()) { return; } if (options.getCompiler() != null) { LOGGER.warn("Falling back to Ant javac task ('CompileOptions.useAnt = true') because 'CompileOptions.compiler' is set."); options.setUseAnt(true); } }
Example #18
Source File: DefaultJavaCompilerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Compiler<JavaCompileSpec> createTargetCompiler(CompileOptions options) { if (options.isFork() && options.getForkOptions().getExecutable() != null) { return new CommandLineJavaCompiler(createSerializableTempFileProvider(), project.getProjectDir()); } Compiler<JavaCompileSpec> compiler = inProcessCompilerFactory.create(options); if (options.isFork() && !jointCompilation) { return new DaemonJavaCompiler(project, compiler, compilerDaemonManager); } return compiler; }
Example #19
Source File: InProcessJavaCompilerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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 #20
Source File: JdkJavaCompiler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private JavaCompiler.CompilationTask createCompileTask(JavaCompileSpec spec) { List<String> options = new JavaCompilerArgumentsBuilder(spec).build(); JavaCompiler compiler = findCompiler(); if(compiler==null){ throw new RuntimeException("Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory."); } CompileOptions compileOptions = spec.getCompileOptions(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, compileOptions.getEncoding() != null ? Charset.forName(compileOptions.getEncoding()) : null); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(spec.getSource()); return compiler.getTask(null, null, null, options, null, compilationUnits); }
Example #21
Source File: DefaultJavaCompilerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Compiler<JavaCompileSpec> createTargetCompiler(CompileOptions options, boolean jointCompilation) { if (options.isFork() && options.getForkOptions().getExecutable() != null) { return new CommandLineJavaCompiler(); } Compiler<JavaCompileSpec> compiler = new JdkJavaCompiler(); if (options.isFork() && !jointCompilation) { return new DaemonJavaCompiler(daemonWorkingDir, compiler, compilerDaemonFactory); } return compiler; }
Example #22
Source File: JavaCompilerArgumentsBuilder.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
private void addMainOptions() { if (!includeMainOptions) { return; } String sourceCompatibility = spec.getSourceCompatibility(); if (sourceCompatibility != null && !JavaVersion.current().equals(JavaVersion.toVersion(sourceCompatibility))) { args.add("-source"); args.add(sourceCompatibility); } String targetCompatibility = spec.getTargetCompatibility(); if (targetCompatibility != null && !JavaVersion.current().equals(JavaVersion.toVersion(targetCompatibility))) { args.add("-target"); args.add(targetCompatibility); } File destinationDir = spec.getDestinationDir(); if (destinationDir != null) { args.add("-d"); args.add(destinationDir.getPath()); } CompileOptions compileOptions = spec.getCompileOptions(); if (compileOptions.isVerbose()) { args.add("-verbose"); } if (compileOptions.isDeprecation()) { args.add("-deprecation"); } if (!compileOptions.isWarnings()) { args.add("-nowarn"); } if (compileOptions.isDebug()) { if (compileOptions.getDebugOptions().getDebugLevel() != null) { args.add("-g:" + compileOptions.getDebugOptions().getDebugLevel().trim()); } else { args.add("-g"); } } else { args.add("-g:none"); } if (compileOptions.getEncoding() != null) { args.add("-encoding"); args.add(compileOptions.getEncoding()); } if (compileOptions.getBootClasspath() != null) { args.add("-bootclasspath"); args.add(compileOptions.getBootClasspath()); } if (compileOptions.getExtensionDirs() != null) { args.add("-extdirs"); args.add(compileOptions.getExtensionDirs()); } if (compileOptions.getCompilerArgs() != null) { args.addAll(compileOptions.getCompilerArgs()); } }
Example #23
Source File: JavaCompilerArgumentsBuilder.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
private void addMainOptions() { if (!includeMainOptions) { return; } String sourceCompatibility = spec.getSourceCompatibility(); if (sourceCompatibility != null && !JavaVersion.current().equals(JavaVersion.toVersion(sourceCompatibility))) { args.add("-source"); args.add(sourceCompatibility); } String targetCompatibility = spec.getTargetCompatibility(); if (targetCompatibility != null && !JavaVersion.current().equals(JavaVersion.toVersion(targetCompatibility))) { args.add("-target"); args.add(targetCompatibility); } File destinationDir = spec.getDestinationDir(); if (destinationDir != null) { args.add("-d"); args.add(destinationDir.getPath()); } CompileOptions compileOptions = spec.getCompileOptions(); if (compileOptions.isVerbose()) { args.add("-verbose"); } if (compileOptions.isDeprecation()) { args.add("-deprecation"); } if (!compileOptions.isWarnings()) { args.add("-nowarn"); } if (compileOptions.isDebug()) { if (compileOptions.getDebugOptions().getDebugLevel() != null) { args.add("-g:" + compileOptions.getDebugOptions().getDebugLevel().trim()); } else { args.add("-g"); } } else { args.add("-g:none"); } if (compileOptions.getEncoding() != null) { args.add("-encoding"); args.add(compileOptions.getEncoding()); } if (compileOptions.getBootClasspath() != null) { args.add("-bootclasspath"); args.add(compileOptions.getBootClasspath()); } if (compileOptions.getExtensionDirs() != null) { args.add("-extdirs"); args.add(compileOptions.getExtensionDirs()); } if (compileOptions.getCompilerArgs() != null) { args.addAll(compileOptions.getCompilerArgs()); } }
Example #24
Source File: JavaCompilerArgumentsBuilder.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
private void addMainOptions() { if (!includeMainOptions) { return; } String sourceCompatibility = spec.getSourceCompatibility(); if (sourceCompatibility != null && !JavaVersion.current().equals(JavaVersion.toVersion(sourceCompatibility))) { args.add("-source"); args.add(sourceCompatibility); } String targetCompatibility = spec.getTargetCompatibility(); if (targetCompatibility != null && !JavaVersion.current().equals(JavaVersion.toVersion(targetCompatibility))) { args.add("-target"); args.add(targetCompatibility); } File destinationDir = spec.getDestinationDir(); if (destinationDir != null) { args.add("-d"); args.add(destinationDir.getPath()); } CompileOptions compileOptions = spec.getCompileOptions(); if (compileOptions.isVerbose()) { args.add("-verbose"); } if (compileOptions.isDeprecation()) { args.add("-deprecation"); } if (!compileOptions.isWarnings()) { args.add("-nowarn"); } if (compileOptions.isDebug()) { if (compileOptions.getDebugOptions().getDebugLevel() != null) { args.add("-g:" + compileOptions.getDebugOptions().getDebugLevel().trim()); } else { args.add("-g"); } } else { args.add("-g:none"); } if (compileOptions.getEncoding() != null) { args.add("-encoding"); args.add(compileOptions.getEncoding()); } if (compileOptions.getBootClasspath() != null) { //TODO: move bootclasspath to platform args.add("-bootclasspath"); args.add(compileOptions.getBootClasspath()); } if (compileOptions.getExtensionDirs() != null) { args.add("-extdirs"); args.add(compileOptions.getExtensionDirs()); } if (compileOptions.getCompilerArgs() != null) { args.addAll(compileOptions.getCompilerArgs()); } }
Example #25
Source File: AntDependsStaleClassCleaner.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public AntDependsStaleClassCleaner(Factory<AntBuilder> antBuilderFactory, CompileOptions compileOptions) { this.antBuilderFactory = antBuilderFactory; this.compileOptions = compileOptions; }
Example #26
Source File: DefaultJavaCompileSpec.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void setCompileOptions(CompileOptions compileOptions) { this.compileOptions = compileOptions; }
Example #27
Source File: DefaultJavaCompileSpec.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public CompileOptions getCompileOptions() { return compileOptions; }
Example #28
Source File: ScalaCompile.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
/** * Returns the Java compilation options. */ @Nested public CompileOptions getOptions() { return compileOptions; }
Example #29
Source File: DefaultJavaCompilerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public Compiler<JavaCompileSpec> createForJointCompilation(CompileOptions options) { return createTargetCompiler(options, true); }
Example #30
Source File: DefaultJavaCompilerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public Compiler<JavaCompileSpec> create(CompileOptions options) { Compiler<JavaCompileSpec> result = createTargetCompiler(options, false); return new NormalizingJavaCompiler(result); }