Anderson
Anderson

Reputation: 1200

Issue with creating custom tag library using OSGI bundle

I am trying to create custom tag libs by using OSGI bundles in cq. Actually i created all the necessary files but i could not place my mytags.tld file under META-INF folder in build time. For that i used maven-bundle-plugin plugin. Here is my code to include the resource in META-INF folder

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <Include-Resource>META-INF/myTags.tld=target/classes/META-INF/myTags.tld</Include-Resource>
        </instructions>
        <Export-Package>com.mine.*</Export-Package>
        <Import-Package>*;resolution:=optional</Import-Package> 
        <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>                   
    </configuration>
</plugin>

Note: i have placed my tag file under "src\main\resources\META-INF\myTags"

I have used <Include-Resource> to include my tld file. But i could see my tld file under META-INF folder after jar file is created.

Here is my build error

[ERROR] Bundle com.mine-bundle:bundle:1.0-SNAPSHOT : Input file does not exist: target/classes/META-INF/myTags.tld

Could you anyone tell what could be the problem?

Upvotes: 1

Views: 2619

Answers (2)

Hazel T
Hazel T

Reputation: 949

I had this issue in IntelliJ if there was no src/main/resources folder. Adding a dummy properties file to that location fixed it.

Upvotes: 0

Tomek Rękawek
Tomek Rękawek

Reputation: 9304

I think the <Include-Resource> parameter is redundant. If you don't specify it, maven-bundle-plugin will include all resources from src/main/resources to the output JAR, as the official doc says:

By default the bundle plugin converts the project's Maven resource directories into a single instruction. If you specify your own instruction, this will replace the generated one.

So if you have TLD file placed in src/main/resources/META-INF, it should be included without additional options.

Upvotes: 0

Related Questions