List of usage examples for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_TargetPlatform
String OPTION_TargetPlatform
To view the source code for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_TargetPlatform.
Click Source Link
From source file:br.com.objectos.code.JdtSourceVersion.java
License:Apache License
public void set(ImmutableMap.Builder<String, Object> optionMap) { optionMap.put(CompilerOptions.OPTION_TargetPlatform, version); optionMap.put(CompilerOptions.OPTION_Compliance, version); optionMap.put(CompilerOptions.OPTION_Source, version); }
From source file:com.codenvy.ide.ext.java.BaseTest.java
License:Open Source License
public BaseTest() { options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); options.put(JavaCore.CORE_ENCODING, "UTF-8"); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); options.put(CompilerOptions.OPTION_TargetPlatform, JavaCore.VERSION_1_7); options.put(AssistOptions.OPTION_PerformVisibilityCheck, AssistOptions.ENABLED); options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_TaskTags, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_SuppressWarnings, CompilerOptions.DISABLED); options.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX"); options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); options.put(CompilerOptions.OPTION_Process_Annotations, JavaCore.DISABLED); }
From source file:com.mysema.codegen.ECJEvaluatorFactory.java
License:Apache License
public static CompilerOptions getDefaultCompilerOptions() { String javaSpecVersion = System.getProperty("java.specification.version"); if (javaSpecVersion.equals("1.8")) { javaSpecVersion = "1.7"; }/*from www .j a va 2 s. com*/ Map<String, Object> settings = Maps.newHashMap(); settings.put(CompilerOptions.OPTION_Source, javaSpecVersion); settings.put(CompilerOptions.OPTION_TargetPlatform, javaSpecVersion); settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE); return new CompilerOptions(settings); }
From source file:com.tsc9526.monalisa.plugin.eclipse.jdt.JDTCompiler.java
License:Open Source License
public CompilerOptions getCompilerOptions() { Map<String, String> settings = new HashMap<String, String>(); settings.put(CompilerOptions.OPTION_ReportMissingSerialVersion, CompilerOptions.IGNORE); settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE); settings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE); settings.put(CompilerOptions.OPTION_Encoding, "UTF-8"); settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); String javaVersion = CompilerOptions.VERSION_1_6; if (System.getProperty("java.version").startsWith("1.5")) { javaVersion = CompilerOptions.VERSION_1_5; } else if (System.getProperty("java.version").startsWith("1.7")) { javaVersion = CompilerOptions.VERSION_1_7; } else if (System.getProperty("java.version").startsWith("1.8")) { javaVersion = CompilerOptions.VERSION_1_8; }/*from w w w .j a v a2s .c om*/ settings.put(CompilerOptions.OPTION_Source, javaVersion); settings.put(CompilerOptions.OPTION_TargetPlatform, javaVersion); settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE); settings.put(CompilerOptions.OPTION_Compliance, javaVersion); return new CompilerOptions(settings); }
From source file:com.wavemaker.tools.compiler.WaveMakerJavaCompiler.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public CompilationTask getTask(Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes, Iterable<? extends JavaFileObject> compilationUnits) { if (fileManager == null) { fileManager = this.getStandardFileManager(diagnosticListener, null, null); }/* w w w. j a va2 s.co m*/ PrintWriter writer = createPrintWriter(out); EclipseBatchCompiler batchCompiler = new EclipseBatchCompiler(writer, writer, false); batchCompiler.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); batchCompiler.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); batchCompiler.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); batchCompiler.diagnosticListener = diagnosticListener; batchCompiler.fileManager = fileManager; batchCompiler.setCompilationUnits(compilationUnits); if (options != null) { for (Iterator<String> iterator = options.iterator(); iterator.hasNext();) { batchCompiler.fileManager.handleOption(iterator.next(), iterator); } } batchCompiler.configure(getArgumentsForBatchCompiler(asList(options), asList(classes))); if (fileManager instanceof StandardJavaFileManager) { Iterable<? extends File> location = ((StandardJavaFileManager) fileManager) .getLocation(StandardLocation.CLASS_OUTPUT); if (location != null) { batchCompiler.setDestinationPath(location.iterator().next().getAbsolutePath()); } } return new CompilationTaskImpl(batchCompiler); }
From source file:com.xqbase.compiler.eclipse.EclipseJavaCompiler.java
License:Open Source License
public CompilerResult performCompile(CompilerConfiguration config) throws CompilerException { // added by xqbase-compiler-eclipse if (config.getGeneratedSourcesDirectory() != null) { config.getGeneratedSourcesDirectory().mkdirs(); }/*from ww w . j av a 2 s . c om*/ List<CompilerMessage> errors = new LinkedList<CompilerMessage>(); List<String> classpathEntries = config.getClasspathEntries(); URL[] urls = new URL[1 + classpathEntries.size()]; int i = 0; try { urls[i++] = new File(config.getOutputLocation()).toURL(); for (String entry : classpathEntries) { urls[i++] = new File(entry).toURL(); } } catch (MalformedURLException e) { throw new CompilerException("Error while converting the classpath entries to URLs.", e); } ClassLoader classLoader = new URLClassLoader(urls); SourceCodeLocator sourceCodeLocator = new SourceCodeLocator(config.getSourceLocations()); INameEnvironment env = new EclipseCompilerINameEnvironment(sourceCodeLocator, classLoader, errors); IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems(); // ---------------------------------------------------------------------- // Build settings from configuration // ---------------------------------------------------------------------- Map<String, String> settings = new HashMap<String, String>(); if (config.isDebug()) { settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); } if (!config.isShowWarnings()) { Map opts = new CompilerOptions().getMap(); for (Object optKey : opts.keySet()) { if (opts.get(optKey).equals(CompilerOptions.WARNING)) { settings.put((String) optKey, CompilerOptions.IGNORE); } } } String sourceVersion = decodeVersion(config.getSourceVersion()); if (sourceVersion != null) { settings.put(CompilerOptions.OPTION_Source, sourceVersion); } String targetVersion = decodeVersion(config.getTargetVersion()); if (targetVersion != null) { settings.put(CompilerOptions.OPTION_TargetPlatform, targetVersion); if (config.isOptimize()) { settings.put(CompilerOptions.OPTION_Compliance, targetVersion); } } if (StringUtils.isNotEmpty(config.getSourceEncoding())) { settings.put(CompilerOptions.OPTION_Encoding, config.getSourceEncoding()); } if (config.isShowDeprecation()) { settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING); } else { settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE); } // ---------------------------------------------------------------------- // Set Eclipse-specific options // ---------------------------------------------------------------------- settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); // compiler-specific extra options override anything else in the config object... Map<String, String> extras = config.getCustomCompilerArguments(); if (extras != null && !extras.isEmpty()) { settings.putAll(extras); } if (settings.containsKey("-properties")) { initializeWarnings(settings.get("-properties"), settings); settings.remove("-properties"); } IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault()); ICompilerRequestor requestor = new EclipseCompilerICompilerRequestor(config.getOutputLocation(), errors); List<CompilationUnit> compilationUnits = new ArrayList<CompilationUnit>(); for (String sourceRoot : config.getSourceLocations()) { Set<String> sources = getSourceFilesForSourceRoot(config, sourceRoot); for (String source : sources) { CompilationUnit unit = new CompilationUnit(source, makeClassName(source, sourceRoot), errors, config.getSourceEncoding()); compilationUnits.add(unit); } } // ---------------------------------------------------------------------- // Compile! // ---------------------------------------------------------------------- CompilerOptions options = new CompilerOptions(settings); Compiler compiler = new Compiler(env, policy, options, requestor, problemFactory); ICompilationUnit[] units = compilationUnits.toArray(new ICompilationUnit[compilationUnits.size()]); compiler.compile(units); CompilerResult compilerResult = new CompilerResult().compilerMessages(errors); for (CompilerMessage compilerMessage : errors) { if (compilerMessage.isError()) { compilerResult.setSuccess(false); continue; } } return compilerResult; }
From source file:de.plugins.eclipse.depclipse.testcommons.TestingEnvironment.java
License:Open Source License
public IPath addProject(String projectName, String compliance) { checkAssertion("a workspace must be open", this.isOpen); //$NON-NLS-1$ IProject project = createProject(projectName); String compilerVersion = null; compilerVersion = CompilerOptions.VERSION_1_6; IJavaProject javaProject = JavaCore.create(project); Map<String, String> options = new HashMap<String, String>(); options.put(CompilerOptions.OPTION_Compliance, compilerVersion); options.put(CompilerOptions.OPTION_Source, compilerVersion); options.put(CompilerOptions.OPTION_TargetPlatform, compilerVersion); javaProject.setOptions(options);/*from w w w .ja v a 2s. c o m*/ return project.getFullPath(); }
From source file:io.gige.compiler.internal.CompilationTaskImpl.java
License:Apache License
protected Main parseOptions(PrintWriter out, Iterable<String> argv, Iterable<? extends JavaFileObject> compilationUnits) { Map<String, String> defaults = new HashMap<>(); defaults.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8); defaults.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8); defaults.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8); Stream<String> files = Stream.concat(stream(argv.spliterator(), false), stream(compilationUnits.spliterator(), false).map(JavaFileObject::toUri) .map(uri -> new File(uri).getAbsolutePath())); Main main = new Main(out, out, false, defaults, null); main.configure(files.toArray(String[]::new)); return main;//from w w w. ja va 2 s . co m }
From source file:io.takari.maven.plugins.compile.jdt.CompilerJdt.java
License:Open Source License
@Override public int compile() throws MojoExecutionException, IOException { Map<String, String> args = new HashMap<String, String>(); // XXX figure out how to reuse source/target check from jdt // org.eclipse.jdt.internal.compiler.batch.Main.validateOptions(boolean) args.put(CompilerOptions.OPTION_TargetPlatform, getTarget()); // support 5/6/7 aliases args.put(CompilerOptions.OPTION_Compliance, getTarget()); // support 5/6/7 aliases args.put(CompilerOptions.OPTION_Source, getSource()); // support 5/6/7 aliases args.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); Set<Debug> debug = getDebug(); if (debug == null || debug.contains(Debug.all)) { args.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); args.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); args.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); } else if (debug.contains(Debug.none)) { args.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); args.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); args.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE); } else {/* ww w . ja v a 2 s .co m*/ args.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); args.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); args.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE); for (Debug keyword : debug) { switch (keyword) { case lines: args.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); break; case source: args.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); break; case vars: args.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); break; default: throw new IllegalArgumentException(); } } } class _CompilerOptions extends CompilerOptions { public void setShowWarnings(boolean showWarnings) { if (showWarnings) { warningThreshold = IrritantSet.COMPILER_DEFAULT_WARNINGS; } else { warningThreshold = new IrritantSet(0); } } } _CompilerOptions compilerOptions = new _CompilerOptions(); compilerOptions.set(args); compilerOptions.performMethodsFullRecovery = false; compilerOptions.performStatementsRecovery = false; compilerOptions.verbose = isVerbose(); compilerOptions.suppressWarnings = true; compilerOptions.setShowWarnings(isShowWarnings()); compilerOptions.docCommentSupport = true; if (isProcEscalate() && strategy instanceof IncrementalCompilationStrategy) { strategy.enqueueAllSources(); strategy = new FullCompilationStrategy(); } Classpath namingEnvironment = strategy.createClasspath(); IErrorHandlingPolicy errorHandlingPolicy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); IProblemFactory problemFactory = ProblemFactory.getProblemFactory(Locale.getDefault()); Compiler compiler = new Compiler(namingEnvironment, errorHandlingPolicy, compilerOptions, this, problemFactory); compiler.options.produceReferenceInfo = true; EclipseFileManager fileManager = null; try { if (!isProcNone()) { fileManager = new EclipseFileManager(null, getSourceEncoding()); fileManager.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, dependencies); fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(getOutputDirectory())); fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(getGeneratedSourcesDirectory())); ProcessingEnvImpl processingEnv = new ProcessingEnvImpl(context, fileManager, getAnnotationProcessorOptions(), compiler, this); compiler.annotationProcessorManager = new AnnotationProcessorManager(processingEnv, fileManager, getAnnotationProcessors()); compiler.options.storeAnnotations = true; } return strategy.compile(namingEnvironment, compiler); } finally { if (fileManager != null) { fileManager.flush(); fileManager.close(); } } }
From source file:jetbrick.template.compiler.JdtCompiler.java
License:Open Source License
private CompilerOptions getCompilerOptions() { Map<String, String> settings = new HashMap<String, String>(); settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE); settings.put(CompilerOptions.OPTION_Encoding, JavaSource.JAVA_FILE_ENCODING); settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); CompilerOptions options = new CompilerOptions(settings); options.parseLiteralExpressionsAsConstants = true; return options; }