Permalink
Browse files

Migrate a batch of changes to subversion to help set MOE up for closu…

…re-templates. The original changes were:

 * Improve ant targets to generate release binaries.
 * Fix AssistedInject deprecation warnings
 * Passes an empty object instance into template when calling renderElement without data.
 * Add utility method to render a template as a single element.

Revision created by MOE tool push_codebase.
MOE_MIGRATION=


git-svn-id: http://closure-templates.googlecode.com/svn/trunk@18 ba6e359a-b4f9-11de-880b-11b4e8d67c75
  • Loading branch information...
nsanch
nsanch committed Jul 21, 2010
1 parent df78f85 commit f718ec9561820cd3534d871ed21bd99df09a309d
Showing 501 changed files with 1,488 additions and 1,013 deletions.
View
198 build.xml
@@ -16,6 +16,7 @@ limitations under the License.
<!--
Author: Kai Huang
Author: Robert Bowdidge
Author: Neil Sanchala
-->
<project name="Soy" basedir="." default="jar">
@@ -31,6 +32,10 @@ Author: Robert Bowdidge
<property name="javadoc.lite.dir" value="${basedir}/javadoc-lite" />
<property name="javadoc.complete.dir" value="${basedir}/javadoc-complete" />
<!-- To release a new stable version of soy, update release.stamp to 'latest' or pass
-Drelease.stamp=latest when running ant. -->
<property name="release.dir" value="${basedir}/release" />
<property name="release.stamp" value="unstable" />
<!-- Target to delete the generated files. -->
<target name="clean"
@@ -269,6 +274,21 @@ Author: Robert Bowdidge
<property name="build.examples.dir" value="${build.dir}/examples" />
<!-- Utility macro. Fails if the specified file is not available. -->
<macrodef name="AssertFileExists">
<attribute name="filename" description="Filename to look for." />
<sequential>
<fail>
<condition>
<not>
<available file="@{filename}" />
</not>
</condition>
</fail>
</sequential>
</macrodef>
<!--
Uses SoyToJsSrcCompiler to compile simple.soy.
In 'build/examples', generates the following file:
@@ -285,6 +305,8 @@ Author: Robert Bowdidge
<arg value="${build.examples.dir}/{INPUT_FILE_NAME_NO_EXT}_generated.js" />
<arg value="${examples.dir}/simple.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/simple_generated.js" />
</target>
@@ -316,6 +338,11 @@ Author: Robert Bowdidge
<arg value="simple.soy" />
<arg value="features.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/simple_generated_en.js" />
<AssertFileExists filename="${build.examples.dir}/features_generated_en.js" />
<AssertFileExists filename="${build.examples.dir}/simple_generated_x-zz.js" />
<AssertFileExists filename="${build.examples.dir}/features_generated_x-zz.js" />
</target>
@@ -338,6 +365,8 @@ Author: Robert Bowdidge
<!-- Resources. -->
<fileset file="${examples.dir}/simple.soy" />
</jar>
<AssertFileExists filename="${build.examples.dir}/SimpleUsage.jar" />
</target>
@@ -361,6 +390,8 @@ Author: Robert Bowdidge
<arg value="filename" />
<arg value="${examples.dir}/features.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/FeaturesSoyInfo.java" />
</target>
@@ -388,9 +419,18 @@ Author: Robert Bowdidge
<fileset file="${examples.dir}/examples_translated_x-zz.xlf" />
<fileset file="${java.examples.dir}/FeaturesUsage_globals.txt" />
</jar>
<AssertFileExists filename="${build.examples.dir}/FeaturesUsage.jar" />
</target>
<!--
********************************************************************************************
Below are targets to generate release zip files, and to test that the generated binaries are
sane.
-->
<!--
Uses SoyMsgExtractor to extract messages from simple.soy and features.soy.
In 'build/examples', generates the following file:
@@ -410,7 +450,165 @@ Author: Robert Bowdidge
<arg value="simple.soy" />
<arg value="features.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/examples_extracted.xlf" />
</target>
<!--
Runs the specified jar with no arguments, and asserts that the specified usage message was
printed.
-->
<macrodef name="RunBuiltJarAndLookForExpectedError">
<attribute name="jar" description="The jar to run and test"/>
<attribute name="expectederror" description="The error message to expect"/>
<sequential>
<!-- Run the jar and dump its output to ${@{jar}_output}. -->
<java jar="${build.dir}/@{jar}.jar"
fork="true"
failonerror="false"
errorproperty="@{jar}_output">
</java>
<!-- Look in the output for the error message we expect to see. -->
<fail message="The output of the specified jar does not include the expected error message.
${line.separator}Expected Error Substring : @{expectederror}
${line.separator}Actual Output : ${@{jar}_output}">
<condition>
<not>
<contains string="${@{jar}_output}" substring="@{expectederror}" />
</not>
</condition>
</fail>
</sequential>
</macrodef>
<target name="test-built-jars" depends="SoyToJsSrcCompiler,
SoyParseInfoGenerator,
SoyMsgExtractor">
<RunBuiltJarAndLookForExpectedError
jar="SoyToJsSrcCompiler"
expectederror="Error: Option &quot;--outputPathFormat&quot; is required" />
<RunBuiltJarAndLookForExpectedError
jar="SoyParseInfoGenerator"
expectederror="Error: Option &quot;--javaClassNameSource&quot; is required" />
<RunBuiltJarAndLookForExpectedError
jar="SoyMsgExtractor"
expectederror="Error: Option &quot;--outputFile&quot; is required" />
</target>
<!-- Runs a full build, the examples, and test-built-jars to ensure that the build is sane. -->
<target name="verification-tests"
depends="compile,
jar,
jar-excluding-deps,
SoyToJsSrcCompiler,
SoyParseInfoGenerator,
SoyMsgExtractor,
test-built-jars,
js-simple-example,
js-features-example,
java-simple-example,
parse-info-generation-example,
java-features-example,
msg-extraction-example" />
<!--
Builds a set of zip files containing releaseable bundles of code. These zip files may be uploaded
to the project's Downloads area at Google Code.
-->
<target name="zips-for-release" depends="jar,
jar-excluding-deps,
javadoc-lite,
SoyMsgExtractor,
SoyParseInfoGenerator,
SoyToJsSrcCompiler">
<mkdir dir="${release.dir}" />
<!--
Rename our three README files to README in appropriately-named directories so they can be
pulled in as just "README" in the zip files below.
-->
<copy file="for-java_jar_README.txt" tofile="${build.dir}/java/README" />
<copy file="for-javascript_jar_README.txt" tofile="${build.dir}/javascript/README" />
<copy file="msg-extractor_jar_README.txt" tofile="${build.dir}/msg_extractor/README" />
<!--
Zip file 1: Create a "msg-extractor" zip files.
Mapping:
COPYING ==> ./COPYING
README.msg_extractor ==> ./README
build/SoyMsgExtractor.jar ==> ./SoyMsgExtractor.jar
-->
<zip destfile="${release.dir}/closure-templates-msg-extractor-${release.stamp}.zip">
<fileset file="COPYING" />
<fileset file="${build.dir}/msg_extractor/README" />
<fileset file="${build.dir}/SoyMsgExtractor.jar" />
</zip>
<!-- Rename soy.jar and soy-excluding-deps.jar to to include a ${release.stamp} suffix. -->
<copy file="${build.dir}/soy-excluding-deps.jar"
tofile="${build.dir}/soy-excluding-deps-${release.stamp}.jar" />
<copy file="${build.dir}/soy.jar"
tofile="${build.dir}/soy-${release.stamp}.jar" />
<!--
Zip file 2.1: Make soy-src-${release.stamp}.zip containing all soy src. Note that this gets
stored in the build directory, not the release directory, because this is only released as part
of the for-java zip.
Mapping:
java/src/** ==> ./**
-->
<zip destfile="${build.dir}/soy-src-${release.stamp}.zip"
basedir="java/src" />
<!--
Zip file 2.2: Create "for-java" zip file.
Mapping:
COPYING ==> ./COPYING
README.java ==> ./README
build/soy.jar ==> ./soy-${release.stamp}.jar
build/SoyParseInfoGenerator.jar ==> ./SoyParseInfoGenerator.jar
java/lib/** ==> ./separate-jars/lib/**
javadoc-lite/** ==> ./separate-jars/javadoc/**
build/soy-excluding-deps.jar ==> ./separate-jars/soy-excluding-deps-${release.stamp}.jar
build/soy-src-${release.stamp}.zip ==> ./separate-jars/soy-src-${release.stamp}.zip
-->
<zip destfile="${release.dir}/closure-templates-for-java-${release.stamp}.zip">
<fileset file="COPYING" />
<fileset file="${build.dir}/java/README" />
<fileset file="${build.dir}/SoyParseInfoGenerator.jar" />
<fileset file="${build.dir}/soy-${release.stamp}.jar" />
<zipfileset dir="${build.dir}"
includes="soy-src-${release.stamp}.zip"
prefix="separate-jars" />
<zipfileset dir="${build.dir}"
includes="soy-excluding-deps-${release.stamp}.jar"
prefix="separate-jars" />
<zipfileset dir="java/lib" prefix="separate-jars/lib" />
<zipfileset dir="javadoc-lite" prefix="separate-jars/javadoc" />
</zip>
<!--
Zip file 3: Create "for-javascript" zip file.
Mapping:
COPYING ==> ./COPYING
README.javascript ==> ./README
build/SoyToJsSrcCompiler.jar ==> ./SoyToJsSrcCompiler.jar
javascript/*.js ==> ./*.js
-->
<zip destfile="${release.dir}/closure-templates-for-javascript-${release.stamp}.zip">
<fileset file="COPYING" />
<fileset file="${build.dir}/javascript/README" />
<fileset file="${build.dir}/SoyParseInfoGenerator.jar" />
<fileset dir="javascript" includes="soyutils.js,soyutils_usegoog.js" />
</zip>
</target>
</project>
View
@@ -0,0 +1,54 @@
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Contents:
+ soy.jar
Jar containing all classes and dependencies. Usually downloaded for Java
usage. However, note that the programmatic API supports all functionality.
Besides Java usage, the programmatic API can also be used for compiling Soy
files to JS, message extraction, etc.
+ SoyParseInfoGenerator.jar
Executable jar that generates Java files containing info/constants parsed
from template files.
+ separate-jars
Directory containing separate jars for Closure Templates classes and for
dependencies. If your project depends on some of the same libraries that
Closure Templates depend on, e.g. Guava or Guice, then then you may need to
mix-and-match separate jars for Java usage of Closure Templates (as opposed
to using the standalone soy.jar). The Closure Templates classes are
packaged into soy-excluding-deps.jar, while the dependencies are in the
subdirectory 'lib'. All dependencies are open source. Also included are
javadoc (lite version) and a zip file of the sources.
Instructions:
+ A simple Hello World for Java:
http://code.google.com/closure/templates/docs/helloworld_java.html
+ Complete documentation:
http://code.google.com/closure/templates/
+ Closure Templates project on Google Code:
http://code.google.com/p/closure-templates/
Notes:
+ Closure Templates requires Java 6 or higher:
http://www.java.com/
@@ -0,0 +1,47 @@
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Contents:
+ SoyToJsSrcCompiler.jar
Executable jar that compiles template files into JavaScript files.
+ soyutils.js
Helper utilities required by all JavaScript code that SoyToJsSrcCompiler
generates. Equivalent functionality to soyutils_usegoog.js, but this
version does not need Closure Library.
+ soyutils_usegoog.js
Helper utilities required by all JavaScript code that SoyToJsSrcCompiler
generates. Equivalent functionality to soyutils.js, but this version
assumes Closure Library is present.
Instructions:
+ A simple Hello World for JavaScript:
http://code.google.com/closure/templates/docs/helloworld_js.html
+ Complete documentation:
http://code.google.com/closure/templates/
+ Closure Templates project on Google Code:
http://code.google.com/p/closure-templates/
Notes:
+ Closure Templates requires Java 6 or higher:
http://www.java.com/
@@ -17,7 +17,7 @@
package com.google.template.soy;
import com.google.inject.AbstractModule;
import com.google.inject.assistedinject.FactoryProvider;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.google.template.soy.SoyFileSet.SoyFileSetFactory;
import com.google.template.soy.basicdirectives.BasicDirectivesModule;
import com.google.template.soy.basicfunctions.BasicFunctionsModule;
@@ -52,8 +52,7 @@
install(new BidiFunctionsModule());
// Bind providers of factories (created via assisted inject).
bind(SoyFileSetFactory.class)
.toProvider(FactoryProvider.newFactory(SoyFileSetFactory.class, SoyFileSet.class));
install(new FactoryModuleBuilder().build(SoyFileSetFactory.class));
// The static injection of SoyFileSetFactory into SoyFileSet.Builder is what allows the Soy
// compiler to use Guice even if the user of the Soy API does not use Guice.
No changes.
Oops, something went wrong.

0 comments on commit f718ec9

Please sign in to comment.