Maven捆绑包装问题,称为MNG-4338

sae*_*nra 6 apache packaging bundle maven

我在使用maven-bundle-plugin时遇到问题:

我想将我的项目部署为osgi包,因此我将包装用作包.但似乎pom并不知道包装是一种包装.在这里你可以看到我的pom.xml:

<project ...>...
    <packaging>bundle</packaging>
<version>1.0.0</version>

<name>Simple CXF project using spring configuration</name>

<properties>
    <cxf-version>2.4.2</cxf-version>
</properties>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <version>2.3.5</version>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.name}</Bundle-Name>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Export-Package>demo.hw.server</Export-Package>
                        <Bundle-Activator>demo.hw.server.Activator</Bundle-Activator>
                        <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<dependencies>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>1.4.0</version>
    </dependency>
</dependencies>

</project>
Run Code Online (Sandbox Code Playgroud)

他们说,这个bug已经修复了(http://jira.codehaus.org/browse/MNG-4338),但对我来说似乎没有.有没有人遇到过这个问题,并找到了解决方案?

错误消息是这样的:

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.talend.liugang.cxf:java_first_jaxws:1.0.0 (C:\Users\Andreas\workspace\java_first_jaxws\pom.xml) has 1 error
[ERROR]     Unknown packaging: bundle @ line 7, column 13
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Run Code Online (Sandbox Code Playgroud)

最好的问候,saen

Pau*_*ant 14

鉴于上面的pom示例,您应该将maven-bundle-plugin移动到<pluginManagement>节点之外.<pluginManagement>通常用于父poms中的继承目的.捆绑包装类型由maven-bundle-plugin提供(这就是您需要的原因<extensions>true</extensions>),因此<pluginManagement>在这种情况下,此插件必须在外面.

<project ...>...
    <packaging>bundle</packaging>
    <version>1.0.0</version>

    <name>Simple CXF project using spring configuration</name>

    <properties>
        <cxf-version>2.4.2</cxf-version>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <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>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <version>2.3.5</version>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.name}</Bundle-Name>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Export-Package>demo.hw.server</Export-Package>
                        <Bundle-Activator>demo.hw.server.Activator</Bundle-Activator>
                        <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>1.4.0</version>
        </dependency>
    </dependencies>

</project>
Run Code Online (Sandbox Code Playgroud)

  • 有类似的问题; 我错过了<extensions> true </ extensions>位.谢谢! (9认同)