简体   繁体   中英

maven-bundle-plugin doesn't include Import-Package

I have parent pom where my child pom locates like a module.

In my child bundle's pom I have something like that

<plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>3.0.1</version>
                    <configuration>
                        <instructions>
                            <Bundle-SymbolicName>...</Bundle-SymbolicName>
                            <Bundle-Description>...</Bundle-Description>
                            <Bundle-Activator>...</Bundle-Activator>
                            <Import-Package>
                                oracle.sql,
                                oracle.jdbc,
                                javax.jws,
                                javax.jws.soap,
                                javax.xml.bind,
                                javax.xml.bind.annotation,
                                javax.xml.namespace,
                                javax.xml.ws,
                                *
                            </Import-Package>
                            <Export-Package>
                            </Export-Package>
                        </instructions>
                    </configuration>
</plugin>

But in the Manifest I get something like that

javax.jws,
javax.jws.soap,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.bind.annotation.adapters,
javax.xml.datatype,
javax.xml.namespace

but I haven't got my oracle.sql and oracle.jdbc.

It happens when I make mvn clean install from the parent folder. If I make mvn clean install in the directory where my child pom locates, everything OK. But question happened after I saw that Jenkin`s build didn't include oracle's packages.

There is interesting in that case, I have other modules which include *oracle's** packages too and after building their manifest has it.

Please add the following dependency in pom.xml in dependencies section.

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc14</artifactId>
    <version>10.2.0.4.0</version>
</dependency>

After that you can check.

I found my error. I have that plugin inside but Jenkins creates bundles without any Profile so, it generated without my Import-Package.

It looks like

<profiles>
    <profile>
        <id>My-Own-Profile</id>
            <build>
             <plugins>
                <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>...</Bundle-SymbolicName>
                        <Bundle-Description>...</Bundle-Description>
                        <Bundle-Activator>...</Bundle-Activator>
                        <Import-Package>
                            oracle.sql,
                            oracle.jdbc,
                            javax.jws,
                            javax.jws.soap,
                            javax.xml.bind,
                            javax.xml.bind.annotation,
                            javax.xml.namespace,
                            javax.xml.ws,
                            *
                        </Import-Package>
                        <Export-Package>
                        </Export-Package>
                    </instructions>
                </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

But I should make it like

<profiles>
    <profile>
        <id>My-Own-Profile</id>
            <build>
             <plugins>
                <plugin>
                  **SOME PLUGIN FOR THAT PROFILE**
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
           <build>
             <plugins>
                <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>...</Bundle-SymbolicName>
                        <Bundle-Description>...</Bundle-Description>
                        <Bundle-Activator>...</Bundle-Activator>
                        <Import-Package>
                            oracle.sql,
                            oracle.jdbc,
                            javax.jws,
                            javax.jws.soap,
                            javax.xml.bind,
                            javax.xml.bind.annotation,
                            javax.xml.namespace,
                            javax.xml.ws,
                            *
                        </Import-Package>
                        <Export-Package>
                        </Export-Package>
                    </instructions>
                </configuration>
                </plugin>
            </plugins>
        </build>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM