Use bnd-maven-plugin instead of maven-bundle-plugin and helper class, and add support for publishing static resources such as themes and widgetsets.tags/8.1.0.alpha7
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.buildhelpers; | |||||
import java.io.IOException; | |||||
import java.util.ArrayList; | |||||
import java.util.Arrays; | |||||
import java.util.Enumeration; | |||||
import java.util.HashSet; | |||||
import java.util.List; | |||||
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; | |||||
import java.util.regex.Pattern; | |||||
/** | |||||
* Generates Export-Packages attribute for OSGi compatible manifest. | |||||
* <p> | |||||
* Reads the included Java packages in a jar file, generates a corresponding | |||||
* Export-Package attribute, and appends it to the jar's MANIFEST.MF. | |||||
* <p> | |||||
* See #3521 for details. | |||||
* | |||||
* @author magi | |||||
*/ | |||||
public class GeneratePackageExports { | |||||
private static final String EXPORT_PACKAGE_ATTRIBUTE = "Export-Package"; | |||||
public static void main(String[] args) { | |||||
if (args.length < 2) { | |||||
System.err.println("Invalid number of parameters\n" | |||||
+ "Usage: java -cp .. GenerateManifest <package.jar> <accepted package prefixes>\n" | |||||
+ "Use -Dvaadin.version to specify the version to be used for the packages\n" | |||||
+ "Use -DincludeNumberPackages=1 to include package names which start with a number (not 100% OSGi compatible)"); | |||||
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); | |||||
} | |||||
// Accepted packages | |||||
List<String> acceptedPackagePrefixes = new ArrayList<>(); | |||||
for (int i = 1; i < args.length; i++) { | |||||
acceptedPackagePrefixes.add(args[i]); | |||||
} | |||||
boolean includeNumberPackages = false; | |||||
if ("1".equals(System.getProperty("includeNumberPackages"))) { | |||||
includeNumberPackages = true; | |||||
} | |||||
// List the included Java packages | |||||
HashSet<String> packages = getPackages(jar, acceptedPackagePrefixes, | |||||
includeNumberPackages); | |||||
// Avoid writing empty Export-Package attribute | |||||
if (packages.isEmpty()) { | |||||
return; | |||||
} | |||||
String exportPackage = sortAndJoinPackages(packages); | |||||
// Read old manifest | |||||
Manifest oldMF = null; | |||||
try { | |||||
oldMF = jar.getManifest(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
Attributes mainAttributes = oldMF.getMainAttributes(); | |||||
String existingExportPackage = mainAttributes | |||||
.getValue(EXPORT_PACKAGE_ATTRIBUTE); | |||||
if (existingExportPackage != null) { | |||||
exportPackage = existingExportPackage + "," + exportPackage; | |||||
} | |||||
// 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 + "'"); | |||||
} | |||||
// Create the modified manifest | |||||
ManifestWriter manifest = new ManifestWriter(); | |||||
manifest.writeAttribute(EXPORT_PACKAGE_ATTRIBUTE, 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); | |||||
} | |||||
} | |||||
private static String sortAndJoinPackages(HashSet<String> packages) { | |||||
// Produce an ordered listing of the package names | |||||
String packageArray[] = new String[packages.size()]; | |||||
packages.toArray(packageArray); | |||||
Arrays.sort(packageArray); | |||||
StringBuilder joinedPackages = new StringBuilder(); | |||||
for (int i = 0; i < packageArray.length; i++) { | |||||
if (i != 0) { | |||||
joinedPackages.append(","); | |||||
} | |||||
String version = getVersion(packageArray[i]); | |||||
String packageAndVersion = packageArray[i]; | |||||
if (version != null) { | |||||
packageAndVersion += ";version=\"" + version + "\""; | |||||
} else { | |||||
Logger.getLogger(GeneratePackageExports.class.getName()) | |||||
.severe("No version defined for " + packageArray[i]); | |||||
} | |||||
joinedPackages.append(packageAndVersion); | |||||
} | |||||
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, | |||||
boolean includeNumberPackages) { | |||||
HashSet<String> packages = new HashSet<>(); | |||||
Pattern startsWithNumber = Pattern.compile("\\.\\d"); | |||||
for (Enumeration<JarEntry> it = jar.entries(); it.hasMoreElements();) { | |||||
JarEntry entry = it.nextElement(); | |||||
boolean classFile = entry.getName().endsWith(".class"); | |||||
boolean directory = entry.isDirectory(); | |||||
if (!classFile && !directory) { | |||||
continue; | |||||
} | |||||
if (!acceptEntry(entry.getName(), acceptedPackagePrefixes)) { | |||||
continue; | |||||
} | |||||
int lastSlash = entry.getName().lastIndexOf('/'); | |||||
String pkg = entry.getName().substring(0, lastSlash).replace('/', | |||||
'.'); | |||||
if (!includeNumberPackages | |||||
&& startsWithNumber.matcher(pkg).find()) { | |||||
continue; | |||||
} | |||||
packages.add(pkg); | |||||
} | |||||
return packages; | |||||
} | |||||
private static boolean acceptEntry(String name, | |||||
List<String> acceptedPackagePrefixes) { | |||||
for (String prefix : acceptedPackagePrefixes) { | |||||
if (name.startsWith(prefix)) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
} |
Bundle-SymbolicName: ${project.groupId}.client.compiled | |||||
Bundle-Name: Default Widgetset | |||||
Bundle-Version: ${osgi.bundle.version} | |||||
Import-Package: com.vaadin*;version='[${osgi.bundle.version},${osgi.bundle.version}]',\ | |||||
* | |||||
Export-Package: com.vaadin.osgi.widgetset;-noimport:=true |
<scope>provided</scope> | <scope>provided</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>${project.groupId}</groupId> | |||||
<artifactId>vaadin-shared</artifactId> | |||||
<version>${project.version}</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | <dependency> | ||||
<groupId>${project.groupId}</groupId> | <groupId>${project.groupId}</groupId> | ||||
<artifactId>vaadin-client</artifactId> | <artifactId>vaadin-client</artifactId> | ||||
<version>${project.version}</version> | <version>${project.version}</version> | ||||
<scope>provided</scope> | <scope>provided</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
<build> | <build> | ||||
<plugins> | <plugins> | ||||
<plugin> | |||||
<groupId>org.codehaus.mojo</groupId> | |||||
<artifactId>exec-maven-plugin</artifactId> | |||||
<executions> | |||||
<execution> | |||||
<id>generate-export-package</id> | |||||
<phase>package</phase> | |||||
<goals> | |||||
<goal>exec</goal> | |||||
</goals> | |||||
<configuration> | |||||
<classpathScope>compile</classpathScope> | |||||
<executable>${java.home}/bin/java</executable> | |||||
<arguments> | |||||
<argument>-Dvaadin.version=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</argument> | |||||
<argument>-DincludeNumberPackages=1</argument> | |||||
<argument>-classpath</argument> | |||||
<classpath /> | |||||
<argument>com.vaadin.buildhelpers.GeneratePackageExports</argument> | |||||
<argument>${project.build.directory}/${project.build.finalName}.${project.packaging}</argument> | |||||
<argument>VAADIN/widgetsets</argument> | |||||
</arguments> | |||||
</configuration> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | <plugin> | ||||
<groupId>com.vaadin</groupId> | <groupId>com.vaadin</groupId> | ||||
<artifactId>vaadin-maven-plugin</artifactId> | <artifactId>vaadin-maven-plugin</artifactId> | ||||
</execution> | </execution> | ||||
</executions> | </executions> | ||||
</plugin> | </plugin> | ||||
<plugin> | |||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<extensions>true</extensions> | |||||
<configuration> | |||||
<instructions> | |||||
<Bundle-Version>${osgi.bundle.version}</Bundle-Version> | |||||
<Bundle-RequiredExecutionEnvironment>${osgi.execution.environment}</Bundle-RequiredExecutionEnvironment> | |||||
<!-- Export package is handled in exec plugin --> | |||||
<Export-Package></Export-Package> | |||||
<Import-Package></Import-Package> | |||||
</instructions> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>bundle-manifest</id> | |||||
<phase>prepare-package</phase> | |||||
<goals> | |||||
<goal>manifest</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
</plugin> | |||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> | ||||
<artifactId>maven-jar-plugin</artifactId> | <artifactId>maven-jar-plugin</artifactId> |
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.osgi.widgetset; | |||||
import org.osgi.service.component.ComponentContext; | |||||
import org.osgi.service.component.annotations.Activate; | |||||
import org.osgi.service.component.annotations.Component; | |||||
import org.osgi.service.component.annotations.Reference; | |||||
import org.osgi.service.http.HttpService; | |||||
import com.vaadin.osgi.resources.OSGiVaadinResources; | |||||
import com.vaadin.osgi.resources.VaadinResourceService; | |||||
@Component(immediate = true) | |||||
public class DefaultWidgetsetContribution { | |||||
private HttpService httpService; | |||||
private static final String WIDGETSET_NAME = "com.vaadin.DefaultWidgetSet"; | |||||
@Activate | |||||
void startup(ComponentContext context) throws Exception { | |||||
VaadinResourceService service = OSGiVaadinResources.getService(); | |||||
service.publishWidgetset(WIDGETSET_NAME, httpService); | |||||
} | |||||
@Reference | |||||
void setHttpService(HttpService httpService) { | |||||
this.httpService = httpService; | |||||
} | |||||
void unsetHttpService(HttpService httpService) { | |||||
this.httpService = null; | |||||
} | |||||
} |
Bundle-SymbolicName: ${project.groupId}.compatibility.client.compiled | |||||
Bundle-Name: Compatibility Widgetset | |||||
Bundle-Version: ${osgi.bundle.version} | |||||
Import-Package: com.vaadin*;version='[${osgi.bundle.version},${osgi.bundle.version}]',\ | |||||
* | |||||
Export-Package: com.vaadin.osgi.compatibility.widgetset;-noimport:=true |
<version>${project.version}</version> | <version>${project.version}</version> | ||||
<scope>provided</scope> | <scope>provided</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
<build> | <build> | ||||
<plugins> | <plugins> | ||||
<plugin> | |||||
<groupId>org.codehaus.mojo</groupId> | |||||
<artifactId>exec-maven-plugin</artifactId> | |||||
<executions> | |||||
<execution> | |||||
<id>generate-export-package</id> | |||||
<phase>package</phase> | |||||
<goals> | |||||
<goal>exec</goal> | |||||
</goals> | |||||
<configuration> | |||||
<classpathScope>compile</classpathScope> | |||||
<executable>${java.home}/bin/java</executable> | |||||
<arguments> | |||||
<argument>-Dvaadin.version=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</argument> | |||||
<argument>-DincludeNumberPackages=1</argument> | |||||
<argument>-classpath</argument> | |||||
<classpath /> | |||||
<argument>com.vaadin.buildhelpers.GeneratePackageExports</argument> | |||||
<argument>${project.build.directory}/${project.build.finalName}.${project.packaging}</argument> | |||||
<argument>VAADIN/widgetsets</argument> | |||||
</arguments> | |||||
</configuration> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | <plugin> | ||||
<groupId>com.vaadin</groupId> | <groupId>com.vaadin</groupId> | ||||
<artifactId>vaadin-maven-plugin</artifactId> | <artifactId>vaadin-maven-plugin</artifactId> | ||||
</execution> | </execution> | ||||
</executions> | </executions> | ||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<extensions>true</extensions> | |||||
<configuration> | |||||
<instructions> | |||||
<Bundle-Version>${osgi.bundle.version}</Bundle-Version> | |||||
<Bundle-RequiredExecutionEnvironment>${osgi.execution.environment}</Bundle-RequiredExecutionEnvironment> | |||||
<!-- Export package is handled in exec plugin --> | |||||
<Export-Package></Export-Package> | |||||
<Import-Package></Import-Package> | |||||
</instructions> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>bundle-manifest</id> | |||||
<phase>prepare-package</phase> | |||||
<goals> | |||||
<goal>manifest</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> | ||||
<artifactId>maven-jar-plugin</artifactId> | <artifactId>maven-jar-plugin</artifactId> |
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.osgi.compatibility.widgetset; | |||||
import org.osgi.service.component.ComponentContext; | |||||
import org.osgi.service.component.annotations.Activate; | |||||
import org.osgi.service.component.annotations.Component; | |||||
import org.osgi.service.component.annotations.Reference; | |||||
import org.osgi.service.http.HttpService; | |||||
import com.vaadin.osgi.resources.OSGiVaadinResources; | |||||
import com.vaadin.osgi.resources.VaadinResourceService; | |||||
@Component(immediate = true) | |||||
public class CompatibilityWidgetsetContribution { | |||||
private HttpService httpService; | |||||
private static final String WIDGETSET_NAME = "com.vaadin.v7.Vaadin7WidgetSet"; | |||||
@Activate | |||||
void startup(ComponentContext context) throws Exception { | |||||
VaadinResourceService service = OSGiVaadinResources.getService(); | |||||
service.publishWidgetset(WIDGETSET_NAME, httpService); | |||||
} | |||||
@Reference | |||||
void setHttpService(HttpService httpService) { | |||||
this.httpService = httpService; | |||||
} | |||||
void unsetHttpService(HttpService httpService) { | |||||
this.httpService = null; | |||||
} | |||||
} |
Bundle-SymbolicName: ${project.groupId}.compatibility.server | |||||
Bundle-Name: Vaadin Compatibility Server | |||||
Import-Package: com.vaadin*;version="[${osgi.bundle.version},${osgi.bundle.version}]",\ | |||||
!com.google*,\ | |||||
org.osgi*,\ | |||||
javax.validation*;resolution:=optional;version='${javax.validation.version}',\ | |||||
* | |||||
Export-Package: !com.vaadin.v7.shared*,\ | |||||
!com.vaadin.v7.client*,\ | |||||
com.vaadin.v7*;-noimport:=true |
</execution> | </execution> | ||||
</executions> | </executions> | ||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<extensions>true</extensions> | |||||
<configuration> | |||||
<instructions> | |||||
<Bundle-RequiredExecutionEnvironment>${osgi.execution.environment}</Bundle-RequiredExecutionEnvironment> | |||||
<Bundle-Version>${osgi.bundle.version}</Bundle-Version> | |||||
<Export-Package>VAADIN;version="${osgi.bundle.version}",com.vaadin.v7.*;version="${osgi.bundle.version}"</Export-Package> | |||||
<Import-Package>!com.google.appengine.api.datastore, | |||||
!com.google.appengine.api.memcache, | |||||
!com.google.apphosting.api, | |||||
* | |||||
</Import-Package> | |||||
<Require-Bundle> | |||||
com.vaadin.server;bundle-version="${osgi.bundle.version}", | |||||
com.vaadin.shared;bundle-version="${osgi.bundle.version}" | |||||
</Require-Bundle> | |||||
</instructions> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>bundle-manifest</id> | |||||
<phase>prepare-package</phase> | |||||
<goals> | |||||
<goal>manifest</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> | ||||
<artifactId>maven-jar-plugin</artifactId> | <artifactId>maven-jar-plugin</artifactId> |
Bundle-SymbolicName: ${project.groupId}.compatibility.shared | |||||
Bundle-Name: Vaadin Compatibility Shared | |||||
Import-Package: com.vaadin*;version="[${osgi.bundle.version},${osgi.bundle.version}]",\ | |||||
org.osgi* | |||||
Export-Package: \ | |||||
com.vaadin.v7.shared*;-noimport:=true |
</execution> | </execution> | ||||
</executions> | </executions> | ||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<extensions>true</extensions> | |||||
<configuration> | |||||
<instructions> | |||||
<Bundle-RequiredExecutionEnvironment>${osgi.execution.environment}</Bundle-RequiredExecutionEnvironment> | |||||
<Bundle-Version>${osgi.bundle.version}</Bundle-Version> | |||||
<Export-Package>com.vaadin.*;version="${osgi.bundle.version}"</Export-Package> | |||||
<Require-Bundle> | |||||
com.vaadin.shared;bundle-version="${osgi.bundle.version}" | |||||
</Require-Bundle> | |||||
</instructions> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>bundle-manifest</id> | |||||
<phase>prepare-package</phase> | |||||
<goals> | |||||
<goal>manifest</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<artifactId>maven-resources-plugin</artifactId> | <artifactId>maven-resources-plugin</artifactId> | ||||
<executions> | <executions> |
Bundle-SymbolicName: ${project.groupId}.compatibility.themes | |||||
Bundle-Name: Vaadin Compatibility Themes | |||||
Bundle-Version: ${osgi.bundle.version} | |||||
Import-Package: com.vaadin*;version='[${osgi.bundle.version},${osgi.bundle.version}]',\ | |||||
* | |||||
Export-Package: com.vaadin.osgi.compatibility.themes;-noimport:=true |
<artifactId>commons-io</artifactId> | <artifactId>commons-io</artifactId> | ||||
<scope>provided</scope> | <scope>provided</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
<build> | <build> | ||||
</arguments> | </arguments> | ||||
</configuration> | </configuration> | ||||
</execution> | </execution> | ||||
<execution> | |||||
<id>generate-export-package</id> | |||||
<phase>package</phase> | |||||
<goals> | |||||
<goal>exec</goal> | |||||
</goals> | |||||
<configuration> | |||||
<classpathScope>compile</classpathScope> | |||||
<executable>${java.home}/bin/java</executable> | |||||
<arguments> | |||||
<argument>-Dvaadin.version=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</argument> | |||||
<argument>-DincludeNumberPackages=0</argument> | |||||
<argument>-classpath</argument> | |||||
<classpath /> | |||||
<argument>com.vaadin.buildhelpers.GeneratePackageExports</argument> | |||||
<argument>${project.build.directory}/${project.build.finalName}.${project.packaging}</argument> | |||||
<argument>VAADIN/themes</argument> | |||||
</arguments> | |||||
</configuration> | |||||
</execution> | |||||
</executions> | </executions> | ||||
</plugin> | </plugin> | ||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<extensions>true</extensions> | |||||
<configuration> | |||||
<instructions> | |||||
<Bundle-Version>${osgi.bundle.version}</Bundle-Version> | |||||
<Bundle-RequiredExecutionEnvironment>${osgi.execution.environment}</Bundle-RequiredExecutionEnvironment> | |||||
<!-- Export package is handled in exec plugin --> | |||||
<Export-Package></Export-Package> | |||||
<Import-Package></Import-Package> | |||||
</instructions> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>bundle-manifest</id> | |||||
<phase>prepare-package</phase> | |||||
<goals> | |||||
<goal>manifest</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> | ||||
<artifactId>maven-jar-plugin</artifactId> | <artifactId>maven-jar-plugin</artifactId> |
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.osgi.compatibility.themes; | |||||
import org.osgi.service.component.annotations.Activate; | |||||
import org.osgi.service.component.annotations.Component; | |||||
import org.osgi.service.component.annotations.Reference; | |||||
import org.osgi.service.http.HttpService; | |||||
import com.vaadin.osgi.resources.OSGiVaadinResources; | |||||
import com.vaadin.osgi.resources.VaadinResourceService; | |||||
@Component(immediate = true) | |||||
public class LegacyThemeContributions { | |||||
private static final String[] LEGACY_THEMES = { "base", "chameleon", | |||||
"reindeer", "runo" }; | |||||
private HttpService httpService; | |||||
@Activate | |||||
void startup() throws Exception { | |||||
VaadinResourceService service = OSGiVaadinResources.getService(); | |||||
for (String themeName : LEGACY_THEMES) { | |||||
service.publishTheme(themeName, httpService); | |||||
} | |||||
} | |||||
@Reference | |||||
void setHttpService(HttpService httpService) { | |||||
this.httpService = httpService; | |||||
} | |||||
void unsetHttpService(HttpService httpService) { | |||||
this.httpService = null; | |||||
} | |||||
} |
<!-- Used version numbers for dependencies --> | <!-- Used version numbers for dependencies --> | ||||
<liferay.portal-service.version>6.2.5</liferay.portal-service.version> | <liferay.portal-service.version>6.2.5</liferay.portal-service.version> | ||||
<liferay.portal-kernel.version>2.0.0</liferay.portal-kernel.version> | |||||
<vaadin.gwt.version>2.8.0</vaadin.gwt.version> | <vaadin.gwt.version>2.8.0</vaadin.gwt.version> | ||||
<vaadin.plugin.version>8.1-SNAPSHOT</vaadin.plugin.version> | <vaadin.plugin.version>8.1-SNAPSHOT</vaadin.plugin.version> | ||||
<atmosphere.runtime.version>2.4.5.vaadin2</atmosphere.runtime.version> | <atmosphere.runtime.version>2.4.5.vaadin2</atmosphere.runtime.version> | ||||
<!-- OSGi --> | <!-- OSGi --> | ||||
<osgi.javax.servlet.version>3.0.0</osgi.javax.servlet.version> | |||||
<osgi.execution.environment>JavaSE-1.8</osgi.execution.environment> | <osgi.execution.environment>JavaSE-1.8</osgi.execution.environment> | ||||
<osgi.bundle.version>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</osgi.bundle.version> | <osgi.bundle.version>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</osgi.bundle.version> | ||||
<osgi.version>6.0.0</osgi.version> | |||||
<osgi.annotation.version>6.0.1</osgi.annotation.version> | |||||
<bnd.version>3.3.0</bnd.version> | |||||
<!-- Dependency unpack directory --> | <!-- Dependency unpack directory --> | ||||
<dependency.unpack.directory>${project.build.directory}/dependency-unpack</dependency.unpack.directory> | <dependency.unpack.directory>${project.build.directory}/dependency-unpack</dependency.unpack.directory> | ||||
<!-- Cannot use 9.3 or 9.4 because they sometimes reset the connection too early in case of errors --> | |||||
<!-- Cannot use 9.3 or 9.4 because they sometimes reset the connection | |||||
too early in case of errors --> | |||||
<!-- See e.g. https://issues.apache.org/jira/browse/SOLR-8453 --> | <!-- See e.g. https://issues.apache.org/jira/browse/SOLR-8453 --> | ||||
<jetty.version>9.2.9.v20150224</jetty.version> | <jetty.version>9.2.9.v20150224</jetty.version> | ||||
<phantomjs.version>2.1.1</phantomjs.version> | <phantomjs.version>2.1.1</phantomjs.version> | ||||
<version>${vaadin.icons.version}</version> | <version>${vaadin.icons.version}</version> | ||||
<scope>provided</scope> | <scope>provided</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
<version>${osgi.version}</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.annotation</artifactId> | |||||
<version>${osgi.annotation.version}</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
<version>${osgi.version}</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
</dependencyManagement> | </dependencyManagement> | ||||
<version>1.8</version> | <version>1.8</version> | ||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<version>3.0.1</version> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
<version>${bnd.version}</version> | |||||
<executions> | |||||
<execution> | |||||
<goals> | |||||
<goal>bnd-process</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> |
Bundle-SymbolicName: ${project.groupId}.push | |||||
Bundle-Name: Vaadin Push | |||||
Bundle-Version: ${osgi.bundle.version} | |||||
Import-Package: com.vaadin*;version='[${osgi.bundle.version},${osgi.bundle.version}]',\ | |||||
* | |||||
Export-Package: com.vaadin.osgi.push;-noimport:=true |
<type>war</type> | <type>war</type> | ||||
<scope>provided</scope> | <scope>provided</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>${project.groupId}</groupId> | |||||
<artifactId>vaadin-shared</artifactId> | |||||
<version>${project.version}</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
<build> | <build> | ||||
<outputDirectory>${project.build.outputDirectory}/VAADIN</outputDirectory> | <outputDirectory>${project.build.outputDirectory}/VAADIN</outputDirectory> | ||||
</configuration> | </configuration> | ||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<extensions>true</extensions> | |||||
<configuration> | |||||
<instructions> | |||||
<Bundle-Version>${osgi.bundle.version}</Bundle-Version> | |||||
<Bundle-RequiredExecutionEnvironment>${osgi.execution.environment}</Bundle-RequiredExecutionEnvironment> | |||||
<Export-Package>VAADIN</Export-Package> | |||||
<Require-Bundle>com.vaadin.external.atmosphere.runtime;bundle-version="${atmosphere.runtime.version}";visibility:=reexport</Require-Bundle> | |||||
</instructions> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>bundle-manifest</id> | |||||
<phase>process-classes</phase> | |||||
<goals> | |||||
<goal>manifest</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> |
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.osgi.push; | |||||
import org.osgi.service.component.ComponentContext; | |||||
import org.osgi.service.component.annotations.Activate; | |||||
import org.osgi.service.component.annotations.Component; | |||||
import org.osgi.service.component.annotations.Reference; | |||||
import org.osgi.service.http.HttpService; | |||||
import com.vaadin.osgi.resources.OSGiVaadinResources; | |||||
import com.vaadin.osgi.resources.VaadinResourceService; | |||||
@Component(immediate = true) | |||||
public class PushResourcesContribution { | |||||
private HttpService httpService; | |||||
private static final String[] RESOURCES = { "vaadinPush.js", | |||||
"vaadinPush.js.gz", "vaadinPush.debug.js", | |||||
"vaadinPush.debug.js.gz" }; | |||||
@Activate | |||||
void startup(ComponentContext context) throws Exception { | |||||
VaadinResourceService service = OSGiVaadinResources.getService(); | |||||
for (String resourceName : RESOURCES) { | |||||
service.publishResource(resourceName, httpService); | |||||
} | |||||
} | |||||
@Reference | |||||
void setHttpService(HttpService httpService) { | |||||
this.httpService = httpService; | |||||
} | |||||
void unsetHttpService(HttpService httpService) { | |||||
this.httpService = null; | |||||
} | |||||
} |
Bundle-SymbolicName: ${project.groupId}.server | |||||
Bundle-Name: Vaadin Server | |||||
Bundle-Version: ${osgi.bundle.version} | |||||
Import-Package: com.vaadin.sass.*;resolution:=optional,\ | |||||
com.liferay.portal.kernel.util;resolution:=optional,\ | |||||
javax.portlet*;resolution:=optional,\ | |||||
javax.validation*;resolution:=optional;version='${javax.validation.version}',\ | |||||
org.atmosphere*;resolution:=optional,\ | |||||
com.vaadin*;version='[${osgi.bundle.version},${osgi.bundle.version}]',\ | |||||
* | |||||
Export-Package: !com.vaadin.sass*,\ | |||||
!com.vaadin.shared*,\ | |||||
!com.vaadin.osgi.resources*,\ | |||||
!com.vaadin.osgi.push*,\ | |||||
com.vaadin*;-noimport:=true |
<!-- API DEPENDENCIES --> | <!-- API DEPENDENCIES --> | ||||
<!-- Liferay Portal Service --> | <!-- Liferay Portal Service --> | ||||
<dependency> | |||||
<groupId>com.liferay.portal</groupId> | |||||
<artifactId>com.liferay.portal.kernel</artifactId> | |||||
<version>${liferay.portal-kernel.version}</version> | |||||
<scope>provided</scope> | |||||
</dependency> | |||||
<!-- Liferay 6 --> | |||||
<dependency> | <dependency> | ||||
<groupId>com.liferay.portal</groupId> | <groupId>com.liferay.portal</groupId> | ||||
<artifactId>portal-service</artifactId> | <artifactId>portal-service</artifactId> | ||||
<version>1.2.0</version> | <version>1.2.0</version> | ||||
</dependency> | </dependency> | ||||
<!-- OSGi API --> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
</dependency> | |||||
<!-- TESTING DEPENDENCIES --> | <!-- TESTING DEPENDENCIES --> | ||||
<!-- Test dependencies --> | <!-- Test dependencies --> | ||||
</execution> | </execution> | ||||
</executions> | </executions> | ||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<extensions>true</extensions> | |||||
<configuration> | |||||
<instructions> | |||||
<Bundle-RequiredExecutionEnvironment>${osgi.execution.environment}</Bundle-RequiredExecutionEnvironment> | |||||
<Bundle-Version>${osgi.bundle.version}</Bundle-Version> | |||||
<Export-Package>VAADIN;version="${osgi.bundle.version}",com.vaadin.*;version="${osgi.bundle.version}"</Export-Package> | |||||
<!-- Note that Liferay 6 does not use OSGi, and the dependency is optional for non-Liferay deployments --> | |||||
<Import-Package>javax.servlet;version="${osgi.javax.servlet.version}", | |||||
javax.servlet.http;version="${osgi.javax.servlet.version}", | |||||
javax.validation;version="${javax.validation.version}";resolution:=optional, | |||||
org.jsoup;version="${jsoup.version}", | |||||
org.jsoup.parser;version="${jsoup.version}", | |||||
org.jsoup.nodes;version="${jsoup.version}", | |||||
org.jsoup.helper;version="${jsoup.version}", | |||||
org.jsoup.safety;version="${jsoup.version}", | |||||
org.jsoup.select;version="${jsoup.version}", | |||||
javax.portlet;version="[${javax.portlet.version},3)";resolution:=optional, | |||||
javax.portlet.filter;version="[${javax.portlet.version},3)";resolution:=optional, | |||||
com.liferay.portal.kernel.util;version="[7,8)";resolution:=optional</Import-Package> | |||||
<Require-Bundle> | |||||
com.vaadin.shared;bundle-version="${osgi.bundle.version}", | |||||
com.vaadin.push;bundle-version="${osgi.bundle.version}";resolution:=optional, | |||||
com.vaadin.sass-compiler;bundle-version="${vaadin.sass.version}";resolution:=optional</Require-Bundle> | |||||
</instructions> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>bundle-manifest</id> | |||||
<phase>prepare-package</phase> | |||||
<goals> | |||||
<goal>manifest</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> | ||||
<artifactId>maven-jar-plugin</artifactId> | <artifactId>maven-jar-plugin</artifactId> | ||||
</manifest> | </manifest> | ||||
</archive> | </archive> | ||||
</configuration> | </configuration> | ||||
<!-- Package src/test into a jar so that compatbility-server | |||||
<!-- Package src/test into a jar so that compatbility-server | |||||
can use the same test classes, e.g. test beans --> | can use the same test classes, e.g. test beans --> | ||||
<executions> | <executions> | ||||
<execution> | <execution> | ||||
<artifactId>maven-surefire-plugin</artifactId> | <artifactId>maven-surefire-plugin</artifactId> | ||||
</plugin> | </plugin> | ||||
</plugins> | </plugins> | ||||
<pluginManagement> | <pluginManagement> | ||||
<plugins> | <plugins> | ||||
<!-- Make Eclipse add the source folder --> | <!-- Make Eclipse add the source folder --> | ||||
</plugins> | </plugins> | ||||
</pluginManagement> | </pluginManagement> | ||||
</build> | </build> | ||||
</project> | </project> |
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.server.osgi; | |||||
import org.osgi.service.component.annotations.Activate; | |||||
import org.osgi.service.component.annotations.Component; | |||||
import org.osgi.service.component.annotations.Reference; | |||||
import org.osgi.service.http.HttpService; | |||||
import org.osgi.service.http.NamespaceException; | |||||
import com.vaadin.osgi.resources.OSGiVaadinResources; | |||||
import com.vaadin.osgi.resources.VaadinResourceService; | |||||
import com.vaadin.osgi.resources.OSGiVaadinResources.ResourceBundleInactiveException; | |||||
@Component(immediate = true) | |||||
public class BootstrapContribution { | |||||
private static final String[] RESOURCES = { "vaadinBootstrap.js", | |||||
"vaadinBootstrap.js.gz" }; | |||||
private HttpService httpService; | |||||
@Activate | |||||
void startup() throws NamespaceException, ResourceBundleInactiveException { | |||||
VaadinResourceService service = OSGiVaadinResources.getService(); | |||||
for (String resourceName : RESOURCES) { | |||||
service.publishResource(resourceName, httpService); | |||||
} | |||||
} | |||||
@Reference | |||||
void setHttpService(HttpService service) { | |||||
this.httpService = service; | |||||
} | |||||
void unsetHttpService(HttpService service) { | |||||
this.httpService = null; | |||||
} | |||||
} |
"com\\.vaadin\\.themes\\.valoutil\\.BodyStyleName", // | "com\\.vaadin\\.themes\\.valoutil\\.BodyStyleName", // | ||||
"com\\.vaadin\\.server\\.communication\\.JSR356WebsocketInitializer.*", // | "com\\.vaadin\\.server\\.communication\\.JSR356WebsocketInitializer.*", // | ||||
"com\\.vaadin\\.screenshotbrowser\\.ScreenshotBrowser.*", // | "com\\.vaadin\\.screenshotbrowser\\.ScreenshotBrowser.*", // | ||||
"com\\.vaadin\\.osgi.*",// | |||||
"com\\.vaadin\\.server\\.osgi.*" | |||||
}; | }; | ||||
/** | /** |
Bundle-SymbolicName: ${project.groupId}.shared | |||||
Bundle-Activator: com.vaadin.osgi.resources.OSGiVaadinResources | |||||
Bundle-Name: Vaadin Shared | |||||
Import-Package: com.vaadin*;version="[${osgi.bundle.version},${osgi.bundle.version}]",\ | |||||
org.osgi* | |||||
Export-Package: com.vaadin.osgi.resources;-noimport:=true,\ | |||||
com.vaadin.shared*;-noimport:=true,\ | |||||
elemental*;-noimport:=true |
<artifactId>gwt-elemental</artifactId> | <artifactId>gwt-elemental</artifactId> | ||||
<scope>provided</scope> | <scope>provided</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
<build> | <build> | ||||
</execution> | </execution> | ||||
</executions> | </executions> | ||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<extensions>true</extensions> | |||||
<configuration> | |||||
<instructions> | |||||
<Bundle-RequiredExecutionEnvironment>${osgi.execution.environment}</Bundle-RequiredExecutionEnvironment> | |||||
<Bundle-Version>${osgi.bundle.version}</Bundle-Version> | |||||
<Export-Package>com.vaadin.*;version="${osgi.bundle.version}",elemental.*;version="${osgi.bundle.version}"</Export-Package> | |||||
<Import-Package></Import-Package> | |||||
<Require-Bundle></Require-Bundle> | |||||
</instructions> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>bundle-manifest</id> | |||||
<phase>prepare-package</phase> | |||||
<goals> | |||||
<goal>manifest</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> | ||||
<artifactId>maven-jar-plugin</artifactId> | <artifactId>maven-jar-plugin</artifactId> |
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.osgi.resources; | |||||
import org.osgi.framework.BundleActivator; | |||||
import org.osgi.framework.BundleContext; | |||||
import org.osgi.framework.Version; | |||||
import com.vaadin.osgi.resources.impl.VaadinResourceServiceImpl; | |||||
/** | |||||
* {@link BundleActivator} used to provide access to the | |||||
* {@link VaadinResourceService} singleton for publishing themes, widgetsets and | |||||
* other necessary resources. | |||||
* | |||||
* @author Vaadin Ltd. | |||||
* | |||||
* @since 8.1 | |||||
*/ | |||||
public class OSGiVaadinResources implements BundleActivator { | |||||
/** | |||||
* Thrown if a method is called when the Resource bundle is not active. | |||||
* | |||||
* @author Vaadin Ltd. | |||||
* | |||||
* @since 8.1 | |||||
*/ | |||||
@SuppressWarnings("serial") | |||||
public static class ResourceBundleInactiveException extends Exception { | |||||
public ResourceBundleInactiveException(String message) { | |||||
super(message); | |||||
} | |||||
} | |||||
private static OSGiVaadinResources instance; | |||||
private VaadinResourceServiceImpl service; | |||||
private Version version; | |||||
/** | |||||
* Returns the {@link VaadinResourceService} instance. Always returns | |||||
* non-null. | |||||
* | |||||
* @return the {@link VaadinResourceService resource service} to use for | |||||
* publishing themes, widgetsets and other necessary resources | |||||
* @throws ResourceBundleInactiveException | |||||
* if the bundle is not active | |||||
*/ | |||||
public static VaadinResourceService getService() | |||||
throws ResourceBundleInactiveException { | |||||
if (instance == null) { | |||||
throw new ResourceBundleInactiveException( | |||||
"Vaadin Shared is not active!"); | |||||
} | |||||
return instance.service; | |||||
} | |||||
@Override | |||||
public void start(BundleContext context) throws Exception { | |||||
version = context.getBundle().getVersion(); | |||||
service = new VaadinResourceServiceImpl(); | |||||
service.setBundleVersion(version.toString()); | |||||
instance = this; | |||||
} | |||||
@Override | |||||
public void stop(BundleContext context) throws Exception { | |||||
instance = null; | |||||
service = null; | |||||
version = null; | |||||
} | |||||
} |
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.osgi.resources; | |||||
import org.osgi.service.http.HttpService; | |||||
import org.osgi.service.http.NamespaceException; | |||||
/** | |||||
* Service used to publish themes, widgetsets and static resources at the root | |||||
* of a versioned namespaced /VAADIN/ folder. | |||||
* | |||||
* @author Vaadin Ltd. | |||||
* | |||||
* @since 8.1 | |||||
*/ | |||||
public interface VaadinResourceService { | |||||
/** | |||||
* Register the theme with the given name under the | |||||
* {@link VaadinResourceService} versioned namespace. The theme folder is | |||||
* expected to be compiled and under "/VAADIN/themes/" in the calling | |||||
* bundle. | |||||
* | |||||
* The theme will become accessible under the url | |||||
* "/vaadin-x.x.x/VAADIN/themes/themeName" where x.x.x is the version of the | |||||
* Vaadin Shared bundle | |||||
* | |||||
* @param themeName | |||||
* the name of the theme | |||||
* @param httpService | |||||
* the {@link HttpService} instance for the calling bundle | |||||
* @throws NamespaceException | |||||
* if there is a clash during the theme registration | |||||
*/ | |||||
void publishTheme(String themeName, HttpService httpService) | |||||
throws NamespaceException; | |||||
/** | |||||
* Register the resource with the given name under the | |||||
* {@link VaadinResourceService} versioned namespace. The resource is | |||||
* expected to be under "/VAADIN/" in the calling bundle. | |||||
* | |||||
* The resource will become accessible under the url "/vaadin-x.x.x/VAADIN/" | |||||
* where x.x.x is the version of the Vaadin Shared bundle | |||||
* | |||||
* @param resourceName | |||||
* the name of the resource | |||||
* @param httpService | |||||
* the {@link HttpService} instance for the calling bundle | |||||
* @throws NamespaceException | |||||
* if there is a clash during the theme registration | |||||
*/ | |||||
void publishResource(String resourceName, HttpService httpService) | |||||
throws NamespaceException; | |||||
/** | |||||
* Register the widgetset with the given name under the | |||||
* {@link VaadinResourceService} versioned namespace. The resource is | |||||
* expected to be under "/VAADIN/widgetsets" in the calling bundle. | |||||
* | |||||
* The resource will become accessible under the url | |||||
* "/vaadin-x.x.x/VAADIN/widgetsets" where x.x.x is the version of the | |||||
* Vaadin Shared bundle | |||||
* | |||||
* @param widgetsetName | |||||
* the name of the resource | |||||
* @param httpService | |||||
* the {@link HttpService} instance for the calling bundle | |||||
* @throws NamespaceException | |||||
* if there is a clash during the theme registration | |||||
*/ | |||||
void publishWidgetset(String widgetsetName, HttpService httpService) | |||||
throws NamespaceException; | |||||
/** | |||||
* Returns the prefix of the versioned namespace for the resources. The | |||||
* result can't be null and is of the format "vaadin-x.x.x" where x.x.x the | |||||
* version of the Vaadin Shared bundle. | |||||
* | |||||
* @return the prefix of the resources folder managed by this service | |||||
*/ | |||||
String getResourcePathPrefix(); | |||||
} |
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.osgi.resources.impl; | |||||
import org.osgi.service.http.HttpService; | |||||
import org.osgi.service.http.NamespaceException; | |||||
import com.vaadin.osgi.resources.VaadinResourceService; | |||||
/** | |||||
* Implementation of {@link VaadinResourceService}. Uses bundle version as a | |||||
* prefix for the /VAADIN/ folder. | |||||
* | |||||
* @author Vaadin Ltd. | |||||
* | |||||
* @since 8.1 | |||||
*/ | |||||
public class VaadinResourceServiceImpl implements VaadinResourceService { | |||||
private static final String NAMESPACE_PREFIX = "vaadin-%s"; | |||||
private static final String VAADIN_ROOT_ALIAS_FORMAT = "/%s/VAADIN/%s"; | |||||
private static final String VAADIN_ROOT_FORMAT = "/VAADIN/%s"; | |||||
private static final String VAADIN_THEME_ALIAS_FORMAT = "/%s/VAADIN/themes/%s"; | |||||
private static final String VAADIN_WIDGETSET_ALIAS_FORMAT = "/%s/VAADIN/widgetsets/%s"; | |||||
private static final String VAADIN_THEME_PATH_FORMAT = "/VAADIN/themes/%s"; | |||||
private static final String VAADIN_WIDGETSET_PATH_FORMAT = "/VAADIN/widgetsets/%s"; | |||||
private String bundleVersion; | |||||
/** | |||||
* Sets the version of the bundle managing this service. | |||||
* | |||||
* <p> | |||||
* This needs to be called before any other method after the service is | |||||
* created. | |||||
* | |||||
* @param bundleVersion | |||||
* the version of the bundle managing this service | |||||
*/ | |||||
public void setBundleVersion(String bundleVersion) { | |||||
this.bundleVersion = bundleVersion; | |||||
} | |||||
@Override | |||||
public void publishTheme(String themeName, HttpService httpService) | |||||
throws NamespaceException { | |||||
doPublish(themeName, VAADIN_THEME_ALIAS_FORMAT, | |||||
VAADIN_THEME_PATH_FORMAT, httpService); | |||||
} | |||||
private void doPublish(String resourceName, String aliasFormat, | |||||
String pathFormat, HttpService httpService) | |||||
throws NamespaceException { | |||||
String bundleVersionPrefix = String.format(NAMESPACE_PREFIX, | |||||
bundleVersion); | |||||
String resourcePath = String.format(pathFormat, resourceName); | |||||
String resourceAlias = String.format(aliasFormat, bundleVersionPrefix, | |||||
resourceName); | |||||
httpService.registerResources(resourceAlias, resourcePath, null); | |||||
} | |||||
@Override | |||||
public void publishResource(String resource, HttpService httpService) | |||||
throws NamespaceException { | |||||
doPublish(resource, VAADIN_ROOT_ALIAS_FORMAT, VAADIN_ROOT_FORMAT, | |||||
httpService); | |||||
} | |||||
@Override | |||||
public void publishWidgetset(String widgetset, HttpService httpService) | |||||
throws NamespaceException { | |||||
doPublish(widgetset, VAADIN_WIDGETSET_ALIAS_FORMAT, | |||||
VAADIN_WIDGETSET_PATH_FORMAT, httpService); | |||||
} | |||||
@Override | |||||
public String getResourcePathPrefix() { | |||||
return String.format(NAMESPACE_PREFIX, bundleVersion); | |||||
} | |||||
} |
Bundle-SymbolicName: ${project.groupId}.themes | |||||
Bundle-Name: Vaadin Themes | |||||
Bundle-Version: ${osgi.bundle.version} | |||||
Import-Package: com.vaadin.*;version='[${osgi.bundle.version},${osgi.bundle.version}]',\ | |||||
* | |||||
Export-Package: com.vaadin.osgi.themes;-noimport:=true |
<artifactId>commons-io</artifactId> | <artifactId>commons-io</artifactId> | ||||
<scope>provided</scope> | <scope>provided</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.core</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.osgi</groupId> | |||||
<artifactId>osgi.cmpn</artifactId> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
<build> | <build> | ||||
</execution> | </execution> | ||||
</executions> | </executions> | ||||
</plugin> | </plugin> | ||||
<plugin> | |||||
<groupId>org.codehaus.mojo</groupId> | |||||
<artifactId>exec-maven-plugin</artifactId> | |||||
<executions> | |||||
<execution> | |||||
<id>generate-export-package</id> | |||||
<phase>package</phase> | |||||
<goals> | |||||
<goal>exec</goal> | |||||
</goals> | |||||
<configuration> | |||||
<classpathScope>compile</classpathScope> | |||||
<executable>${java.home}/bin/java</executable> | |||||
<arguments> | |||||
<argument>-Dvaadin.version=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</argument> | |||||
<argument>-DincludeNumberPackages=0</argument> | |||||
<argument>-classpath</argument> | |||||
<classpath /> | |||||
<argument>com.vaadin.buildhelpers.GeneratePackageExports</argument> | |||||
<argument>${project.build.directory}/${project.build.finalName}.${project.packaging}</argument> | |||||
<argument>VAADIN/themes</argument> | |||||
</arguments> | |||||
</configuration> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | <plugin> | ||||
<groupId>org.apache.felix</groupId> | |||||
<artifactId>maven-bundle-plugin</artifactId> | |||||
<extensions>true</extensions> | |||||
<configuration> | |||||
<instructions> | |||||
<Bundle-Version>${osgi.bundle.version}</Bundle-Version> | |||||
<Bundle-RequiredExecutionEnvironment>${osgi.execution.environment}</Bundle-RequiredExecutionEnvironment> | |||||
<!-- Export package is handled in exec plugin --> | |||||
<Export-Package></Export-Package> | |||||
<Import-Package></Import-Package> | |||||
</instructions> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<id>bundle-manifest</id> | |||||
<phase>prepare-package</phase> | |||||
<goals> | |||||
<goal>manifest</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<groupId>biz.aQute.bnd</groupId> | |||||
<artifactId>bnd-maven-plugin</artifactId> | |||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | <groupId>org.apache.maven.plugins</groupId> | ||||
<artifactId>maven-jar-plugin</artifactId> | <artifactId>maven-jar-plugin</artifactId> |
/* | |||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* | |||||
* 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. | |||||
*/ | |||||
package com.vaadin.osgi.themes; | |||||
import org.osgi.service.component.annotations.Activate; | |||||
import org.osgi.service.component.annotations.Component; | |||||
import org.osgi.service.component.annotations.Reference; | |||||
import org.osgi.service.http.HttpService; | |||||
import com.vaadin.osgi.resources.OSGiVaadinResources; | |||||
import com.vaadin.osgi.resources.VaadinResourceService; | |||||
@Component(immediate = true) | |||||
public class ValoThemeContribution { | |||||
private HttpService httpService; | |||||
@Activate | |||||
void startup() throws Exception { | |||||
VaadinResourceService service = OSGiVaadinResources.getService(); | |||||
service.publishTheme("valo", httpService); | |||||
} | |||||
@Reference | |||||
void setHttpService(HttpService httpService) { | |||||
this.httpService = httpService; | |||||
} | |||||
void unsetHttpService(HttpService httpService) { | |||||
this.httpService = null; | |||||
} | |||||
} |