Reputation: 4078
I want to encrypt a password with maven, from within a Java program. Basically, I want to achieve the equivalent of calling mvn --encrypt-password p4ssw0rd
, but without dropping to the command line.
I've looked into Apache Maven Invoker. I've found setters on InvocationRequest
for _some command line options, such as InvocationRequest.setShowVersion(..)
for --show-version
. But I can't find one for --encrypt-password
.
Is there a way to do this, either with Apache Maven Invoker or another way? I do not want to drop to or call a command line directly, since I want to be platform independent.
How do I invoke mvn --encrypt-password p4ssw0rd
from a Java program?
Upvotes: -1
Views: 460
Reputation: 30088
It looks like you can use the plexus-cipher library, which is apparently what Maven uses to do the encryption.
See the code at https://github.com/sonatype/plexus-cipher
The unit tests will probably be enut to get you started.
Upvotes: 2