Skip to content

Commit 528fab9

Browse files
authored
[MGPG-113] SignAndDeployFileMojo results in 401 (#82)
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
1 parent 770636b commit 528fab9

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

src/main/java/org/apache/maven/plugins/gpg/AbstractGpgMojo.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ public abstract class AbstractGpgMojo extends AbstractMojo {
258258
@Component
259259
protected MavenSession session;
260260

261-
// === Deprecated stuff
262-
263261
/**
264262
* Switch to improve plugin enforcement of "best practices". If set to {@code false}, plugin retains all the
265263
* backward compatibility regarding getting secrets (but will warn). If set to {@code true}, plugin will fail
@@ -280,7 +278,7 @@ public abstract class AbstractGpgMojo extends AbstractMojo {
280278
* @since 1.6
281279
*/
282280
@Parameter(defaultValue = "${settings}", readonly = true, required = true)
283-
private Settings settings;
281+
protected Settings settings;
284282

285283
/**
286284
* Maven Security Dispatcher.

src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java

+3-15
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ public class SignAndDeployFileMojo extends AbstractGpgMojo {
7272
@Parameter(property = "gpg.ascDirectory")
7373
private File ascDirectory;
7474

75-
/**
76-
* Flag whether Maven is currently in online/offline mode.
77-
*/
78-
@Parameter(defaultValue = "${settings.offline}", readonly = true)
79-
private boolean offline;
80-
8175
/**
8276
* GroupId of the artifact to be deployed. Retrieved from POM file if specified.
8377
*/
@@ -147,12 +141,6 @@ public class SignAndDeployFileMojo extends AbstractGpgMojo {
147141
@Parameter(property = "repositoryId", defaultValue = "remote-repository", required = true)
148142
private String repositoryId;
149143

150-
/**
151-
* The type of remote repository layout to deploy to. Try <i>legacy</i> for a Maven 1.x-style repository layout.
152-
*/
153-
@Parameter(property = "repositoryLayout", defaultValue = "default")
154-
private String repositoryLayout;
155-
156144
/**
157145
* The bundled API docs for the artifact.
158146
*
@@ -241,7 +229,7 @@ private void initProperties() throws MojoExecutionException {
241229

242230
@Override
243231
protected void doExecute() throws MojoExecutionException, MojoFailureException {
244-
if (offline) {
232+
if (settings.isOffline()) {
245233
throw new MojoFailureException("Cannot deploy artifacts when Maven is in offline mode");
246234
}
247235

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

256-
RemoteRepository deploymentRepository = new RemoteRepository.Builder(repositoryId, "default", url).build();
257-
258244
// create artifacts
259245
List<Artifact> artifacts = new ArrayList<>();
260246

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

371357
// deploy all
358+
RemoteRepository deploymentRepository = repositorySystem.newDeploymentRepository(
359+
session.getRepositorySession(), new RemoteRepository.Builder(repositoryId, "default", url).build());
372360
try {
373361
deploy(deploymentRepository, artifacts);
374362
} catch (DeploymentException e) {

0 commit comments

Comments
 (0)