Skip to content

Commit

Permalink
Allow setting the SettingsDecrypter when initializing a Maven artifac…
Browse files Browse the repository at this point in the history
…t resolver
  • Loading branch information
aloubyansky authored and galderz committed Mar 6, 2024
1 parent 14a61cc commit 47d3504
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public BootstrapMavenContext(BootstrapMavenContextConfig<?> config)
this.remoteRepos = config.remoteRepos;
this.remotePluginRepos = config.remotePluginRepos;
this.remoteRepoManager = config.remoteRepoManager;
this.settingsDecrypter = config.settingsDecrypter;
this.cliOptions = config.cliOptions;
this.excludeSisuBeanPackages = config.getExcludeSisuBeanPackages();
this.includeSisuBeanPackages = config.getIncludeSisuBeanPackages();
Expand Down Expand Up @@ -312,7 +313,7 @@ public List<RemoteRepository> getRemotePluginRepositories() throws BootstrapMave
return remotePluginRepos == null ? remotePluginRepos = resolveRemotePluginRepos() : remotePluginRepos;
}

private SettingsDecrypter getSettingsDecrypter() {
public SettingsDecrypter getSettingsDecrypter() {
if (settingsDecrypter == null) {
initRepoSystemAndManager();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.function.Function;

import org.apache.maven.model.Model;
import org.apache.maven.settings.crypto.SettingsDecrypter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.impl.RemoteRepositoryManager;
Expand All @@ -28,6 +29,7 @@ public class BootstrapMavenContextConfig<T extends BootstrapMavenContextConfig<?
protected List<RemoteRepository> remoteRepos;
protected List<RemoteRepository> remotePluginRepos;
protected RemoteRepositoryManager remoteRepoManager;
protected SettingsDecrypter settingsDecrypter;
protected String alternatePomName;
protected File userSettings;
protected boolean artifactTransferLogging = true;
Expand Down Expand Up @@ -191,6 +193,18 @@ public T setRemoteRepositoryManager(RemoteRepositoryManager remoteRepoManager) {
return (T) this;
}

/**
* Settings decryptor
*
* @param settingsDecrypter settings decrypter
* @return
*/
@SuppressWarnings("unchecked")
public T setSettingsDecrypter(SettingsDecrypter settingsDecrypter) {
this.settingsDecrypter = settingsDecrypter;
return (T) this;
}

/**
* The meaning of this option is equivalent to alternative POM in Maven,
* which can be specified with command line argument '-f'.
Expand Down

0 comments on commit 47d3504

Please sign in to comment.