Skip to content

Commit

Permalink
Add a basic github extension and github task.
Browse files Browse the repository at this point in the history
Refs #7.
  • Loading branch information
jwir3 committed Oct 26, 2016
1 parent a711653 commit c28072a
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions gruel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
compile 'com.google.code.gson:gson:2.3.1'
compile 'io.reactivex:rxjava-debug:1.0.1'
compile 'net.rcarz:jira-client:0.5'
compile 'org.kohsuke:github-api:1.77'
}

sourceCompatibility=1.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.glasstowerstudios.gruel

import com.glasstowerstudios.gruel.tasks.BumpVersionTask
import com.glasstowerstudios.gruel.extensions.HipChatExtension
import com.glasstowerstudios.gruel.extensions.GithubExtension
import com.glasstowerstudios.gruel.extensions.GruelExtension
import com.glasstowerstudios.gruel.tasks.UninstallTask

Expand All @@ -16,6 +17,7 @@ public class GruelPlugin implements Plugin<Project> {
gruelExtension.setProject(aProject);

aProject.extensions.create("hipchat", HipChatExtension);
def githubExtension = aProject.extensions.create("github", GithubExtension);

aProject.task('bumpVersion', type: BumpVersionTask, description: 'Bumps the version number of the current release.', group: 'Management') << {
}
Expand All @@ -38,6 +40,12 @@ public class GruelPlugin implements Plugin<Project> {
gruelExtension.adjustOutputSettings(aProject);
gruelExtension.adjustVersionNameSettings(aProject);
}

if (aProject.hasProperty('github')) {
if (!githubExtension.isValid()) {
throw new Exception("When using the github extension, you must provide a repository, along with either an authentication token, or a username/password combination");
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.glasstowerstudios.gruel.extensions;

/**
* Plugin extension file. This allows specific parameters to be defined in the
* plugin itself. (Think of it like mini-plugins within the Gruel plugin).
*
* For the Github extension, the repository must always be provided, along with
* either a username/password combination, or an auth token.
*/
class GithubExtension {
String auth_token;
String username;
String password;
String repo;

boolean isValid() {
return repo != null && !repo.isEmpty() && ((auth_token != null && !auth_token.isEmpty()) || (username != null && !username.isEmpty() && password != null && !password.isEmpty()));
}

String getUsername() {
return username;
}

String getPassword() {
return password;
}

String getRepo() {
return repo;
}

String getAuthToken() {
return auth_token;
}

void setAuthToken(String aToken) {
auth_token = aToken;
}

void setUsername(String aUsername) {
username = aUsername;
}

void setPassword(String aPassword) {
password = aPassword;
}

void setRepo(String aRepo) {
repo = aRepo;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.glasstowerstudios.gruel.tasks.github

import com.glasstowerstudios.gruel.tasks.GruelTask
import org.gradle.api.tasks.TaskAction

class GithubTask extends GruelTask {
@TaskAction
def doTask() {
println "Github Username: " + project.github.username;
println "Github Password: " + project.github.password;
println "Github Repo: " + project.github.repo;
}
}
10 changes: 10 additions & 0 deletions test/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ gruel {
commitHash gitSha()
}

github {
username='blah'
password='123abc456'
repo='jwir3/gruel'
}

hipchat {
auth_token = "YOUR_AUTH_TOKEN_HERE"
}

project.task('outputGithubInfo', type: com.glasstowerstudios.gruel.tasks.github.GithubTask) {

}

project.task('notifyHipChat', type: com.glasstowerstudios.gruel.tasks.hipchat.HipChatNotificationTask) {
color = 'yellow'
message = 'A MESSAGE'
Expand Down

0 comments on commit c28072a

Please sign in to comment.