diff options
author | Henri Sara <hesara@vaadin.com> | 2012-07-02 11:40:38 +0300 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2012-07-02 11:40:38 +0300 |
commit | 7906b675fe8ece493229a54605d60a70d91737ab (patch) | |
tree | 944312cc454e52186592ceae08900635c2606b52 /build | |
parent | d948c23bf48ec0cfb4f090f27de468bf59ee71db (diff) | |
parent | 63de3863057995f529444e6251d2b6d955f5bd46 (diff) | |
download | vaadin-framework-7906b675fe8ece493229a54605d60a70d91737ab.tar.gz vaadin-framework-7906b675fe8ece493229a54605d60a70d91737ab.zip |
Merge branch 'gwt'
Diffstat (limited to 'build')
-rw-r--r-- | build/GWT-VERSION.properties | 2 | ||||
-rw-r--r-- | build/build.xml | 184 | ||||
-rw-r--r-- | build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java | 68 | ||||
-rw-r--r-- | build/ivy/ivy.xml | 5 |
4 files changed, 215 insertions, 44 deletions
diff --git a/build/GWT-VERSION.properties b/build/GWT-VERSION.properties index 028ad8b4de..e5bb635e01 100644 --- a/build/GWT-VERSION.properties +++ b/build/GWT-VERSION.properties @@ -1,2 +1,2 @@ -gwt-version=2.4.0 +gwt-version=2.5.0 gwt-version-dependencies=validation-api-1.0.0.GA.jar, validation-api-1.0.0.GA-sources.jar diff --git a/build/build.xml b/build/build.xml index 9b79683bcf..6b3a046616 100644 --- a/build/build.xml +++ b/build/build.xml @@ -34,16 +34,61 @@ <path id="additional.jar.path"> <fileset dir="build" includes="lib/**/*.jar" ></fileset> </path> + + <property name="gwt.build.dir" value="${gwt.root}/build"/> + <property name="gwt.tools" value="${gwt.root}/../tools"/> + <property name="gwt.tools.lib" value="${gwt.tools}/lib"/> + + <property name="gwt.user.jar" value="${gwt.build.dir}/lib/gwt-user.jar"/> + <property name="gwt.dev.jar" value="${gwt.build.dir}/lib/gwt-dev.jar"/> + <property name="gwt.codeserver.jar" value="${gwt.build.dir}/lib/gwt-codeserver.jar"/> + <property name="gwt.elemental.jar" value="${gwt.build.dir}/lib/gwt-elemental.jar"/> + + <property name="gwt.user.dir" value="${gwt.root}/user"/> + <property name="gwt.user.bin" value="${gwt.build.dir}/out/user/bin"/> + + <property name="jarjar-jar" value="${gwt.tools.lib}/tonicsystems/jarjar-1.0rc8.jar"/> + <path id="compile.classpath.server-side"> <path refid="additional.jar.path" /> + + <!-- GWT --> + <pathelement location="${gwt.user.jar}" /> + <pathelement location="${gwt.dev.jar}" /> + + <!-- GWT dependencies --> + <pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" /> + <pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3-gg2.jar" /> + <path refid="ivy.compile.classpath.server-side" /> </path> <path id="compile.classpath.client-side"> - <path refid="additional.jar.path" /> - <path refid="ivy.compile.classpath.client-side" /> + <path refid="additional.jar.path" /> + + <!-- GWT user --> + <!-- + <pathelement path="${gwt.user.dir}/src" /> + <pathelement path="${gwt.user.dir}/super" /> + <pathelement path="${gwt.user.dir}/out/user/bin"/> + --> + <!-- GWT --> + <pathelement location="${gwt.user.jar}" /> + <pathelement location="${gwt.dev.jar}" /> + + <!-- GWT dependencies --> + <pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" /> + <pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3-gg2.jar" /> + + <path refid="ivy.compile.classpath.client-side" /> </path> <path id="compile.classpath.server-side-tests"> <path refid="additional.jar.path" /> + + <!-- GWT --> + <pathelement location="${gwt.user.jar}" /> + <!-- needed at least for Apache Commons --> + <pathelement location="${gwt.dev.jar}" /> + <path refid="ivy.compile.classpath.server-side-tests" /> </path> </target> @@ -68,6 +113,7 @@ <property name="result-classes-core" value="${result-path}/classes/core"/> <property name="result-classes-junit" value="${result-path}/classes/junit"/> <property name="result-classes-testbench" value="${result-path}/classes/testbench"/> + <property name="result-precompiled-widgetsets" value="${result-path}/classes/widgetsets"/> <!-- Folder where Emma instrumented classes are placed (if Emma is used)--> <property name="result-classes-core-for-emma-war" value="${result-path}/classes/emma-war"/> <property name="result-classes-core-for-emma-junit" value="${result-path}/classes/emma-junit"/> @@ -77,6 +123,7 @@ <path refid="compile.classpath.client-side" /> <pathelement location="${result-classes-core}" /> <pathelement location="${result-src-core}" /> + <pathelement location="${result-precompiled-widgetsets}" /> </path> </target> <target name="clean-all" depends="clean-result"> @@ -265,7 +312,7 @@ description="Build package required files, without packing them."> </target> - <target name="compile-server-side" depends="compile-core, webcontent"/> + <target name="compile-server-side" depends="compile-gwt, compile-core, webcontent"/> <!-- Copy and preprocess sources for packaging NOTE: Replaces <version></version> tags with build version tag for some "textual" files @@ -516,6 +563,22 @@ <property name="widgetset-extraParams" value="" /> <echo>Compiling widgetset ${widgetset}. Output directory: ${widgetsets-output-dir}</echo> <mkdir dir="${widgetsets-output-dir}"/> + + <!-- Disabled to reduce JAR size: precompile the widgetset to a .gwtar file --> + <!-- + <java classname="com.google.gwt.dev.CompileModule" classpathref="compile.classpath.widgetset" failonerror="yes" fork="yes" maxmemory="512m"> + <arg value="-out" /> + <arg value="${result-precompiled-widgetsets}" /> + <arg value="-strict" /> + <arg value="${widgetset}" /> + + <jvmarg value="-Xss8M"/> + <jvmarg value="-XX:MaxPermSize=256M"/> + <jvmarg value="-Djava.awt.headless=true"/> + </java> + --> + + <!-- compile the widgetset --> <java classname="com.google.gwt.dev.Compiler" classpathref="compile.classpath.widgetset" failonerror="yes" fork="yes" maxmemory="512m"> <arg value="-war" /> <arg value="${widgetsets-output-dir}" /> @@ -524,13 +587,14 @@ <arg value="-strict" /> <arg value="-localWorkers" /> <arg value="${widgetset-localWorkers}" /> - <arg line="${widgetset-extraParams}" /> + <arg line="${widgetset-extraParams}" /> <arg value="${widgetset}" /> <jvmarg value="-Xss8M"/> <jvmarg value="-XX:MaxPermSize=256M"/> <jvmarg value="-Djava.awt.headless=true"/> </java> + <antcall target="remove-widgetset-gwt-tmp"/> <echo>Compiled ${widgetset}</echo> @@ -566,7 +630,7 @@ <!-- Compiles all widgetsets. --> <!-- This is called when building packages and when compiling all --> <!-- widgetsets, but not when compiling individual widgetsets. --> - <target name="compile-client-side" depends="compile-server-side, compile-tests"> + <target name="compile-client-side" depends="compile-gwt, compile-server-side, compile-tests"> <echo>Compiling widget sets in parallel.</echo> <parallel threadsperprocessor="1"> <antcall inheritrefs="true" target="compile-widgetset-default"/> @@ -596,6 +660,22 @@ <!-- Libraries and Tests --> <!-- ================================================================== --> + <target name="compile-gwt" depends="init"> + <!-- Compile GWT in a directory defined by properties --> + <ant antfile="${gwt.root}/build.xml" target="user" dir="${gwt.root}" inheritall="false" inheritrefs="false"> + <property name="gwt.root" value="${gwt.root}"/> + </ant> + <ant antfile="${gwt.root}/build.xml" target="dev" dir="${gwt.root}" inheritall="false" inheritrefs="false"> + <property name="gwt.root" value="${gwt.root}"/> + </ant> + <ant antfile="${gwt.root}/build.xml" target="codeserver" dir="${gwt.root}" inheritall="false" inheritrefs="false"> + <property name="gwt.root" value="${gwt.root}"/> + </ant> + <ant antfile="${gwt.root}/build.xml" target="elemental" dir="${gwt.root}" inheritall="false" inheritrefs="false"> + <property name="gwt.root" value="${gwt.root}"/> + </ant> + </target> + <!-- Compile the Vaadin library JAR. --> <!-- Need only the default widgetset for this, but can't depend --> <!-- specifically on it, because dependence does not see compiled --> @@ -606,7 +686,6 @@ <!-- Create Vaadin JAR --> <mkdir dir="${output-dir}/META-INF"/> <echo file="${output-dir}/META-INF/VERSION">${version.full}</echo> - <echo file="${output-dir}/META-INF/GWT-VERSION">${gwt-version}</echo> <emma enabled="${emma.enabled}" > <instr instrpath="${result-classes-core}" @@ -618,10 +697,13 @@ <filter includes="com.vaadin.*" /> <filter excludes="com.vaadin.terminal.gwt.*" /> </instr> - </emma> + </emma> - <jar jarfile="${output-dir}/WebContent/WEB-INF/lib/${lib-jar-name}" - compress="true" manifest="build/package/META-INF/MANIFEST.MF" duplicate="preserve"> + <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" + classpath="${jarjar-jar}"/> + + <jarjar jarfile="${output-dir}/WebContent/WEB-INF/lib/${lib-jar-name}" + compress="true" manifest="build/package/META-INF/MANIFEST.MF" duplicate="preserve" index="true"> <metainf dir="${output-dir}/META-INF"/> <manifest> <attribute name="Vaadin-Package-Version" value="1" /> @@ -629,7 +711,8 @@ <attribute name="Implementation-Vendor" value="Vaadin Ltd" /> <attribute name="Implementation-URL" value="http://vaadin.com" /> <attribute name="Implementation-Version" value="${version.full}" /> - <attribute name="GWT-Version" value="${gwt-version}" /> + <!-- No separate GWT-Version attribute or file --> + <!-- <attribute name="GWT-Version" value="${gwt-version}" /> --> <attribute name="GWT-Version-Dependencies" value="${gwt-version-dependencies}" /> <attribute name="Bundle-Version" value="${version.full}" /> </manifest> @@ -654,7 +737,86 @@ <include name="img/**" /> </patternset> </fileset> - </jar> + + <!-- Precompiled widgetset (.gwtar file) not included to limit JAR size --> + <!-- <fileset dir="${result-precompiled-widgetsets}" includes="com/vaadin/terminal.gwt.DefaultWidgetSet.gwtar" /> --> + + <!-- TODO GWT related license files etc. should be in subdirectories --> + + <!-- GWT --> + <fileset dir="${gwt.user.dir}/src" excludes="**/package.html" /> + <fileset dir="${gwt.user.dir}/super" excludes="**/package.html" /> + <!-- Precompiled GWT modules (.gwtar file) not included to limit JAR size --> + <fileset dir="${gwt.user.bin}" excludes="**/*.gwtar" /> + + <zipfileset src="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" /> + <zipfileset src="${gwt.tools.lib}/w3c/flute/flute-1.3-gg2.jar" /> + <zipfileset src="${gwt.tools.lib}/streamhtmlparser/streamhtmlparser-jsilver-r10/streamhtmlparser-jsilver-r10-1.5-rebased.jar" /> + + <!-- GWT development JAR contents including many external dependencies --> + <zipfileset src="${gwt.dev.jar}" excludes="javax/servlet/**,javax/xml/**" /> + + <!-- Alternative approach: GWT compiler and its dependencies only from the dev JAR --> + <!-- + <zipfileset src="${gwt.dev.jar}"> + <include name="com/google/gwt/core/client/**"/> + <include name="com/google/gwt/core/shared/**"/> + + <include name="com/google/gwt/core/ext/**"/> + <include name="com/google/gwt/core/linker/**"/> + <include name="com/google/gwt/dev/About.java"/> + <include name="com/google/gwt/dev/GwtVersion.java"/> + <include name="com/google/gwt/dev/Permutation.java"/> + <include name="com/google/gwt/dev/asm/**"/> + <include name="com/google/gwt/dev/cfg/**"/> + <include name="com/google/gwt/dev/javac/**"/> + <include name="com/google/gwt/dev/jdt/**"/> + <include name="com/google/gwt/dev/jjs/**"/> + <include name="com/google/gwt/dev/js/**"/> + <include name="com/google/gwt/dev/json/**"/> + <include name="com/google/gwt/dev/resource/**"/> + <include name="com/google/gwt/dev/util/**"/> + <include name="com/google/gwt/soyc/**"/> + <include name="com/google/gwt/util/**"/> + <include name="org/eclipse/jdt/**"/> + </zipfileset> + <zipfileset src="${gwt.tools.lib}/apache/ant-1.6.5.jar" /> + <zipfileset src="${gwt.tools.lib}/eclipse/jdt-3.4.2_r894.jar" /> + <zipfileset src="${gwt.tools.lib}/tomcat/commons-collections-3.1.jar" /> + <zipfileset src="${gwt.tools.lib}/guava/guava-10.0.1/guava-10.0.1-rebased.jar" /> + <zipfileset src="${gwt.tools.lib}/jscomp/r1649/compiler-rebased.jar" /> + --> + + <!-- GWT SuperDevMode --> + <zipfileset src="${gwt.codeserver.jar}" /> + + <!-- GWT Elemental --> + <zipfileset src="${gwt.elemental.jar}" /> + + <!-- jarjar rules: rebase packages from gwt-dev.jar but not those from gwt-user --> + + <!-- Don't rebase these --> + <!-- xalan is used via reflection --> + <rule pattern="org.apache.xalan.**" result="@0"/> + <rule pattern="org.apache.xml.**" result="@0"/> + <!-- Cannot rebase - used in APIs etc. --> + <!-- <rule pattern="org.mortbay.**" result="@0"/> --> + <!-- <rule pattern="org.xml.**" result="@0"/> --> + + <!-- Rebase these --> + <rule pattern="com.gargoylesoftware.**" result="com.vaadin.external.@0"/> + <rule pattern="com.ibm.**" result="com.vaadin.external.@0"/> + <rule pattern="com.steadystate.**" result="com.vaadin.external.@0"/> + <rule pattern="mx4j.**" result="com.vaadin.external.@0"/> + <rule pattern="net.sourceforge.htmlunit.**" result="com.vaadin.external.@0"/> + <rule pattern="org.apache.**" result="com.vaadin.external.@0"/> + <rule pattern="org.cyberneko.**" result="com.vaadin.external.@0"/> + <rule pattern="org.eclipse.**" result="com.vaadin.external.@0"/> + <!-- looked up based on class name? --> + <rule pattern="org.hibernate.validator.**" result="com.vaadin.external.@0"/> + <rule pattern="org.jdesktop.swingworker.**" result="com.vaadin.external.@0"/> + <rule pattern="org.kohsuke.args4j.**" result="com.vaadin.external.@0"/> + </jarjar> <!-- Generate the Export-Package attribute in the manifest of the JAR --> <java classname="com.vaadin.buildhelpers.GeneratePackageExports" failonerror="true" fork="yes"> diff --git a/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java b/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java index 6f477601ed..0deebdc9a1 100644 --- a/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java +++ b/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java @@ -7,37 +7,40 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Vector; import java.util.jar.Attributes; +import java.util.jar.Attributes.Name; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; -import java.util.jar.Attributes.Name; /** * Generates Export-Packages attribute for OSGi compatible manifest. * * Reads the included Java packages in Vaadin JAR, generates a corresponding - * MANIFEST.MF file, and replaces the dummy one in the JAR with the - * generated one. + * MANIFEST.MF file, and replaces the dummy one in the JAR with the generated + * one. * * See #3521 for details. * * @author magi */ public class GeneratePackageExports { + public static final String VAADIN_PACKAGE_PATH_PREFIX = "com/vaadin/"; + public static final String GOOGLE_PACKAGE_PATH_PREFIX = "com/google/"; + public static void main(String[] args) { if (args.length < 1) { - System.err.println("Invalid number of parameters\n"+ - "Usage: java -cp .. GenerateManifest <package.jar>"); + System.err.println("Invalid number of parameters\n" + + "Usage: java -cp .. GenerateManifest <package.jar>"); System.exit(1); } - // Open tje JAR + // Open the JAR String jarFilename = args[0]; JarFile jar = null; try { jar = new JarFile(jarFilename); } catch (IOException e) { - System.err.println("Unable to open JAR '"+jarFilename+"'"); + System.err.println("Unable to open JAR '" + jarFilename + "'"); System.exit(1); } @@ -45,9 +48,12 @@ public class GeneratePackageExports { HashSet<String> packages = new HashSet<String>(); for (Enumeration<JarEntry> it = jar.entries(); it.hasMoreElements();) { JarEntry entry = it.nextElement(); - if (entry.getName().startsWith("com") && entry.getName().endsWith(".class")) { + if ((entry.getName().startsWith(VAADIN_PACKAGE_PATH_PREFIX) || entry + .getName().startsWith(GOOGLE_PACKAGE_PATH_PREFIX)) + && entry.getName().endsWith(".class")) { int lastSlash = entry.getName().lastIndexOf('/'); - String pkg = entry.getName().substring(0, lastSlash).replace('/', '.'); + String pkg = entry.getName().substring(0, lastSlash) + .replace('/', '.'); packages.add(pkg); } } @@ -55,14 +61,16 @@ public class GeneratePackageExports { // List theme packages for (Enumeration<JarEntry> it = jar.entries(); it.hasMoreElements();) { JarEntry entry = it.nextElement(); - if (entry.isDirectory() && entry.getName().startsWith("VAADIN/themes")) { + if (entry.isDirectory() + && entry.getName().startsWith("VAADIN/themes")) { // Strip ending slash int lastSlash = entry.getName().lastIndexOf('/'); - String pkg = entry.getName().substring(0, lastSlash).replace('/', '.'); + String pkg = entry.getName().substring(0, lastSlash) + .replace('/', '.'); packages.add(pkg); } } - + // Replacement for the "Export-Package" attribute in the manifest String exportPackage = ""; @@ -70,13 +78,14 @@ public class GeneratePackageExports { String packageArray[] = new String[packages.size()]; packages.toArray(packageArray); Arrays.sort(packageArray); - for (int i=0; i<packageArray.length; i++) { - if (i == 0) + for (int i = 0; i < packageArray.length; i++) { + if (i == 0) { exportPackage = packageArray[i]; - else + } else { exportPackage += ", " + packageArray[i]; + } } - + // Read old manifest Manifest oldMF = null; try { @@ -84,11 +93,12 @@ public class GeneratePackageExports { } catch (IOException e) { e.printStackTrace(); } - + // Read main attributes Attributes mainAtts = oldMF.getMainAttributes(); Vector<String> keys = new Vector<String>(mainAtts.size()); - for (Iterator<Object> attrit = mainAtts.keySet().iterator(); attrit.hasNext();) { + for (Iterator<Object> attrit = mainAtts.keySet().iterator(); attrit + .hasNext();) { Name name = (Name) attrit.next(); keys.add(name.toString()); } @@ -98,11 +108,11 @@ public class GeneratePackageExports { try { jar.close(); } catch (IOException e) { - System.err.println("Unable to close JAR '"+jarFilename+"'"); + System.err.println("Unable to close JAR '" + jarFilename + "'"); } - + // Put the manifest version as the first line - String orderedKeys[] = new String[keys.size()]; + String orderedKeys[] = new String[keys.size()]; keys.toArray(orderedKeys); Arrays.sort(orderedKeys); // Must sort to be able to search int mvPos = Arrays.binarySearch(orderedKeys, "Manifest-Version"); @@ -110,20 +120,21 @@ public class GeneratePackageExports { orderedKeys[0] = "Manifest-Version"; // This final ordering is just for esthetic reasons and - // in practice unnecessary and will actually be messed up + // in practice unnecessary and will actually be messed up // when the 'jar' command reads the manifest - Arrays.sort(orderedKeys, 1, orderedKeys.length-1); + Arrays.sort(orderedKeys, 1, orderedKeys.length - 1); // Create the modified manifest ManifestWriter manifest = new ManifestWriter(); - for (int i=0; i<orderedKeys.length; i++) { + for (int i = 0; i < orderedKeys.length; i++) { // Skip an existing Export-Package attribute if (orderedKeys[i].equals("Export-Package")) { // Copy the attribute to the modified manifest - manifest.writeAttribute(orderedKeys[i], mainAtts.getValue(orderedKeys[i])); + manifest.writeAttribute(orderedKeys[i], + mainAtts.getValue(orderedKeys[i])); } } - + // Add the Export-Package attribute at the end of the manifest. // The alternative would be replacing an existing attribute in // the loop above, but it's not guaranteed that it exists. @@ -133,8 +144,9 @@ public class GeneratePackageExports { // before this is done. int status = manifest.updateJar(jarFilename); - if (status != 0) + if (status != 0) { System.exit(status); + } } - + } diff --git a/build/ivy/ivy.xml b/build/ivy/ivy.xml index ffcf7b19c8..6b569d1248 100644 --- a/build/ivy/ivy.xml +++ b/build/ivy/ivy.xml @@ -19,11 +19,8 @@ <!-- Google App Engine --> <dependency org="com.google.appengine" name="appengine-api-1.0-sdk" rev="1.2.1" /> - <!-- GWT user with dependencies (validation-api) --> - <dependency org="com.google.gwt" name="gwt-user" rev="2.4.0" conf="cs.compile->master" /> + <!-- GWT dependencies (validation-api) --> <dependency org="javax.validation" name="validation-api" rev="1.0.0.GA" conf="cs.compile->master,sources" /> - <!-- GWT dev (incl. servlet-api 2.4 classes) --> - <dependency org="com.google.gwt" name="gwt-dev" rev="2.4.0" conf="cs.compile->master" /> <!-- Test frameworks & related --> <dependency org="junit" name="junit" rev="4.5" conf="ss.test.compile -> master"/> |