Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Maven plugin for encryption

Tags:

java

maven-2

ant

I'm translating an Ant script to Maven 2 and I have this problem: the Ant script use a pretty simple java class to encrypt files this way:

<target name="encrypt">
    <java classname="DESEncrypter">
        <classpath>
            <pathelement path="...classpath for this thing..." />
        </classpath>
        <arg line="fileToEncrypt.properties fileEncrypted.properties" />
    </java>
</target>

This DESEncrypter is a compiled class which source doesn't belong to the project I am converting but is used similarly in other projects. Probably I have to create a maven plugin for this to reuse, but I don't want to do it now. My question is: in which directory do i put the DESEncrypter class and how do i invoke it? Using the exec:java plugin, may be? I don't think the encrypter belong to src, test or resources directories.

Obviously, I don't want to include the encrypter class in the final product, just the encrypted files.

like image 327
Ither Avatar asked Dec 21 '25 14:12

Ither


1 Answers

My question is: in which directory do i put the DESEncrypter class and how do i invoke it? Using the exec:java plugin, may be? I don't think the encrypter belong to src, test or resources directories.

A very straightforward solution would be to use the Maven AntRun Plugin. Regarding the location of your encrypter, you could either:

  • put it in a separate module that you could declare as dependency OF the plugin (see this example)
  • keep it in the current module, in the source tree, and configure the Maven JAR Plugin to exclude it using excludes.
like image 170
Pascal Thivent Avatar answered Dec 23 '25 03:12

Pascal Thivent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!