Skip to content

Instantly share code, notes, and snippets.

@sebersole
Created October 11, 2010 22:49
Show Gist options
  • Save sebersole/621368 to your computer and use it in GitHub Desktop.
Save sebersole/621368 to your computer and use it in GitHub Desktop.
public class UploadManager implements Plugin<Project> {
@Override
public void apply(Project project) {
final Authenticator authenticator = project.getTasks().add( "nexusAuthHandler", Authenticator.class );
project.getTasks().allTasks(
new Action<Task>() {
@Override
public void execute(Task task) {
if ( Upload.class.isInstance( task ) ) {
final Upload uploadTask = (Upload) task;
RemoteRepository repository = uploadTask.getRepositories().mavenDeployer().getRepository();
if ( repository != null ) {
authenticator.addRepository( repository );
uploadTask.getDependsOn().add( authenticator );
}
repository = uploadTask.getRepositories().mavenDeployer().getSnapshotRepository();
if ( repository != null ) {
authenticator.addRepository( repository );
uploadTask.getDependsOn().add( authenticator );
}
}
}
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment