private void addOtherOptions(final Element rootElement) { final Map<String, String> options = new THashMap<String, String>(myProjectLevelCompilerOptions.getAllOptions()); options.putAll(myModuleLevelCompilerOptions.getAllOptions()); options.putAll(myBC.getCompilerOptions().getAllOptions()); final String addOptions = myProjectLevelCompilerOptions.getAdditionalOptions() + " " + myModuleLevelCompilerOptions.getAdditionalOptions() + " " + myBC.getCompilerOptions().getAdditionalOptions(); final List<String> contextRootInAddOptions = FlexCommonUtils.getOptionValues(addOptions, "context-root", "compiler.context-root"); if (options.get("compiler.context-root") == null && contextRootInAddOptions.isEmpty()) { final List<String> servicesInAddOptions = FlexCommonUtils.getOptionValues(addOptions, "services", "compiler.services"); if (options.get("compiler.services") != null || !servicesInAddOptions.isEmpty()) { options.put("compiler.context-root", ""); } } for (final Map.Entry<String, String> entry : options.entrySet()) { addOption(rootElement, CompilerOptionInfo.getOptionInfo(entry.getKey()), entry.getValue()); } final String namespacesRaw = options.get("compiler.namespaces.namespace"); if (namespacesRaw != null && myBC.getOutputType() == OutputType.Library) { final String namespaces = FlexCommonUtils.replacePathMacros( namespacesRaw, myModule, myFlexmojos ? "" : mySdk.getHomePath()); final StringBuilder buf = new StringBuilder(); for (final String listEntry : StringUtil.split(namespaces, CompilerOptionInfo.LIST_ENTRIES_SEPARATOR)) { final int tabIndex = listEntry.indexOf(CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR); assert tabIndex != -1 : namespaces; final String namespace = listEntry.substring(0, tabIndex); if (buf.length() > 0) buf.append(CompilerOptionInfo.LIST_ENTRIES_SEPARATOR); buf.append(namespace); } if (buf.length() > 0) { addOption(rootElement, CompilerOptionInfo.INCLUDE_NAMESPACES_INFO, buf.toString()); } } }
private void addNamespaces(final Element rootElement) { final StringBuilder namespaceBuilder = new StringBuilder(); FlexCommonUtils.processStandardNamespaces( myBC, new PairConsumer<String, String>() { @Override public void consume(final String namespace, final String relativePath) { if (namespaceBuilder.length() > 0) { namespaceBuilder.append(CompilerOptionInfo.LIST_ENTRIES_SEPARATOR); } namespaceBuilder .append(namespace) .append(CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR) .append(CompilerOptionInfo.FLEX_SDK_MACRO + "/") .append(relativePath); } }); if (namespaceBuilder.length() == 0) return; final CompilerOptionInfo info = CompilerOptionInfo.getOptionInfo("compiler.namespaces.namespace"); addOption(rootElement, info, namespaceBuilder.toString()); }
private void addSourcePaths(final Element rootElement) { final String localeValue = getValueAndSource(CompilerOptionInfo.getOptionInfo("compiler.locale")).first; final List<String> locales = StringUtil.split(localeValue, CompilerOptionInfo.LIST_ENTRIES_SEPARATOR); // when adding source paths we respect locales set both in UI and in Additional compiler options locales.addAll( FlexCommonUtils.getOptionValues( myProjectLevelCompilerOptions.getAdditionalOptions(), "locale", "compiler.locale")); locales.addAll( FlexCommonUtils.getOptionValues( myModuleLevelCompilerOptions.getAdditionalOptions(), "locale", "compiler.locale")); locales.addAll( FlexCommonUtils.getOptionValues( myBC.getCompilerOptions().getAdditionalOptions(), "locale", "compiler.locale")); final Set<String> sourcePathsWithLocaleToken = new THashSet<String>(); // Set - to avoid duplication of paths like "locale/{locale}" final List<String> sourcePathsWithoutLocaleToken = new LinkedList<String>(); for (JpsModuleSourceRoot srcRoot : myModule.getSourceRoots(JavaSourceRootType.SOURCE)) { final String srcRootPath = JpsPathUtil.urlToPath(srcRoot.getUrl()); if (locales.contains(PathUtilRt.getFileName(srcRootPath))) { sourcePathsWithLocaleToken.add( PathUtilRt.getParentPath(srcRootPath) + "/" + FlexCommonUtils.LOCALE_TOKEN); } else { sourcePathsWithoutLocaleToken.add(srcRootPath); } } if (includeTestRoots()) { for (JpsModuleSourceRoot srcRoot : myModule.getSourceRoots(JavaSourceRootType.TEST_SOURCE)) { final String srcRootPath = JpsPathUtil.urlToPath(srcRoot.getUrl()); if (locales.contains(PathUtilRt.getFileName(srcRootPath))) { sourcePathsWithLocaleToken.add( PathUtilRt.getParentPath(srcRootPath) + "/" + FlexCommonUtils.LOCALE_TOKEN); } else { sourcePathsWithoutLocaleToken.add(srcRootPath); } } } final StringBuilder sourcePathBuilder = new StringBuilder(); if (myCSS) { final String cssFolderPath = PathUtilRt.getParentPath(myBC.getMainClass()); if (!sourcePathsWithoutLocaleToken.contains(cssFolderPath)) { sourcePathBuilder.append(cssFolderPath); } } for (final String sourcePath : sourcePathsWithLocaleToken) { if (sourcePathBuilder.length() > 0) { sourcePathBuilder.append(CompilerOptionInfo.LIST_ENTRIES_SEPARATOR); } sourcePathBuilder.append(sourcePath); } for (final String sourcePath : sourcePathsWithoutLocaleToken) { if (sourcePathBuilder.length() > 0) { sourcePathBuilder.append(CompilerOptionInfo.LIST_ENTRIES_SEPARATOR); } sourcePathBuilder.append(sourcePath); } addOption(rootElement, CompilerOptionInfo.SOURCE_PATH_INFO, sourcePathBuilder.toString()); }