我正在構建自定義標籤,我希望它可以作爲單個jar文件提供。我似乎遇到了tld文件的問題,以及如何將它包含到構建過程中。什麼是在Maven項目中TLD文件的正確/推薦位置
我目前的文件夾結構:pom.xml中的
src
license.md
main
java
my.package
class1.java
class2.java
resources
META-INF
customtag.tld
部分(.tld
文件不包含到默認的構建過程)
<resources>
<resource>
<directory>${basedir}/src/main/resources/META-INF</directory>
<targetPath>META-INF</targetPath>
<filtering>true</filtering>
<includes>
<include>customtag.tld</include>
</includes>
</resource>
上述作品,但:
- 它對我來說看起來不太好,尤其是目錄的路徑
- 在NetBeans中,額外分支是在「項目」視圖中創建的。不用說這真的看起來很糟糕。
- 我需要在pom.xml中的條目,因爲否則.tld文件將不會包含在jar中。
第一個問題: 是否有Maven的一些設置,其中將包括默認${basedir}/src/main/resources/META-INF
文件夾的內容?
替代做法:pom.xml中的
src
license.md
ckeditor.tld
main
java
my.package
class1.java
class2.java
部分(.tld
文件不包含到默認的構建過程)
<resource>
<directory>${basedir}</directory>
<targetPath>META-INF</targetPath>
<filtering>true</filtering>
<includes>
<include>customtag.tld</include>
</includes>
</resource>
這種做法有pom.xml
沒有長路徑,在Netbeans p中沒有創建額外的分支roject視圖,但我不確定該位置是否正確。我找到了很多這樣的鏈接,如Where do I put the .tld file so that the resulting JAR file built with maven2 is properly packaged?,其中說項目代碼中的tld文件應該放入src/main/resources/META-INF
。
第二個問題: 什麼是.tld
文件Maven項目內的正確/推薦位置?請注意,我詢問項目的位置,而不是在創建的jar文件中的位置(它必須是META-INF
,我知道)。