@Override void compile(SoyFileSet.Builder sfsBuilder) throws IOException { sfsBuilder.setAllowExternalCalls(allowExternalCalls); SoyFileSet sfs = sfsBuilder.build(); ImmutableMap<String, String> parseInfo = sfs.generateParseInfo(javaPackage, javaClassNameSource); if (outputSrcJar == null) { for (Map.Entry<String, String> entry : parseInfo.entrySet()) { File outputFile = new File(outputDirectory, entry.getKey()); BaseUtils.ensureDirsExistInPath(outputFile.getPath()); Files.asCharSink(outputFile, UTF_8).write(entry.getValue()); } } else { String resourcePath = javaPackage.replace('.', '/') + "/"; try (SoyJarFileWriter writer = new SoyJarFileWriter(new FileOutputStream(outputSrcJar))) { for (Map.Entry<String, String> entry : parseInfo.entrySet()) { writer.writeEntry( resourcePath + entry.getKey(), CharSource.wrap(entry.getValue()).asByteSource(UTF_8)); } } } } }
MainClassUtils.addSoyFilesToBuilder( sfsBuilder, inputPrefix, srcs, arguments, ImmutableList.<String>of(), exitWithErrorFn); sfsBuilder.setAllowExternalCalls(allowExternalCalls);
@Override void compile(SoyFileSet.Builder sfsBuilder) throws IOException { sfsBuilder.setAllowExternalCalls(allowExternalCalls); SoyFileSet sfs = sfsBuilder.build(); ImmutableMap<String, String> parseInfo = sfs.generateParseInfo(javaPackage, javaClassNameSource); if (outputSrcJar == null) { for (Map.Entry<String, String> entry : parseInfo.entrySet()) { File outputFile = new File(outputDirectory, entry.getKey()); BaseUtils.ensureDirsExistInPath(outputFile.getPath()); Files.asCharSink(outputFile, UTF_8).write(entry.getValue()); } } else { String resourcePath = javaPackage.replace('.', '/') + "/"; try (SoyJarFileWriter writer = new SoyJarFileWriter(new FileOutputStream(outputSrcJar))) { for (Map.Entry<String, String> entry : parseInfo.entrySet()) { writer.writeEntry( resourcePath + entry.getKey(), CharSource.wrap(entry.getValue()).asByteSource(UTF_8)); } } } } }
MainClassUtils.addSoyFilesToBuilder(sfsBuilder, inputPrefix, srcs, arguments, deps, exitWithErrorFn); sfsBuilder.setAllowExternalCalls(allowExternalCalls); String cssHandlingSchemeUc = cssHandlingScheme.toUpperCase(); sfsBuilder.setCssHandlingScheme(
sfsBuilder, inputPrefix, ImmutableSet.copyOf(srcs), ImmutableSet.copyOf(arguments), ImmutableSet.copyOf(deps), exitWithErrorFn); sfsBuilder.setAllowExternalCalls(allowExternalCalls); SoyFileSet sfs = sfsBuilder.build();
MainClassUtils.addSoyFilesToBuilder(sfsBuilder, inputPrefix, srcs, arguments, deps, exitWithErrorFn); sfsBuilder.setAllowExternalCalls(allowExternalCalls); sfsBuilder.setCssHandlingScheme(CssHandlingScheme.valueOf(cssHandlingScheme.toUpperCase())); if (compileTimeGlobalsFile.length() > 0) {
sfsBuilder.setDeclaredSyntaxVersionName(syntaxVersion); sfsBuilder.setAllowExternalCalls(allowExternalCalls);
sfsBuilder.setAllowExternalCalls(false);
@Override void compile(SoyFileSet.Builder sfsBuilder) throws IOException { sfsBuilder.setAllowExternalCalls(allowExternalCalls); SoyFileSet sfs = sfsBuilder.build(); // Create SoyJsSrcOptions. SoyJsSrcOptions jsSrcOptions = new SoyJsSrcOptions(); jsSrcOptions.setShouldAllowDeprecatedSyntax(shouldAllowDeprecatedSyntax); jsSrcOptions.setShouldGenerateGoogMsgDefs(shouldGenerateGoogMsgDefs); jsSrcOptions.setGoogMsgsAreExternal(googMsgsAreExternal); jsSrcOptions.setBidiGlobalDir(bidiGlobalDir); jsSrcOptions.setUseGoogIsRtlForBidiGlobalDir(useGoogIsRtlForBidiGlobalDir); // Compile. boolean generateLocalizedJs = !locales.isEmpty(); if (generateLocalizedJs) { sfs.compileToJsSrcFiles( outputPathFormat, jsSrcOptions, locales, messagePlugin, messageFilePathFormat); } else { sfs.compileToJsSrcFiles(outputPathFormat, jsSrcOptions, locales, null, null); } } }
@Override void compile(SoyFileSet.Builder sfsBuilder) throws IOException { // Disallow external call entirely in Python. sfsBuilder.setAllowExternalCalls(false); // Require strict templates in Python. sfsBuilder.setStrictAutoescapingRequired(true); SoyFileSet sfs = sfsBuilder.build(); // Load the manifest if available. ImmutableMap<String, String> manifest = loadNamespaceManifest(namespaceManifestPaths); if (!manifest.isEmpty() && outputNamespaceManifest == null) { exitWithError("Namespace manifests provided without outputting a new manifest."); } // Create SoyPySrcOptions. SoyPySrcOptions pySrcOptions = new SoyPySrcOptions( runtimePath, environmentModulePath, bidiIsRtlFn, translationClass, manifest, outputNamespaceManifest); // Compile. sfs.compileToPySrcFiles(outputPathFormat, pySrcOptions); }
@Override void compile(SoyFileSet.Builder sfsBuilder, Injector injector) throws IOException { sfsBuilder.setAllowExternalCalls(allowExternalCalls); SoyFileSet sfs = sfsBuilder.build(); SoyMsgBundleHandler msgBundleHandler = new SoyMsgBundleHandler(messagePlugin); // Main loop. for (int i = 0; i < inputMsgFiles.size(); i++) { // Get the input msg bundle. File inputMsgFilePath = inputMsgFiles.get(i); SoyMsgBundle origTransMsgBundle = msgBundleHandler.createFromFile(inputMsgFilePath); if (origTransMsgBundle.getLocaleString() == null) { throw new IOException("Error opening or parsing message file " + inputMsgFilePath); } // Do the pruning. SoyMsgBundle prunedTransSoyMsgBundle = sfs.pruneTranslatedMsgs(origTransMsgBundle); // Write out the pruned msg bundle. File outputMsgFilePath = outputMsgFiles.get(i); msgBundleHandler.writeToTranslatedMsgsFile( prunedTransSoyMsgBundle, new OutputFileOptions(), outputMsgFilePath); } } }
private SoyFileSet buildSoyFileSetFrom(final Collection<URL> urls) { final SoyFileSet.Builder builder = new SoyFileSet.Builder(); for (final URL url : urls) { builder.setAllowExternalCalls(true); builder.add(url); } addCompileTimeGlobalModel(builder); return builder.build(); }
@Override void compile(SoyFileSet.Builder sfsBuilder, Injector injector) throws IOException { sfsBuilder.setAllowExternalCalls(allowExternalCalls); SoyFileSet sfs = sfsBuilder.build(); OutputFileOptions options = new OutputFileOptions(); options.setSourceLocaleString(sourceLocaleString); if (targetLocaleString.length() > 0) { options.setTargetLocaleString(targetLocaleString); } sfs.extractAndWriteMsgs( new SoyMsgBundleHandler(messagePlugin), options, Files.asByteSink(outputFile)); } }
@Override void compile(SoyFileSet.Builder sfsBuilder) throws IOException { sfsBuilder.setAllowExternalCalls(allowExternalCalls); SoyFileSet sfs = sfsBuilder.build(); OutputFileOptions options = new OutputFileOptions(); options.setSourceLocaleString(sourceLocaleString); if (targetLocaleString.length() > 0) { options.setTargetLocaleString(targetLocaleString); } sfs.extractAndWriteMsgs( new SoyMsgBundleHandler(messagePlugin), options, Files.asByteSink(outputFile)); } }