如何从MAven生成的OSGI包中排除GWT依赖代码+;BND?
我在根pom.xml文件中有几个Maven模块与Vaadin库相关 我正在尝试使用Maven+BND构建一组OSGI捆绑包(每个Maven模块1个) 我将其添加到我的“root”pom.xml文件中:如何从MAven生成的OSGI包中排除GWT依赖代码+;BND?,maven,osgi,vaadin,Maven,Osgi,Vaadin,我在根pom.xml文件中有几个Maven模块与Vaadin库相关 我正在尝试使用Maven+BND构建一组OSGI捆绑包(每个Maven模块1个) 我将其添加到我的“root”pom.xml文件中: <dependencies> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin</artifactId>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin</artifactId>
<version>6.6.6</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
com.vaadin
瓦丁
6.6.6
com.google.gwt
gwt用户
2.3.0
org.apache.felix
org.osgi.core
1.0.0
不幸的是,生成的JAR文件(bundle)包括GWT(com.google.GWT)类。这
1) 使捆绑包变得巨大,具有大量重复的依赖项。
2) 生成了数千个关于“拆分包”的生成警告
问题:如何防止将GWT类添加到我的Jar文件中
我尝试将GWT的“scope”设置为“provided”,将“type”设置为“bundle”,甚至optional=true——都没有帮助
下面是我的根pom.xml的一部分,它负责Vaadin/GWT内容:
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.5</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>mycompany.*</Export-Package>
<Private-Package>*.impl.*</Private-Package>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<!-- <Bundle-Activator>com.alskor.publicpackage.MyActivator</Bundle-Activator>-->
</instructions>
</configuration>
</plugin>
<!-- Compiles your custom GWT components with the GWT compiler -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<!-- Version 2.1.0-1 works at least with Vaadin 6.5 -->
<version>2.3.0-1</version>
<configuration>
<!-- if you don't specify any modules, the plugin will find them -->
<!--modules>
..
</modules-->
<webappDirectory>${project.build.directory}/${project.build.finalName}/VAADIN/widgetsets
</webappDirectory>
<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
<runTarget>clean</runTarget>
<hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>
<noServer>true</noServer>
<port>8080</port>
</configuration>
<executions>
<execution>
<goals>
<goal>resources</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Updates Vaadin 6.2+ widgetset definitions based on project dependencies -->
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<configuration>
<!-- if you don't specify any modules, the plugin will find them -->
<!--
<modules>
<module>${package}.gwt.MyWidgetSet</module>
</modules>
-->
</configuration>
<goals>
<goal>update-widgetset</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
org.apache.felix
maven捆绑插件
2.3.5
真的
我的公司*
*.impl*
${project.artifactId}
org.codehaus.mojo
GWTMaven插件
2.3.0-1
${project.build.directory}/${project.build.finalName}/VAADIN/widgetsets
-Xmx512M-Xss1024k
清洁的
${project.build.directory}/${project.build.finalName}
真的
8080
资源
编译
com.vaadin
vaadin maven插件
1.0.1
更新WidgeSet
的
元素添加到相关的依赖项以抑制它
的
元素添加到相关的依赖项以抑制它我觉得导出包和私有包语句中的通配符非常危险。GWT包可能因为私有包中的
*.impl.*
模式而被拖入
此外,您不应该在导出包中使用通配符:导出应该受到严格控制和版本控制。您的导出包和私有包语句中的通配符让我觉得非常危险。GWT包可能因为私有包中的
*.impl.*
模式而被拖入
此外,您永远不应该在导出包中使用通配符:导出应该严格控制和版本控制。我也遇到过类似的问题,因为最终的war文件超过了近90MB! 其中一个罪犯就是上面提到的罐子,所以我这样做了:
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>widgetset</artifactId>
<version>3.2</version>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.gwt</groupId>
<artifactId>gwt-user</artifactId>
</exclusion>
</exclusions>
</dependency>
...
</dependencies>
${project.groupId}
widgetset
3.2
com.vaadin.external.gwt
gwt用户
...
我也遇到过类似的问题,因为最终的war文件超过了近90MB!
其中一个罪犯就是上面提到的罐子,所以我这样做了:
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>widgetset</artifactId>
<version>3.2</version>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.gwt</groupId>
<artifactId>gwt-user</artifactId>
</exclusion>
</exclusions>
</dependency>
...
</dependencies>
${project.groupId}
widgetset
3.2
com.vaadin.external.gwt
gwt用户
...
这是否意味着我不能在根文件中定义这个“mycompany.*”模式,并且必须在每个模块中都有一些BND配置文件?另外,出于某些原因,我希望依赖项“type=bundle”不包含在构建的JAR文件中,但我在这里肯定错了。当我将Maven依赖项设置为“bundle”时,我看不到对打包的影响。这可能会影响BND从依赖项加载文件的方式,我不知道…在回答您的第一个问题时…这是一个有争议的问题。在我看来,导出包非常重要,应该始终以明确和受控的方式完成。请记住,这些是您提供给消费者的API,因此需要进行维护、版本控制等。私有包不太重要,因为它们是私有的,但这里的通配符仍然是错误的来源。请仔细阅读有关使用这些说明的Maven Bundle插件文档!谢谢,尼尔。我现在有另一个问题,可能应该作为一个单独的问题发布:我可以启动Equinox服务器并访问localhost:8080,但我的Vaadin应用程序不可访问(404)。我发现我的webui.jar包不包含任何Vaadin资源(图标/主题)。它只有类和manifest.mf。如何使用Maven+BND将这些资源添加到包中?我正在使用标准的Vaadin项目布局:WebContent/META-INF WebContent/Vaadin WebContent/WEB-INF pom.xml我尝试使用包含资源:WebContent/Vaadin
将“bnd.bnd”文件添加到模块中-没有更改我将“WebContent”添加到webui模块pom.xml中作为实验。现在资源被添加到jar中(除了Vaadin widgetsets),但是捆绑包无法启动:来自“webui”的同一个包被添加到manifest.mf中的“export”和“import”列表中。另一个问题是否意味着我不能在根文件中定义这个“mycompany.*”模式,并且必须有一些BND配置