问题
I'd like to bundle some data files with the Netbeans module i'm working on. I know that i can bundle resources by adding them in a subfolder of /src
so they will be packed within the jar. But i don't want the files to appear within an archive. The files should appear "loose" in a subfolder of the RCP app's directory.
Is there a way to achieve that?
Thanks in advance,
David
回答1:
NetBeans modules are packaged into .nbm files, which are essentially JAR files with some extra info in them
If you want to package something within your .nbm it must be in the /src
, folder unless you're using maven then it will be /resources
, but either way your resource will end up being packaged into the NBM alongside your class files
回答2:
If you are using maven you can configure the plugin to add addition files to the nbm
.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<nbmResources>
<nbmResource>
<directory>release/test</directory> <!-- This is the sourcedir -->
<targetPath>modules/test</targetPath> <!-- This is the path relative to the installed module -->
<includes>
<include>**/*.*</include> <!-- Pattern of files to include -->
</includes>
</nbmResource>
</nbmResources>
</configuration>
</plugin>
This should also give you hints for the ant solution(Which I don't know by heart).
回答3:
I got a solution from the NB Platform email list: I just have to create a directory called release
and copy the additional files to this folder or a subdirectory. After installation of the module, these contents appear in the applications root folder.
来源:https://stackoverflow.com/questions/11173469/how-to-bundle-additional-data-files-with-a-netbeans-module