Skip to content

Commit

Permalink
[MGPG-113] SignAndDeployFileMojo results in 401 (#82)
Browse files Browse the repository at this point in the history
The RemoteRepository was "bare", it has to be equipped with AuthenticationSelector to be able to perform authenticated deploys. Also, remove "layout" as since Maven 3.0 there is no other layout than "default".

Also, a bit of tidy up, layout is deprecated in Maven3 and is unused.

---

https://issues.apache.org/jira/browse/MGPG-113
  • Loading branch information
cstamas authored Mar 23, 2024
1 parent 770636b commit 528fab9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ public abstract class AbstractGpgMojo extends AbstractMojo {
@Component
protected MavenSession session;

// === Deprecated stuff

/**
* Switch to improve plugin enforcement of "best practices". If set to {@code false}, plugin retains all the
* backward compatibility regarding getting secrets (but will warn). If set to {@code true}, plugin will fail
Expand All @@ -280,7 +278,7 @@ public abstract class AbstractGpgMojo extends AbstractMojo {
* @since 1.6
*/
@Parameter(defaultValue = "${settings}", readonly = true, required = true)
private Settings settings;
protected Settings settings;

/**
* Maven Security Dispatcher.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ public class SignAndDeployFileMojo extends AbstractGpgMojo {
@Parameter(property = "gpg.ascDirectory")
private File ascDirectory;

/**
* Flag whether Maven is currently in online/offline mode.
*/
@Parameter(defaultValue = "${settings.offline}", readonly = true)
private boolean offline;

/**
* GroupId of the artifact to be deployed. Retrieved from POM file if specified.
*/
Expand Down Expand Up @@ -147,12 +141,6 @@ public class SignAndDeployFileMojo extends AbstractGpgMojo {
@Parameter(property = "repositoryId", defaultValue = "remote-repository", required = true)
private String repositoryId;

/**
* The type of remote repository layout to deploy to. Try <i>legacy</i> for a Maven 1.x-style repository layout.
*/
@Parameter(property = "repositoryLayout", defaultValue = "default")
private String repositoryLayout;

/**
* The bundled API docs for the artifact.
*
Expand Down Expand Up @@ -241,7 +229,7 @@ private void initProperties() throws MojoExecutionException {

@Override
protected void doExecute() throws MojoExecutionException, MojoFailureException {
if (offline) {
if (settings.isOffline()) {
throw new MojoFailureException("Cannot deploy artifacts when Maven is in offline mode");
}

Expand All @@ -253,8 +241,6 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
throw new MojoFailureException(file.getPath() + " not found.");
}

RemoteRepository deploymentRepository = new RemoteRepository.Builder(repositoryId, "default", url).build();

// create artifacts
List<Artifact> artifacts = new ArrayList<>();

Expand Down Expand Up @@ -369,6 +355,8 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
artifacts.addAll(signatures);

// deploy all
RemoteRepository deploymentRepository = repositorySystem.newDeploymentRepository(
session.getRepositorySession(), new RemoteRepository.Builder(repositoryId, "default", url).build());
try {
deploy(deploymentRepository, artifacts);
} catch (DeploymentException e) {
Expand Down

0 comments on commit 528fab9

Please sign in to comment.