WSO2和创建可部署的归档文件从Maven获取旧属性
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WSO2和创建可部署的归档文件从Maven获取旧属性相关的知识,希望对你有一定的参考价值。
我对WSO2 ESB有另一个问题。我创建了一些Maven项目。该项目包含在WSO2的Java Library Project中。在库项目中,我在pom.xml中设置了maven-bundle-plugin。它通过Maven构建正确创建MANIFEST,但Export Project as Deployable Archive使用旧属性创建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 Library Project。
Java Library Project 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>
来自Export的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 build的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,但Export Project as Deployable Archive创建具有未更改属性的MANIFEST.md。
你能给我一些评论,应该如何设定?
看起来“将项目导出为可部署存档”不支持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());
以上是关于WSO2和创建可部署的归档文件从Maven获取旧属性的主要内容,如果未能解决你的问题,请参考以下文章