I’m building custom tag which I want make available as single jar file. I seem to be having a problem with tld file and how to include it into build process.
My current folder structure:
src
license.md
main
java
my.package
class1.java
class2.java
resources
META-INF
customtag.tld
Part of pom.xml (.tld
file is not included into build process by default)
<resources>
<resource>
<directory>${basedir}/src/main/resources/META-INF</directory>
<targetPath>META-INF</targetPath>
<filtering>true</filtering>
<includes>
<include>customtag.tld</include>
</includes>
</resource>
The above works but:
First Question:
Is there some setting in Maven which will include ${basedir}/src/main/resources/META-INF
folder contents by default?
Alternative approach:
src
license.md
ckeditor.tld
main
java
my.package
class1.java
class2.java
Part of pom.xml (.tld
file is not included into build process by default)
<resource>
<directory>${basedir}</directory>
<targetPath>META-INF</targetPath>
<filtering>true</filtering>
<includes>
<include>customtag.tld</include>
</includes>
</resource>
With that approach there is no long path in pom.xml
, no extra branch created in Netbeans project view but I’m not sure if that location is correct. I have found many links like this one Where do I put the .tld file so that the resulting JAR file built with maven2 is properly packaged? which say that tld files in project code should be put into src/main/resources/META-INF
.
Second Question:
What is the correct/recommended location of the .tld
file inside the Maven project? Please note that I’m asking about project location and not location in created jar file (it has to be META-INF
, I know that).
答案 0 :(得分:1)
我想我已经设法解决了我的问题,以下是答案:
第一个问题: Maven中是否有一些设置默认包含
${basedir}/src/main/resources/META-INF
文件夹内容?
我花了很多时间在互联网上搜索,我可以说没有没有,你需要在pom.xml
中写下那样做的条目。
第二个问题: Maven项目中tld文件的正确/推荐位置是什么?
毕竟,似乎正确或推荐的位置为src/main/resources/META-INF
。
解决我的问题:
我在.tld
level上复制了<resources>
中定义的<build>
文件。
<resources>
<resource>
<directory>${basedir}/src/main/resources/META-INF</directory>
<targetPath>META-INF</targetPath>
<filtering>true</filtering>
<includes>
<include>customtag.tld</include>
</includes>
</resource>
<resources>
我已将该资源移至maven-resources-plugin的<resources>
。目录的路径仍然很长,但这是我可以忍受的,特别是通过这种方法,我可以将.tld
文件保存在src/main/resources/META-INF
中,而Netbeans项目视图中令人烦恼的额外分支现在已经消失。 / p>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources/META-INF</directory>
<targetPath>META-INF</targetPath>
<filtering>true</filtering>
<includes>
<include>customtag.tld</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>