/** Imports */
import java.util.List;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
import org.apache.maven.settings.crypto.SettingsDecrypter;
import org.apache.maven.settings.crypto.SettingsDecryptionRequest;
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
Note that I use guava in other parts as well so I did exclude it in
the maven-plugin-api.
/* POM */
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.4</version>
<exclusions>
<exclusion><!-- provided by com.google.guava:guava directly -->
<artifactId>sisu-guava</artifactId>
<groupId>org.sonatype.sisu</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings-builder</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>13.0-rc2</version>
</dependency>
</dependencies>
Regards Mirko
On Mon, Aug 27, 2012 at 4:20 PM, Michael Hüttermann
<[email protected]> wrote:
> Hi Mirko,
> thanks! What are the necessary imports and the POM dependencies for that?
> Thanks.
>
>
> Michael
>
>
>
>> Hello Michael,
>>
>> reading your Agile ALM book right now :-):
>>
>> Here is an example how to get all servers with password decrypted:
>>
>> public class MyMojo extends AbstractMojo {
>>
>> /**
>> * Maven settings.
>> */
>> @Component
>> private Settings settings;
>> /**
>> * The decrypter for passwords.
>> */
>> @Component
>> private SettingsDecrypter settingsDecrypter;
>>
>> /**
>> * Returns the list of servers with decrypted passwords.
>> *
>> * @return list of servers with decrypted passwords.
>> */
>> List<Server> getDecryptedServers() {
>> final SettingsDecryptionRequest settingsDecryptionRequest =
>> new DefaultSettingsDecryptionRequest();
>> settingsDecryptionRequest.setServers(settings.getServers());
>> final SettingsDecryptionResult decrypt =
>> settingsDecrypter.decrypt(settingsDecryptionRequest);
>> return decrypt.getServers();
>> }
>> }
>>
>> Regards Mirko
>> --
>> http://illegalstateexception.blogspot.com/
>> https://github.com/mfriedenhagen/
>> https://bitbucket.org/mfriedenhagen/
>> https://twitter.com/mfriedenhagen
>>
>>
>> On Fri, Aug 24, 2012 at 11:36 AM, Michael Hüttermann
>> <[email protected]> wrote:
>>> Hello,
>>>
>>> how can I (e.g. programmatically, in an own Maven plugin) access the
>>> "server">"password" element of settings.xml, to re-use the value. Is
>>> there
>>> any chance to do so?
>>>
>>>
>>>
>>> Thanks!
>>>
>>> Michael
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]