我对WSO2 ESB有另一个问题。我已经创建了一些Maven项目。该项目包含在WSO2的Java库项目中。在库项目中,我在pom.xml中设置了maven-bundle-plugin。它通过Maven构建正确地创建了MANIFEST,但是将项目导出为可部署档案库创建的MANIFEST.md具有旧属性(我认为,通过Eclipse创建新项目后,MANIFEST具有属性(未更改SymbolicName,无导入)。
Maven项目带有捆绑POM.xml的类
<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.coig.esb.osgi</groupId>
<artifactId>emf</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>emf</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</project>
然后将上述项目中的jar文件从WSO2导入Java库项目中。
Java库项目POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.coig.esb.osgi.emf.EMFService</groupId>
<artifactId>EMFService</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>
<name>EMFService</name>
<description>EMFService</description>
<properties>
<CApp.type>lib/library/bundle</CApp.type>
</properties>
<dependencies>
<dependency>
<groupId>com.coig.esb.osgi</groupId>
<artifactId>emf</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<id>wso2-nexus</id>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
</repository>
<repository>
<id>wso2-maven2-repository-1</id>
<url>http://dist.wso2.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<id>wso2-nexus</id>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
</pluginRepository>
<pluginRepository>
<id>wso2-maven2-repository-1</id>
<url>http://dist.wso2.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>com.coig.osgi.emf.providerservice</Bundle-SymbolicName>
<Bundle-Name>EMFService</Bundle-Name>
<Export-Package>com.coig.esb.osgi.emf,com.coig.esb.osgi.emf</Export-Package>
<DynamicImport-Package>*</DynamicImport-Package>
<Embed-Dependency>emf</Embed-Dependency>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<buildcommands />
<projectnatures>
<projectnature>org.wso2.developerstudio.eclipse.library.project.nature</projectnature>
</projectnatures>
</configuration>
</plugin>
</plugins>
</build>
</project>
MANIFEST.md来自导出
Manifest-Version: 1.0
Bundle-SymbolicName: EMFService
Bundle-Name: EMFService
Bundle-Version: 1.0.0
Bundle-Description: EMFService
Export-Package: com.coig.esb.osgi.emf,
com.coig.esb.osgi.emf
DynamicImport-Package: *
Maven版本中的MANIFEST.md
Manifest-Version: 1.0
Bundle-Description: EMFService
Bundle-SymbolicName: com.coig.osgi.emf.providerservice
Built-By: author
Bundle-ManifestVersion: 2
Bnd-LastModified: 1532429067922
Embed-Dependency: emf
Import-Package: javax.persistence;version="[2.2,3)"
DynamicImport-Package: *
Tool: Bnd-1.15.0
Export-Package: com.coig.esb.osgi.emf;uses:="javax.persistence",com.co
ig.esb.osgi.emf
Bundle-Version: 1.0.0
Bundle-Name: EMFService
Bundle-ClassPath: .,emf-1.0.0.jar
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.8.0_172
当我创建Mediator项目时,将maven-bunlde-plugin设置为导入我之前提到的模块,情况相同。 Maven构建会创建正确的MANIFEST.md,但是将项目导出为可部署存档会创建具有不变属性的MANIFEST.md。
您能给我一些备注吗,应该如何设置?
答案 0 :(得分:0)
类似“将项目导出为可部署的存档”之类的文件不支持MANIFEST.MF中的Import-Package标头。该文件由MediatorExportHandler类构建,该类忽略此标头。
IJavaProject javaProject = JavaCore.create(project);
List<String> exportPac =getExportPackages(javaProject);
BundleManifest manifest = new BundleManifest();
manifest.setBundleName(project.getName());
manifest.setBundleSymbolicName(project.getName());
manifest.setBundleDescription(project.getName());
manifest.setBundleVersion("2.0");
manifest.setExportPackagesList(exportPac);
[...]
File manifestFile=new File(metainfPath,"MANIFEST.MF");
FileUtils.createFile(manifestFile, manifest.toString());