#57857 Based on the Apache Tika OSGi bundle and tests, start on a maven-powered build and test for a POI bundle
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1675989 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d46e76b8a1
commit
5fc4bd3f48
@ -1593,6 +1593,14 @@ under the License.
|
|||||||
<echo>Use ${dist.dir}/multisign.sh to create md5 checksums and GPG signatures</echo>
|
<echo>Use ${dist.dir}/multisign.sh to create md5 checksums and GPG signatures</echo>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="osgi" depends="mvn-install">
|
||||||
|
<echo message="Building OSGi bundle via Maven" />
|
||||||
|
<mvn:mvn pom="osgi/build.xml">
|
||||||
|
<arg value="-Dpoi.version=${version.id}" />
|
||||||
|
<arg value="install" />
|
||||||
|
</mvn:mvn>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="dist" depends="clean, compile-all, test-all, site, jar, release-notes, assemble"
|
<target name="dist" depends="clean, compile-all, test-all, site, jar, release-notes, assemble"
|
||||||
description="Creates the entire distribution into build/dist, from scratch">
|
description="Creates the entire distribution into build/dist, from scratch">
|
||||||
</target>
|
</target>
|
||||||
|
226
osgi/pom.xml
Normal file
226
osgi/pom.xml
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<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/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache</groupId>
|
||||||
|
<artifactId>apache</artifactId>
|
||||||
|
<version>10</version>
|
||||||
|
<relativePath />
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-bundle</artifactId>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
<name>Apache POI OSGi bundle</name>
|
||||||
|
<description>
|
||||||
|
OSGi bundle that contains Apache POI, and the dependencies.
|
||||||
|
</description>
|
||||||
|
<url>http://poi.apache.org/</url>
|
||||||
|
<version>${poi.version}</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>1.6</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.6</maven.compiler.target>
|
||||||
|
<pax.exam.version>4.4.0</pax.exam.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>${poi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>poi-scratchpad</artifactId>
|
||||||
|
<version>${poi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>${poi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Test dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.12</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ops4j.pax.exam</groupId>
|
||||||
|
<artifactId>pax-exam-junit4</artifactId>
|
||||||
|
<version>${pax.exam.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ops4j.pax.exam</groupId>
|
||||||
|
<artifactId>pax-exam-container-native</artifactId>
|
||||||
|
<version>${pax.exam.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>org.apache.felix.framework</artifactId>
|
||||||
|
<version>4.6.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ops4j.pax.exam</groupId>
|
||||||
|
<artifactId>pax-exam-link-assembly</artifactId>
|
||||||
|
<version>${pax.exam.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ops4j.pax.url</groupId>
|
||||||
|
<artifactId>pax-url-aether</artifactId>
|
||||||
|
<version>2.3.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.inject</groupId>
|
||||||
|
<artifactId>javax.inject</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.osgi</groupId>
|
||||||
|
<artifactId>org.osgi.core</artifactId>
|
||||||
|
<version>5.0.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-Activator>
|
||||||
|
org.apache.poi.osgi.Activator
|
||||||
|
</Bundle-Activator>
|
||||||
|
<Embed-Dependency>
|
||||||
|
poi;inline=true,
|
||||||
|
poi-scratchpad;inline=true,
|
||||||
|
poi-ooxml;inline=true,
|
||||||
|
poi-ooxml-schemas,
|
||||||
|
xmlbeans
|
||||||
|
</Embed-Dependency>
|
||||||
|
<Embed-Transitive>true</Embed-Transitive>
|
||||||
|
<Bundle-DocURL>${project.url}</Bundle-DocURL>
|
||||||
|
<Export-Package>
|
||||||
|
org.apache.poi.*
|
||||||
|
</Export-Package>
|
||||||
|
<!--
|
||||||
|
<Import-Package>
|
||||||
|
!org.junit,
|
||||||
|
*,
|
||||||
|
org.apache.xmlbeans.impl.xpath.saxon;resolution:=optional,
|
||||||
|
org.apache.xmlbeans.impl.xquery.saxon;resolution:=optional,
|
||||||
|
org.bouncycastle.cert;resolution:=optional,
|
||||||
|
org.bouncycastle.cert.ocsp;resolution:=optional,
|
||||||
|
org.bouncycastle.cms.bc;resolution:=optional,
|
||||||
|
org.bouncycastle.operator;resolution:=optional,
|
||||||
|
org.bouncycastle.operator.bc;resolution:=optional,
|
||||||
|
org.bouncycastle.tsp;resolution:=optional,
|
||||||
|
org.openxmlformats.schemas.officeDocument.x2006.math;resolution:=optional,
|
||||||
|
org.openxmlformats.schemas.schemaLibrary.x2006.main;resolution:=optional,
|
||||||
|
schemasMicrosoftComOfficePowerpoint;resolution:=optional,
|
||||||
|
schemasMicrosoftComOfficeWord;resolution:=optional,
|
||||||
|
</Import-Package>
|
||||||
|
-->
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.2</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${maven.compiler.source}</source>
|
||||||
|
<target>${maven.compiler.target}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>java6</id>
|
||||||
|
<activation>
|
||||||
|
<jdk>[1.6,)</jdk>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<descriptor>test-bundles.xml</descriptor>
|
||||||
|
<finalName>test</finalName>
|
||||||
|
<attach>false</attach>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>2.10</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<org.ops4j.pax.logging.DefaultServiceLog.level>
|
||||||
|
WARN
|
||||||
|
</org.ops4j.pax.logging.DefaultServiceLog.level>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<organization>
|
||||||
|
<name>The Apache Software Founation</name>
|
||||||
|
<url>http://www.apache.org</url>
|
||||||
|
</organization>
|
||||||
|
<scm>
|
||||||
|
<url>http://svn.apache.org/viewvc/poi/trunk/osgi</url>
|
||||||
|
<connection>scm:svn:http://svn.apache.org/repos/asf/poi/trunk/osgi</connection>
|
||||||
|
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/poi/trunk/osgi</developerConnection>
|
||||||
|
</scm>
|
||||||
|
</project>
|
84
osgi/src/test/java/org/apache/poi/osgi/TestOSGiBundle.java
Normal file
84
osgi/src/test/java/org/apache/poi/osgi/TestOSGiBundle.java
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You 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 org.apache.poi.osgi;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.ops4j.pax.exam.CoreOptions.bundle;
|
||||||
|
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
|
||||||
|
import static org.ops4j.pax.exam.CoreOptions.options;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.ops4j.pax.exam.Configuration;
|
||||||
|
import org.ops4j.pax.exam.Option;
|
||||||
|
import org.ops4j.pax.exam.junit.PaxExam;
|
||||||
|
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
|
||||||
|
import org.ops4j.pax.exam.spi.reactors.PerMethod;
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
import org.osgi.framework.ServiceReference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test to ensure that all our main formats can create, write
|
||||||
|
* and read back in, when running under OSGi
|
||||||
|
*/
|
||||||
|
@RunWith(PaxExam.class)
|
||||||
|
@ExamReactorStrategy(PerMethod.class)
|
||||||
|
public class TestOSGiBundle {
|
||||||
|
|
||||||
|
private final File TARGET = new File("target");
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BundleContext bc;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public Option[] configuration() throws IOException, URISyntaxException {
|
||||||
|
File base = new File(TARGET, "test-bundles");
|
||||||
|
return options(
|
||||||
|
junitBundles(),
|
||||||
|
bundle(new File(base, "poi-bundle.jar").toURI().toURL().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHSSF() throws Exception {
|
||||||
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
HSSFSheet s = wb.createSheet("OSGi");
|
||||||
|
s.createRow(0).createCell(0).setCellValue("With OSGi");
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
wb.write(baos);
|
||||||
|
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||||
|
|
||||||
|
wb = new HSSFWorkbook(bais);
|
||||||
|
assertEquals(1, wb.getNumberOfSheets());
|
||||||
|
|
||||||
|
s = wb.getSheet("OSGi");
|
||||||
|
assertEquals("With OSGi", s.getRow(0).getCell(0).toString());
|
||||||
|
}
|
||||||
|
}
|
34
osgi/test-bundles.xml
Normal file
34
osgi/test-bundles.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You 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.
|
||||||
|
-->
|
||||||
|
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||||
|
<id>bundles</id>
|
||||||
|
<formats>
|
||||||
|
<format>dir</format>
|
||||||
|
</formats>
|
||||||
|
<includeBaseDirectory>false</includeBaseDirectory>
|
||||||
|
<dependencySets>
|
||||||
|
<dependencySet>
|
||||||
|
<outputDirectory/>
|
||||||
|
<outputFileNameMapping>${artifact.artifactId}.jar</outputFileNameMapping>
|
||||||
|
<includes>
|
||||||
|
<include>org.apache.poi:poi-bundle</include>
|
||||||
|
</includes>
|
||||||
|
</dependencySet>
|
||||||
|
</dependencySets>
|
||||||
|
</assembly>
|
Loading…
Reference in New Issue
Block a user