<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<generateClient>true</generateClient>
</configuration>
</plugin>
This can be dependend-upon from other projects:
<dependency>
<groupid>com.shopzilla.ca.bidding.impl.google</groupid>
<artifactid>ejbs</artifactid>
<type>ejb-client</type>
</dependency>
Unfortunately, it often includes many classes / resources that you don't want to provide to the client. The default excludes get rid of some stuff. In my case, I had a beanRefContext.xml Spring config file in there that broke clients (since it referred to other Spring xml files that are in a server-side jar).
Supposedly you can add <clientexcludes> elements:
<clientexcludes>
<clientexclude>beanRefContext.xml</clientexclude>
<clientexclude>META-INF/ejb-jar.xml</clientexclude>
<clientexclude>META-INF/jboss.xml</clientexclude>
<clientexclude>**/mdb/</clientexclude>
</clientexcludes>
Sadly, that doesn't work with Maven 2.0.4 due to a bug in the ejb plugin: http://jira.codehaus.org/browse/MEJB-19
My workaround was to add an Ant task that rather heavy-handedly simulated this by unzipping the client jar and re-zipping with the exlcuded files. here it is:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Manually strip client files since clientExcludes doesn't work on ejb plugin -->
<tasks>
<property name="ejb-client-excludes-list" value="beanRefContext.xml, META-INF/ejb-jar.xml, META-INF/jboss.xml, **/mdb/" />
<echo>Manually excluding from ejb client jar: ${ejb-client-excludes-list}</echo>
<property name="ejb-client-expanded.dir" value="${project.build.directory}/tmpClient" />
<property name="ejb-client-artifact-name"
value="${project.build.directory}/${project.artifactId}-${project.version}-client.jar" />
<delete dir="${ejb-client-expanded.dir}" />
<unzip src="${ejb-client-artifact-name}" dest="${ejb-client-expanded.dir}" />
<delete file="${ejb-client-artifact-name}" />
<zip destfile="${ejb-client-artifact-name}" basedir="${ejb-client-expanded.dir}"
excludes="${ejb-client-excludes-list}" />
</tasks>
</configuration>
</plugin>
No comments:
Post a Comment