diff options
author | Artur Signell <artur@vaadin.com> | 2012-12-02 11:16:17 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-12-02 11:16:17 +0200 |
commit | b5e242213d8616d1166df580c00d5ef1165c0784 (patch) | |
tree | 88aef597e71f54169f19cb4d625d751218acd026 /buildhelpers/src | |
parent | 84099ee2b8363c12a813157f9752981add5db113 (diff) | |
download | vaadin-framework-b5e242213d8616d1166df580c00d5ef1165c0784.tar.gz vaadin-framework-b5e242213d8616d1166df580c00d5ef1165c0784.zip |
Allow specifying version per java package (#10322)
Change-Id: Ib7cba6c4229c3a213efb57f096800268c5dd3512
Diffstat (limited to 'buildhelpers/src')
-rw-r--r-- | buildhelpers/src/com/vaadin/buildhelpers/GeneratePackageExports.java | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/buildhelpers/src/com/vaadin/buildhelpers/GeneratePackageExports.java b/buildhelpers/src/com/vaadin/buildhelpers/GeneratePackageExports.java index 0a69fbdf97..e2786dd4d8 100644 --- a/buildhelpers/src/com/vaadin/buildhelpers/GeneratePackageExports.java +++ b/buildhelpers/src/com/vaadin/buildhelpers/GeneratePackageExports.java @@ -10,6 +10,7 @@ import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; +import java.util.logging.Logger; /** * Generates Export-Packages attribute for OSGi compatible manifest. @@ -33,7 +34,6 @@ public class GeneratePackageExports { + "Use -Dvaadin.version to specify the version to be used for the packages"); System.exit(1); } - String vaadinVersion = System.getProperty("vaadin.version"); // Open the JAR String jarFilename = args[0]; @@ -59,7 +59,7 @@ public class GeneratePackageExports { return; } - String exportPackage = sortAndJoinPackages(packages, vaadinVersion); + String exportPackage = sortAndJoinPackages(packages); // Read old manifest Manifest oldMF = null; @@ -97,8 +97,7 @@ public class GeneratePackageExports { } } - private static String sortAndJoinPackages(HashSet<String> packages, - String vaadinVersion) { + private static String sortAndJoinPackages(HashSet<String> packages) { // Produce an ordered listing of the package names String packageArray[] = new String[packages.size()]; packages.toArray(packageArray); @@ -108,9 +107,13 @@ public class GeneratePackageExports { if (i != 0) { joinedPackages.append(","); } + String version = getVersion(packageArray[i]); String packageAndVersion = packageArray[i]; - if (vaadinVersion != null) { - packageAndVersion += ";version=\"" + vaadinVersion + "\""; + if (version != null) { + packageAndVersion += ";version=\"" + version + "\""; + } else { + Logger.getLogger(GeneratePackageExports.class.getName()) + .severe("No version defined for " + packageArray[i]); } joinedPackages.append(packageAndVersion); } @@ -118,6 +121,39 @@ public class GeneratePackageExports { return joinedPackages.toString(); } + /** + * Tries to find version specified using system properties of type + * version.<java package>. Searches for the packge and then its parents + * recursively. Falls back to the "vaadin.version" system property if no + * other properties are found. + * + * @param javaPackage + * The package to determine a version for + * @return A version or null if no version has been defined + */ + private static String getVersion(String javaPackage) { + String packageVersion = System.getProperty("version." + javaPackage); + if (packageVersion != null) { + return packageVersion; + } + String parentPackage = null; + if (javaPackage.contains(".")) { + parentPackage = javaPackage.substring(0, + javaPackage.lastIndexOf('.')); + String parentVersion = getVersion(parentPackage); + if (parentVersion != null) { + return parentVersion; + } + } + + String vaadinVersion = System.getProperty("vaadin.version"); + if (vaadinVersion != null) { + return vaadinVersion; + } + + return null; + } + private static HashSet<String> getPackages(JarFile jar, List<String> acceptedPackagePrefixes) { HashSet<String> packages = new HashSet<String>(); |