Skip to content

Commit

Permalink
Merge pull request #47 from cescoffier/#46
Browse files Browse the repository at this point in the history
Fix issue #46
Using Maven 3.1 API.
  • Loading branch information
cescoffier committed Oct 3, 2013
2 parents 5eada8d + 68e6d4b commit 63d597d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions github-core/pom.xml
Expand Up @@ -125,13 +125,13 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0</version>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0</version>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Expand Up @@ -21,12 +21,6 @@
*/
package com.github.maven.plugins.core;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.List;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
Expand All @@ -36,9 +30,12 @@
import org.apache.maven.settings.Settings;
import org.eclipse.egit.github.core.RepositoryId;
import org.eclipse.egit.github.core.client.GitHubClient;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.repository.Authentication;
import org.sonatype.aether.repository.RemoteRepository;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.List;

/**
* Base GitHub Mojo class to be extended.
Expand Down Expand Up @@ -248,21 +245,24 @@ protected boolean configureServerCredentials(final GitHubClient client,
String serverUsername = null;
String serverPassword = null;

if (session != null) {
RepositorySystemSession systemSession = session
.getRepositorySession();
if (systemSession != null) {
Authentication authInfo = systemSession
.getAuthenticationSelector().getAuthentication(
new RemoteRepository().setId(serverId));
if (authInfo != null) {
serverUsername = authInfo.getUsername();
serverPassword = authInfo.getPassword();
}
}
}
// Maven 3.1.0 - It's now impossible to retrieve the username and password from the remote repository.

// if (session != null) {
// RepositorySystemSession systemSession = session
// .getRepositorySession();
// if (systemSession != null) {
// RemoteRepository.Builder builder = new RemoteRepository.Builder(serverId, "", "");
// Authentication authInfo = systemSession.getAuthenticationSelector().getAuthentication
// (builder.build());
// if (authInfo != null) {
// serverUsername = authInfo.getUsername();
// serverPassword = authInfo.getPassword();
// }
// }
// }

if (StringUtils.isEmpty(serverPassword)) {
// Always true.
// if (StringUtils.isEmpty(serverPassword)) {
Server server = getServer(settings, serverId);
if (server == null)
throw new MojoExecutionException(MessageFormat.format(
Expand All @@ -274,7 +274,7 @@ protected boolean configureServerCredentials(final GitHubClient client,

serverUsername = server.getUsername();
serverPassword = server.getPassword();
}
// }

if (!StringUtils.isEmpty(serverUsername, serverPassword)) {
if (isDebug())
Expand Down
6 changes: 3 additions & 3 deletions github-site-plugin/pom.xml
Expand Up @@ -199,13 +199,13 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0</version>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0</version>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -216,7 +216,7 @@
<dependency>
<groupId>com.github.github</groupId>
<artifactId>github-maven-core</artifactId>
<version>0.6</version>
<version>0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down

0 comments on commit 63d597d

Please sign in to comment.