From 0a77dae8b57a99cb5112a387b2a374c14e1fae1b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 23 Aug 2012 10:43:24 +0300 Subject: Created separate build.xml files for each module (#9299) --- .gitignore | 4 + build.properties | 8 ++ build.xml | 32 +++++ .../vaadin/buildhelpers/CompileDefaultTheme.java | 121 ---------------- .../buildhelpers/GeneratePackageExports.java | 152 -------------------- .../com/vaadin/buildhelpers/ManifestWriter.java | 130 ----------------- build/package/META-INF/MANIFEST.MF | 2 +- buildhelpers/build.xml | 27 ++++ buildhelpers/ivy.xml | 18 +++ .../buildhelpers/GeneratePackageExports.java | 152 ++++++++++++++++++++ .../com/vaadin/buildhelpers/ManifestWriter.java | 130 +++++++++++++++++ client-compiler/build.xml | 32 +++++ client-compiler/ivy.xml | 25 ++++ client/build.xml | 32 +++++ client/ivy.xml | 28 ++++ common.xml | 156 +++++++++++++++++++++ gwt-files.xml | 119 ++++++++++++++++ ivysettings.xml | 49 +++++++ pom-template.xml | 62 ++++++++ server/build.xml | 29 ++++ server/ivy.xml | 55 ++++++++ shared/build.xml | 31 ++++ shared/ivy.xml | 22 +++ theme-compiler/build.xml | 29 ++++ theme-compiler/ivy.xml | 30 ++++ .../ivymodule/smartsprites-ivy-0.2.3-itmill.xml | 38 +++++ .../vaadin/buildhelpers/CompileDefaultTheme.java | 121 ++++++++++++++++ 27 files changed, 1230 insertions(+), 404 deletions(-) create mode 100644 build.properties create mode 100644 build.xml delete mode 100644 build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java delete mode 100644 build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java delete mode 100644 build/buildhelpers/com/vaadin/buildhelpers/ManifestWriter.java create mode 100644 buildhelpers/build.xml create mode 100644 buildhelpers/ivy.xml create mode 100644 buildhelpers/src/com/vaadin/buildhelpers/GeneratePackageExports.java create mode 100644 buildhelpers/src/com/vaadin/buildhelpers/ManifestWriter.java create mode 100755 client-compiler/build.xml create mode 100755 client-compiler/ivy.xml create mode 100644 client/build.xml create mode 100644 client/ivy.xml create mode 100644 common.xml create mode 100755 gwt-files.xml create mode 100644 ivysettings.xml create mode 100644 pom-template.xml create mode 100644 server/build.xml create mode 100644 server/ivy.xml create mode 100644 shared/build.xml create mode 100644 shared/ivy.xml create mode 100644 theme-compiler/build.xml create mode 100644 theme-compiler/ivy.xml create mode 100644 theme-compiler/ivymodule/smartsprites-ivy-0.2.3-itmill.xml create mode 100755 theme-compiler/src/com/vaadin/buildhelpers/CompileDefaultTheme.java diff --git a/.gitignore b/.gitignore index 999a655caf..fbc7eee0af 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,7 @@ # Mac *.DS_Store + +# build result folders +*/result +result \ No newline at end of file diff --git a/build.properties b/build.properties new file mode 100644 index 0000000000..7da02058ac --- /dev/null +++ b/build.properties @@ -0,0 +1,8 @@ +javadoc.doctitle=

Vaadin

+javadoc.bottom=Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved. +ivy.organisation=com.vaadin +vaadin.vendor=Vaadin Ltd +vaadin.java.version=6 +vaadin.version=0.0.0.noversion + + diff --git a/build.xml b/build.xml new file mode 100644 index 0000000000..f735a6ae7a --- /dev/null +++ b/build.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java b/build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java deleted file mode 100644 index 5b17ae4902..0000000000 --- a/build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.vaadin.buildhelpers; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; - -import com.vaadin.sass.ScssStylesheet; - -/** - * Helper to combine css divided into separate per component dirs into one to - * optimize http requests. - */ -public class CompileDefaultTheme { - - private static final String ARG_VERSION = "-version"; - - private static final String THEME_DIR = "./WebContent/VAADIN/themes/"; - private static final String BASE = "base"; - private static final String RUNO = "runo"; - private static final String REINDEER = "reindeer"; - private static final String LIFERAY = "liferay"; - private static final String CHAMELEON = "chameleon"; - - /** - * @param args - * @throws IOException - */ - public static void main(String[] args) throws IOException { - String ver = null; - for (int i = 0; i < args.length; i++) { - if (ARG_VERSION.equals(args[i])) { - if (args.length >= i) { - ver = args[i + 1]; - } - break; - } - } - - for (String themeName : new String[] { BASE, RUNO, LIFERAY, CHAMELEON }) { - try { - processSassTheme(themeName, false, ver); - System.out.println("Compiling theme " + themeName - + " successful"); - } catch (Exception e) { - System.err.println("Compiling theme " + themeName + " failed"); - e.printStackTrace(); - } - } - - // Compile Reindeer last, since it requires the spriting operation - // (makes testing the other themes a bit faster, since you don't need to - // wait for the spriting operation to finish before the theme CSS is - // compiled) - for (String themeName : new String[] { REINDEER }) { - try { - processSassTheme(themeName, true, ver); - System.out.println("Compiling theme " + themeName - + " successful"); - } catch (Exception e) { - System.err.println("Compiling theme " + themeName + " failed"); - e.printStackTrace(); - } - } - } - - private static void processSassTheme(String themeName, - boolean useSmartSprites, String version) throws Exception { - - StringBuffer cssHeader = new StringBuffer(); - - // Theme version - if (version == null) { - version = "9.9.9.INTERNAL-DEBUG-BUILD"; - } - version = version.replaceAll("\\.", "_"); - cssHeader.append(".v-theme-version:after {content:\"" + version - + "\";}\n"); - cssHeader.append(".v-theme-version-" + version + " {display: none;}\n"); - - String stylesCssDir = THEME_DIR + themeName + "/"; - String stylesCssName = stylesCssDir + "styles.css"; - - // Process as SASS file - ScssStylesheet scss = ScssStylesheet.get(stylesCssDir + "styles.scss"); - scss.compile(); - - BufferedWriter out = new BufferedWriter(new FileWriter(stylesCssName)); - out.write(cssHeader.toString()); - out.write(scss.toString()); - out.close(); - - System.out.println("Compiled CSS to " + stylesCssName + " (" - + scss.toString().length() + " bytes)"); - - if (useSmartSprites) { - createSprites(themeName); - System.out.println("Used SmartSprites to create sprites"); - File oldCss = new File(stylesCssName); - oldCss.delete(); - - File newCss = new File(stylesCssDir + "styles-sprite.css"); - boolean ok = newCss.renameTo(oldCss); - if (!ok) { - System.out.println("Rename " + newCss + " -> " + oldCss - + " failed"); - } - } - } - - private static void createSprites(String themeName) - throws FileNotFoundException, IOException { - String[] parameters = new String[] { "--sprite-png-depth", "AUTO", - "--css-file-suffix", "-sprite", "--css-file-encoding", "UTF-8", - "--root-dir-path", THEME_DIR + themeName, "--log-level", "WARN" }; - - org.carrot2.labs.smartsprites.SmartSprites.main(parameters); - - } -} diff --git a/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java b/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java deleted file mode 100644 index 0deebdc9a1..0000000000 --- a/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.vaadin.buildhelpers; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Enumeration; -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; - -/** - * 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. - * - * 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 "); - System.exit(1); - } - - // 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.exit(1); - } - - // List the included Java packages - HashSet packages = new HashSet(); - for (Enumeration it = jar.entries(); it.hasMoreElements();) { - JarEntry entry = it.nextElement(); - 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('/', '.'); - packages.add(pkg); - } - } - - // List theme packages - for (Enumeration it = jar.entries(); it.hasMoreElements();) { - JarEntry entry = it.nextElement(); - if (entry.isDirectory() - && entry.getName().startsWith("VAADIN/themes")) { - // Strip ending slash - int lastSlash = entry.getName().lastIndexOf('/'); - String pkg = entry.getName().substring(0, lastSlash) - .replace('/', '.'); - packages.add(pkg); - } - } - - // Replacement for the "Export-Package" attribute in the manifest - String exportPackage = ""; - - // Produce an ordered listing of the package names - String packageArray[] = new String[packages.size()]; - packages.toArray(packageArray); - Arrays.sort(packageArray); - for (int i = 0; i < packageArray.length; i++) { - if (i == 0) { - exportPackage = packageArray[i]; - } else { - exportPackage += ", " + packageArray[i]; - } - } - - // Read old manifest - Manifest oldMF = null; - try { - oldMF = jar.getManifest(); - } catch (IOException e) { - e.printStackTrace(); - } - - // Read main attributes - Attributes mainAtts = oldMF.getMainAttributes(); - Vector keys = new Vector(mainAtts.size()); - for (Iterator attrit = mainAtts.keySet().iterator(); attrit - .hasNext();) { - Name name = (Name) attrit.next(); - keys.add(name.toString()); - } - - // Jar must be closed before updating it below, as it's - // locked in Windows until closed. (#6045) - try { - jar.close(); - } catch (IOException e) { - System.err.println("Unable to close JAR '" + jarFilename + "'"); - } - - // Put the manifest version as the first line - 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"); - orderedKeys[mvPos] = orderedKeys[0]; // Swap - orderedKeys[0] = "Manifest-Version"; - - // This final ordering is just for esthetic reasons and - // in practice unnecessary and will actually be messed up - // when the 'jar' command reads the manifest - Arrays.sort(orderedKeys, 1, orderedKeys.length - 1); - - // Create the modified manifest - ManifestWriter manifest = new ManifestWriter(); - 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])); - } - } - - // 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. - manifest.writeAttribute("Export-Package", exportPackage); - - // Update the manifest in the Jar. The jar must be closed - // before this is done. - int status = manifest.updateJar(jarFilename); - - if (status != 0) { - System.exit(status); - } - } - -} diff --git a/build/buildhelpers/com/vaadin/buildhelpers/ManifestWriter.java b/build/buildhelpers/com/vaadin/buildhelpers/ManifestWriter.java deleted file mode 100644 index a6130e2a46..0000000000 --- a/build/buildhelpers/com/vaadin/buildhelpers/ManifestWriter.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * - */ -package com.vaadin.buildhelpers; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Date; -import java.util.jar.Manifest; - -public class ManifestWriter { - StringBuffer buffer = new StringBuffer(); - - public ManifestWriter() { - } - - /** - * Writes a manifest attribute to a temporary buffer. - * - * @param name Attribute name - * @param value Attribute value - */ - public void writeAttribute(String name, String value) { - int linelen = name.length() + 2; - buffer.append(name); - buffer.append(": "); - - String remainingValue = value; - while (linelen + remainingValue.length() > 72) { - int fitsLine = 72 - linelen; - buffer.append(remainingValue.substring(0, fitsLine) + "\n "); - remainingValue = remainingValue.substring(fitsLine); - linelen = 1; - } - buffer.append(remainingValue + "\n"); - } - - /** - * Writes the manifest to given JAR file. - * - * The manifest must be created with {@code #writeAttribute(String, String)} - * before calling this write. - * - * @param jarFilename File name of the JAR in which the manifest is written - * @return 0 on success, nonzero value on error - */ - int updateJar(String jarFilename) { - int status = 0; - - // Determine a temporary file name - String newMfPrefix = "vaadin-manifest-" + (new Date()).getTime(); - File newMfFile = null; - try { - newMfFile = File.createTempFile(newMfPrefix, ".mf"); - } catch (IOException e) { - System.err.println("Creating temp file failed"); - status = 1; - } - - // Write the manifest to the temporary file - if (status == 0) { - FileOutputStream fos = null; - try { - fos = new FileOutputStream(newMfFile); - fos.write(getBytes()); - fos.close(); - } catch (IOException e) { - System.err.println("Writing to file '"+newMfFile.getAbsolutePath() +"' failed because: " + e.getMessage()); - status = 1; - } - } - - // Check that the manifest is OK - if (status == 0) { - Manifest checkMf = new Manifest(); - FileInputStream is; - try { - is = new FileInputStream(newMfFile); - checkMf.read(is); - } catch (IOException e) { - System.err.println("Reading from file '"+newMfFile.getAbsolutePath() +"' failed because: " + e.getMessage()); - status = 1; - } - } - - // Update the manifest in the Jar - if (status == 0) { - System.out.println("Updating manifest in JAR " + jarFilename); - try { - // The "mf" order must correspond with manifest-jarfile order - Process process = Runtime.getRuntime().exec(new String[]{"jar", "umf", newMfFile.getAbsolutePath(), jarFilename}); - int exitValue = process.waitFor(); - if (exitValue != 0) { - InputStream jarErr = process.getErrorStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(jarErr)); - while (reader.ready()) { - System.err.println("jar: " + reader.readLine()); - } - System.err.println("The 'jar' command returned with exit value " + exitValue); - status = 1; - } - } catch (IOException e) { - System.err.println("Failed to execute 'jar' command. " + e.getMessage()); - status = 1; - } catch (InterruptedException e) { - System.err.println("Execution of 'jar' command was interrupted. " + e.getMessage()); - status = 1; - } - } - - // Remove the temporary file - if (newMfFile != null) - newMfFile.delete(); - - return status; - } - - public String toString() { - return buffer.toString(); - } - - public byte[] getBytes() { - return buffer.toString().getBytes(); - } -} \ No newline at end of file diff --git a/build/package/META-INF/MANIFEST.MF b/build/package/META-INF/MANIFEST.MF index ba28f96394..5d2e13a4da 100644 --- a/build/package/META-INF/MANIFEST.MF +++ b/build/package/META-INF/MANIFEST.MF @@ -2,5 +2,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: Vaadin Bundle-SymbolicName: com.vaadin Bundle-Vendor: Vaadin Ltd -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: javax.servlet; version="2.3.0",javax.servlet.http; version="2.3.0" diff --git a/buildhelpers/build.xml b/buildhelpers/build.xml new file mode 100644 index 0000000000..6137082e6b --- /dev/null +++ b/buildhelpers/build.xml @@ -0,0 +1,27 @@ + + + + + Compiles build helpers used when building other modules. + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/buildhelpers/ivy.xml b/buildhelpers/ivy.xml new file mode 100644 index 0000000000..63fee56709 --- /dev/null +++ b/buildhelpers/ivy.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/buildhelpers/src/com/vaadin/buildhelpers/GeneratePackageExports.java b/buildhelpers/src/com/vaadin/buildhelpers/GeneratePackageExports.java new file mode 100644 index 0000000000..0deebdc9a1 --- /dev/null +++ b/buildhelpers/src/com/vaadin/buildhelpers/GeneratePackageExports.java @@ -0,0 +1,152 @@ +package com.vaadin.buildhelpers; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Enumeration; +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; + +/** + * 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. + * + * 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 "); + System.exit(1); + } + + // 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.exit(1); + } + + // List the included Java packages + HashSet packages = new HashSet(); + for (Enumeration it = jar.entries(); it.hasMoreElements();) { + JarEntry entry = it.nextElement(); + 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('/', '.'); + packages.add(pkg); + } + } + + // List theme packages + for (Enumeration it = jar.entries(); it.hasMoreElements();) { + JarEntry entry = it.nextElement(); + if (entry.isDirectory() + && entry.getName().startsWith("VAADIN/themes")) { + // Strip ending slash + int lastSlash = entry.getName().lastIndexOf('/'); + String pkg = entry.getName().substring(0, lastSlash) + .replace('/', '.'); + packages.add(pkg); + } + } + + // Replacement for the "Export-Package" attribute in the manifest + String exportPackage = ""; + + // Produce an ordered listing of the package names + String packageArray[] = new String[packages.size()]; + packages.toArray(packageArray); + Arrays.sort(packageArray); + for (int i = 0; i < packageArray.length; i++) { + if (i == 0) { + exportPackage = packageArray[i]; + } else { + exportPackage += ", " + packageArray[i]; + } + } + + // Read old manifest + Manifest oldMF = null; + try { + oldMF = jar.getManifest(); + } catch (IOException e) { + e.printStackTrace(); + } + + // Read main attributes + Attributes mainAtts = oldMF.getMainAttributes(); + Vector keys = new Vector(mainAtts.size()); + for (Iterator attrit = mainAtts.keySet().iterator(); attrit + .hasNext();) { + Name name = (Name) attrit.next(); + keys.add(name.toString()); + } + + // Jar must be closed before updating it below, as it's + // locked in Windows until closed. (#6045) + try { + jar.close(); + } catch (IOException e) { + System.err.println("Unable to close JAR '" + jarFilename + "'"); + } + + // Put the manifest version as the first line + 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"); + orderedKeys[mvPos] = orderedKeys[0]; // Swap + orderedKeys[0] = "Manifest-Version"; + + // This final ordering is just for esthetic reasons and + // in practice unnecessary and will actually be messed up + // when the 'jar' command reads the manifest + Arrays.sort(orderedKeys, 1, orderedKeys.length - 1); + + // Create the modified manifest + ManifestWriter manifest = new ManifestWriter(); + 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])); + } + } + + // 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. + manifest.writeAttribute("Export-Package", exportPackage); + + // Update the manifest in the Jar. The jar must be closed + // before this is done. + int status = manifest.updateJar(jarFilename); + + if (status != 0) { + System.exit(status); + } + } + +} diff --git a/buildhelpers/src/com/vaadin/buildhelpers/ManifestWriter.java b/buildhelpers/src/com/vaadin/buildhelpers/ManifestWriter.java new file mode 100644 index 0000000000..a6130e2a46 --- /dev/null +++ b/buildhelpers/src/com/vaadin/buildhelpers/ManifestWriter.java @@ -0,0 +1,130 @@ +/** + * + */ +package com.vaadin.buildhelpers; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Date; +import java.util.jar.Manifest; + +public class ManifestWriter { + StringBuffer buffer = new StringBuffer(); + + public ManifestWriter() { + } + + /** + * Writes a manifest attribute to a temporary buffer. + * + * @param name Attribute name + * @param value Attribute value + */ + public void writeAttribute(String name, String value) { + int linelen = name.length() + 2; + buffer.append(name); + buffer.append(": "); + + String remainingValue = value; + while (linelen + remainingValue.length() > 72) { + int fitsLine = 72 - linelen; + buffer.append(remainingValue.substring(0, fitsLine) + "\n "); + remainingValue = remainingValue.substring(fitsLine); + linelen = 1; + } + buffer.append(remainingValue + "\n"); + } + + /** + * Writes the manifest to given JAR file. + * + * The manifest must be created with {@code #writeAttribute(String, String)} + * before calling this write. + * + * @param jarFilename File name of the JAR in which the manifest is written + * @return 0 on success, nonzero value on error + */ + int updateJar(String jarFilename) { + int status = 0; + + // Determine a temporary file name + String newMfPrefix = "vaadin-manifest-" + (new Date()).getTime(); + File newMfFile = null; + try { + newMfFile = File.createTempFile(newMfPrefix, ".mf"); + } catch (IOException e) { + System.err.println("Creating temp file failed"); + status = 1; + } + + // Write the manifest to the temporary file + if (status == 0) { + FileOutputStream fos = null; + try { + fos = new FileOutputStream(newMfFile); + fos.write(getBytes()); + fos.close(); + } catch (IOException e) { + System.err.println("Writing to file '"+newMfFile.getAbsolutePath() +"' failed because: " + e.getMessage()); + status = 1; + } + } + + // Check that the manifest is OK + if (status == 0) { + Manifest checkMf = new Manifest(); + FileInputStream is; + try { + is = new FileInputStream(newMfFile); + checkMf.read(is); + } catch (IOException e) { + System.err.println("Reading from file '"+newMfFile.getAbsolutePath() +"' failed because: " + e.getMessage()); + status = 1; + } + } + + // Update the manifest in the Jar + if (status == 0) { + System.out.println("Updating manifest in JAR " + jarFilename); + try { + // The "mf" order must correspond with manifest-jarfile order + Process process = Runtime.getRuntime().exec(new String[]{"jar", "umf", newMfFile.getAbsolutePath(), jarFilename}); + int exitValue = process.waitFor(); + if (exitValue != 0) { + InputStream jarErr = process.getErrorStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(jarErr)); + while (reader.ready()) { + System.err.println("jar: " + reader.readLine()); + } + System.err.println("The 'jar' command returned with exit value " + exitValue); + status = 1; + } + } catch (IOException e) { + System.err.println("Failed to execute 'jar' command. " + e.getMessage()); + status = 1; + } catch (InterruptedException e) { + System.err.println("Execution of 'jar' command was interrupted. " + e.getMessage()); + status = 1; + } + } + + // Remove the temporary file + if (newMfFile != null) + newMfFile.delete(); + + return status; + } + + public String toString() { + return buffer.toString(); + } + + public byte[] getBytes() { + return buffer.toString().getBytes(); + } +} \ No newline at end of file diff --git a/client-compiler/build.xml b/client-compiler/build.xml new file mode 100755 index 0000000000..71e15cac46 --- /dev/null +++ b/client-compiler/build.xml @@ -0,0 +1,32 @@ + + + + + Compiles build helpers used when building other modules. + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/client-compiler/ivy.xml b/client-compiler/ivy.xml new file mode 100755 index 0000000000..79def69bd8 --- /dev/null +++ b/client-compiler/ivy.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/client/build.xml b/client/build.xml new file mode 100644 index 0000000000..99dbb268d5 --- /dev/null +++ b/client/build.xml @@ -0,0 +1,32 @@ + + + + + Compiles build helpers used when building other modules. + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/client/ivy.xml b/client/ivy.xml new file mode 100644 index 0000000000..953ca51a61 --- /dev/null +++ b/client/ivy.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/common.xml b/common.xml new file mode 100644 index 0000000000..7eef3f1b00 --- /dev/null +++ b/common.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <h1>${module.name}</h1> + + ${javadoc.bottom} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gwt-files.xml b/gwt-files.xml new file mode 100755 index 0000000000..953a92b871 --- /dev/null +++ b/gwt-files.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ivysettings.xml b/ivysettings.xml new file mode 100644 index 0000000000..63d97b304c --- /dev/null +++ b/ivysettings.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom-template.xml b/pom-template.xml new file mode 100644 index 0000000000..cec0ca6dc4 --- /dev/null +++ b/pom-template.xml @@ -0,0 +1,62 @@ + + 4.0.0 + com.vaadin + ${module.name} + ${vaadin.version} + Vaadin + + Vaadin Ltd + http://vaadin.com + + http://vaadin.com + + Vaadin is a web application framework for Rich Internet Applications (RIA). + + Vaadin enables easy development and maintenance of fast and secure rich web + applications with a stunning look and feel and a wide browser support. + It features a server-side architecture with the majority of the logic running + on the server. Ajax technology is used at the browser-side to ensure a rich + and interactive user experience. + + + + Apache License Version 2.0 + repo + http://www.apache.org/licenses/LICENSE-2.0 + + + + + vaadin-releases + Vaadin release repository + http://oss.sonatype.org/content/repositories/vaadin-releases/ + + + vaadin-snapshots + Vaadin snapshot repository + http://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + + + + vaadin-snapshots + http://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + vaadin-releases + http://oss.sonatype.org/content/repositories/vaadin-releases/ + + true + + + false + + + + \ No newline at end of file diff --git a/server/build.xml b/server/build.xml new file mode 100644 index 0000000000..b4609cd265 --- /dev/null +++ b/server/build.xml @@ -0,0 +1,29 @@ + + + + + Compiles build helpers used when building other modules. + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/ivy.xml b/server/ivy.xml new file mode 100644 index 0000000000..7e9c826689 --- /dev/null +++ b/server/ivy.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shared/build.xml b/shared/build.xml new file mode 100644 index 0000000000..83dbe61b36 --- /dev/null +++ b/shared/build.xml @@ -0,0 +1,31 @@ + + + + + Compiles build helpers used when building other modules. + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shared/ivy.xml b/shared/ivy.xml new file mode 100644 index 0000000000..857ca1e859 --- /dev/null +++ b/shared/ivy.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/theme-compiler/build.xml b/theme-compiler/build.xml new file mode 100644 index 0000000000..9c3e5f46ce --- /dev/null +++ b/theme-compiler/build.xml @@ -0,0 +1,29 @@ + + + + + Compiles build helpers used when building other modules. + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/theme-compiler/ivy.xml b/theme-compiler/ivy.xml new file mode 100644 index 0000000000..9574328a3c --- /dev/null +++ b/theme-compiler/ivy.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/theme-compiler/ivymodule/smartsprites-ivy-0.2.3-itmill.xml b/theme-compiler/ivymodule/smartsprites-ivy-0.2.3-itmill.xml new file mode 100644 index 0000000000..495b6d00c9 --- /dev/null +++ b/theme-compiler/ivymodule/smartsprites-ivy-0.2.3-itmill.xml @@ -0,0 +1,38 @@ + + + + + + CSS Sprites Generator Done Right. SmartSprites maintains CSS sprites in your designs, + fully automatically. No tedious copying and pasting to your CSS when adding or changing + sprited images. + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/theme-compiler/src/com/vaadin/buildhelpers/CompileDefaultTheme.java b/theme-compiler/src/com/vaadin/buildhelpers/CompileDefaultTheme.java new file mode 100755 index 0000000000..5b17ae4902 --- /dev/null +++ b/theme-compiler/src/com/vaadin/buildhelpers/CompileDefaultTheme.java @@ -0,0 +1,121 @@ +package com.vaadin.buildhelpers; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; + +import com.vaadin.sass.ScssStylesheet; + +/** + * Helper to combine css divided into separate per component dirs into one to + * optimize http requests. + */ +public class CompileDefaultTheme { + + private static final String ARG_VERSION = "-version"; + + private static final String THEME_DIR = "./WebContent/VAADIN/themes/"; + private static final String BASE = "base"; + private static final String RUNO = "runo"; + private static final String REINDEER = "reindeer"; + private static final String LIFERAY = "liferay"; + private static final String CHAMELEON = "chameleon"; + + /** + * @param args + * @throws IOException + */ + public static void main(String[] args) throws IOException { + String ver = null; + for (int i = 0; i < args.length; i++) { + if (ARG_VERSION.equals(args[i])) { + if (args.length >= i) { + ver = args[i + 1]; + } + break; + } + } + + for (String themeName : new String[] { BASE, RUNO, LIFERAY, CHAMELEON }) { + try { + processSassTheme(themeName, false, ver); + System.out.println("Compiling theme " + themeName + + " successful"); + } catch (Exception e) { + System.err.println("Compiling theme " + themeName + " failed"); + e.printStackTrace(); + } + } + + // Compile Reindeer last, since it requires the spriting operation + // (makes testing the other themes a bit faster, since you don't need to + // wait for the spriting operation to finish before the theme CSS is + // compiled) + for (String themeName : new String[] { REINDEER }) { + try { + processSassTheme(themeName, true, ver); + System.out.println("Compiling theme " + themeName + + " successful"); + } catch (Exception e) { + System.err.println("Compiling theme " + themeName + " failed"); + e.printStackTrace(); + } + } + } + + private static void processSassTheme(String themeName, + boolean useSmartSprites, String version) throws Exception { + + StringBuffer cssHeader = new StringBuffer(); + + // Theme version + if (version == null) { + version = "9.9.9.INTERNAL-DEBUG-BUILD"; + } + version = version.replaceAll("\\.", "_"); + cssHeader.append(".v-theme-version:after {content:\"" + version + + "\";}\n"); + cssHeader.append(".v-theme-version-" + version + " {display: none;}\n"); + + String stylesCssDir = THEME_DIR + themeName + "/"; + String stylesCssName = stylesCssDir + "styles.css"; + + // Process as SASS file + ScssStylesheet scss = ScssStylesheet.get(stylesCssDir + "styles.scss"); + scss.compile(); + + BufferedWriter out = new BufferedWriter(new FileWriter(stylesCssName)); + out.write(cssHeader.toString()); + out.write(scss.toString()); + out.close(); + + System.out.println("Compiled CSS to " + stylesCssName + " (" + + scss.toString().length() + " bytes)"); + + if (useSmartSprites) { + createSprites(themeName); + System.out.println("Used SmartSprites to create sprites"); + File oldCss = new File(stylesCssName); + oldCss.delete(); + + File newCss = new File(stylesCssDir + "styles-sprite.css"); + boolean ok = newCss.renameTo(oldCss); + if (!ok) { + System.out.println("Rename " + newCss + " -> " + oldCss + + " failed"); + } + } + } + + private static void createSprites(String themeName) + throws FileNotFoundException, IOException { + String[] parameters = new String[] { "--sprite-png-depth", "AUTO", + "--css-file-suffix", "-sprite", "--css-file-encoding", "UTF-8", + "--root-dir-path", THEME_DIR + themeName, "--log-level", "WARN" }; + + org.carrot2.labs.smartsprites.SmartSprites.main(parameters); + + } +} -- cgit v1.2.3