Hi,
I'm trying to compile OSGI bundle as EAR file in Netbeans 7.0.1. This is the main POM file:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.core.dx</groupId> <artifactId>TESTOSGI</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <build> <finalName>${project.artifactId}</finalName> <pluginManagement> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.1.0</version> <extensions>true</extensions> <configuration> <supportedProjectTypes> <supportedProjectType>ejb</supportedProjectType> <supportedProjectType>war</supportedProjectType> <supportedProjectType>bundle</supportedProjectType> <supportedProjectType>jar</supportedProjectType> </supportedProjectTypes> <instructions> <!-- Read all OSGi configuration info from this optional file --> <_include>-osgi.properties</_include> <!-- By default, we don't export anything --> <Export-Package>!*.impl.*, *</Export-Package> </instructions> </configuration> <executions> <execution> <id>bundle-manifest</id> <phase>process-classes</phase> <goals> <goal>manifest</goal> </goals> </execution> <execution> <id>bundle-install</id> <phase>install</phase> <goals> <goal>install</goal> </goals> </execution> </executions> </plugin> <plugin> <!-- Need to use this plugin to build war files --> <artifactId>maven-war-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId> <!-- Use version 2.1-beta-1, as it supports the new property failOnMissingWebXml --> <version>2.1-beta-1</version> <configuration> <archive> <!-- add bundle plugin generated manifest to the war --> <manifestFile> ${project.build.outputDirectory}/META-INF/MANIFEST.MF </manifestFile> <!-- For some reason, adding Bundle-ClassPath in maven-bundle-plugin confuses that plugin and it generates wrong Import-Package, etc. So, we generate it here. --> <manifestEntries> <Bundle-ClassPath>WEB-INF/classes/ </Bundle-ClassPath> </manifestEntries> </archive> <!-- We don't have a web.xml --> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <!-- add bundle plugin generated manifest to the jar --> <manifestFile> ${project.build.outputDirectory}/META-INF/MANIFEST.MF </manifestFile> </archive> </configuration> </plugin> <plugin> <!-- Need to use this plugin to build ejb-jar files --> <artifactId>maven-ejb-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId> <!-- Use version 2.1-beta-1, as it supports the new property failOnMissingWebXml --> <version>2.1</version> <configuration> <configuration> <ejbVersion>3.1</ejbVersion> </configuration> <archive> <!-- add bundle plugin generated manifest to the war --> <manifestFile> ${project.build.outputDirectory}/META-INF/MANIFEST.MF </manifestFile> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <!-- Enable this plugin for all modules --> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> <dependencyManagement> <dependencies> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> <version>4.2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> <version>4.2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> </dependencies> </dependencyManagement> <modules> <module>OSGI_Module</module> </modules> </project>
This is the POM file of the OSGI bundle:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>DX_57</artifactId> <groupId>com.core.dx</groupId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.core.dx</groupId> <artifactId>OSGI_Module</artifactId> <version>1.0-SNAPSHOT</version> <packaging>bundle</packaging> <name>OSGI_Module OSGi Bundle</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.osgi.core</artifactId> <version>1.4.0</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.2.0</version> <extensions>true</extensions> <configuration> <instructions> <Bundle-Activator>com.core.dx.osgi_module.Activator</Bundle-Activator> </instructions> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>build-for-felix</id> <dependencies> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.main</artifactId> <version>3.0.7</version> <scope>provided</scope> </dependency> <!-- To include a shell: <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.gogo.shell</artifactId> <version>0.6.1</version> </dependency> --> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <id>compile</id> <phase>package</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <pathconvert property="plugins.jars" pathsep="${path.separator}"> <path refid="maven.runtime.classpath" /> <map from="${project.build.directory}${file.separator}classes" to="" /> </pathconvert> <pathconvert pathsep=" " property="bundles"> <path path="${plugins.jars}" /> <mapper> <chainedmapper> <flattenmapper /> <globmapper from="*" to="file:modules/*" casesensitive="no" /> </chainedmapper> </mapper> </pathconvert> <propertyfile file="${project.build.directory}/config.properties"> <entry key="felix.auto.start" value="${bundles} file:modules/${project.build.finalName}.jar" /> <entry key="org.osgi.framework.bootdelegation" value="*" /> </propertyfile> <copy file="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}" tofile="${project.build.directory}/felix.jar" /> </target> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.2</version> <executions> <execution> <id>create-executable-jar</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptors> <descriptor>${basedir}/src/main/assembly/felix.xml</descriptor> </descriptors> <finalName>${project.build.finalName}</finalName> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>run-on-felix</id> <dependencies> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.main</artifactId> <version>3.0.7</version> <scope>provided</scope> </dependency> <!-- org.apache.felix:org.apache.felix.gogo.shell:0.6.1 useless from Maven since stdin is swallowed --> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <configuration> <target> <property name="vm.args" value="" /> <pathconvert property="plugins.jars" pathsep="${path.separator}"> <path refid="maven.runtime.classpath" /> <map from="${project.build.directory}${file.separator}classes" to="" /> </pathconvert> <makeurl property="urls" separator=" "> <path path="${plugins.jars}" /> <path location="${project.build.directory}/${project.build.finalName}.jar" /> </makeurl> <propertyfile file="${project.build.directory}/run.properties"> <entry key="felix.auto.start" value="${urls}" /> <entry key="felix.auto.deploy.action" value="uninstall,install,update,start" /> <entry key="org.osgi.framework.storage" value="${project.build.directory}${file.separator}felix-cache" /> <entry key="org.osgi.framework.bootdelegation" value="*" /> </propertyfile> <makeurl property="run.properties.url" file="${project.build.directory}/run.properties" /> <java fork="true" jar="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}"> <sysproperty key="felix.config.properties" value="${run.properties.url}" /> <jvmarg line="${vm.args}" /> </java> </target> </configuration> </plugin> </plugins> </build> </profile> </profiles> </project>
When I build the files the out put OSGI file is .jar file. How I can compile the OSGI bundle as .EAR file
Regards
Peter