Recently, I was frustrated while trying to package a Java keystore file from my Maven project to a project archive (tar or zip) using assembly.xml. Somehow, when I used the command:
keytool -keystore cacerts -list
on the certificate keystore inside the tar/zip archive, it would just say that the keystore is invalid. After some search, I found that there is a little setting in the pom.xml which instructs maven not to do any filtering tasks on the files you specify when you execute a maven command.
Lets talk a bit about maven resources filtering. Maven resources documentation has a very good explanation of this feature. Basically, when you use filtering=true inside your resources tag, the output file in the target folder will contain dynamic values of fields (if it had any). Like, for example:
Suppose, src/main/resources has a Hello.txt, whose contents are Hello ${name}
If filtering is true, ${name} is going to be replaces with the actual value of the property "name" in the pom.xml, when the file is copied to target folder.
Now, even though this filtering is useful, sometimes, we don't want maven to apply this feature on all files in the directory - for example certificate key stores, which are inherently binary in nature. So how do you tackle this? Simple, just use something like this:
Here, I am manually excluding files on which I don't want to apply filters.
Also, in the assembly.xml, I would like to keep line endings, as they might also corrupt these files.
These simple steps will enable you to package any binary content files using Maven.
Thank you! Safed my day. I did pack the 7za.exe in my zip which was corrupt afterwards.
ReplyDeleteAttractive, post. I just stumbled upon your weblog and wanted to say that I have liked browsing your blog posts. After all, I will surely subscribe to your feed, and I hope you will write again soon! BinaryToday
ReplyDeleteSuperior post, keep up with this exceptional work. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! BinaryToday
ReplyDeleteTitanium Flash Mica - Online Sports Betting, Casino, Slot Machines
ReplyDeleteBetting. titanium knife Online Sports Betting. black oxide vs titanium drill bits Online stilletto titanium hammer Sports Betting, Casino, Slot Machines. The biggest sports bet in titanium granite the world! We offer you the best in titanium strength online betting with
Additionally, online playing presents Koreans a degree of anonymity that is not possible when playing in traditional casinos. This is a crucial factor for a lot of} Koreans, as they don't want to be seen as gamblers by their family and friends. It isn't any secret that online playing has been on the rise latest years|in latest times|lately}, with increasingly individuals throughout the globe turning to the web to place their bets. This trend is especially evident in South Korea, the place the number of individuals participating in online playing actions has been growing steadily. Recently, a new new} regulation – Foreign Exchange Management Act – has been imposed, which points out that online cost on playing websites should be done in Rupees. Nevertheless, most players choose to make use of an electronic wallet, similar to Skrill, 우리카지노 PayPal and Neteller.
ReplyDelete