-1

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?


SQB
  • 3,926
  • 2
  • 28
  • 49
  • @DamCx, no I want the equivalent of that. I want the same result. I've edited my question to reflect that better. – SQB May 23 '18 at 10:05

1 Answers1

2

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.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67