@@ -2,6 +2,33 @@ apply plugin: 'java'
22apply plugin : ' maven'
33apply plugin : ' signing'
44
5+ ext. projectName = ' jdroid-java-github'
6+ description = ' Java Connector for GitHub API'
7+ group = ' com.jdroidframework'
8+ ext. packaging = jar
9+
10+ Boolean isSnapshot = getBooleanProp(' SNAPSHOT' , true )
11+
12+ ext. VERSION_MAJOR = 0
13+ ext. VERSION_MINOR = 9
14+ ext. VERSION_PATCH = 1
15+ ext. VERSION_CLASSIFIER = isSnapshot ? " SNAPSHOT" : null
16+
17+ project. version = " ${ ext.VERSION_MAJOR} .${ ext.VERSION_MINOR} .${ ext.VERSION_PATCH} "
18+ if (ext. VERSION_CLASSIFIER != null && ! ext. VERSION_CLASSIFIER . isEmpty()) {
19+ project. version = project. version + " -" + ext. VERSION_CLASSIFIER
20+ }
21+
22+ buildscript {
23+ repositories {
24+ mavenCentral()
25+ jcenter()
26+ }
27+ dependencies {
28+ classpath ' com.jdroidframework:jdroid-java-github-connector:0.9.0'
29+ }
30+ }
31+
532repositories {
633 mavenCentral()
734}
@@ -10,13 +37,6 @@ dependencies {
1037 compile ' com.google.code.gson:gson:2.2.2'
1138}
1239
13- version = ' 0.9.2-SNAPSHOT'
14- group = ' com.jdroidframework'
15- ext. projectName = ' jdroid-java-github'
16- ext. description = ' Java Connector for GitHub API'
17-
18- ext. packaging = jar
19-
2040task javadocJar (type : Jar ) {
2141 classifier = ' javadoc'
2242 from javadoc
@@ -31,83 +51,170 @@ artifacts {
3151 archives javadocJar, sourcesJar
3252}
3353
34- afterEvaluate {
35- uploadArchives {
36- repositories {
37- mavenDeployer {
54+ Boolean localUpload = getBooleanProp(' LOCAL_UPLOAD' , true )
55+ def localMavenRepo = getProp(' LOCAL_MAVEN_REPO' )
3856
39- beforeDeployment { MavenDeployment deployment ->
40- signing. signPom(deployment)
41- }
57+ if (localUpload && localMavenRepo == null ) {
58+ project. logger. warn(" LOCAL_MAVEN_REPO property is not defined. Skipping uploadArchives configuration" )
59+ } else {
60+ afterEvaluate {
61+ uploadArchives {
62+ repositories {
63+ mavenDeployer {
4264
43- def localUpload = getProp(' LOCAL_UPLOAD' )
44- if (localUpload != null && localUpload == ' true' ) {
45- repository(url : uri(getProp(' LOCAL_MAVEN_REPO' )))
46- } else {
47- repository(url : " https://oss.sonatype.org/service/local/staging/deploy/maven2/" ) {
48- authentication(userName : getRepositoryUsername(), password : getRepositoryPassword())
65+ beforeDeployment { MavenDeployment deployment ->
66+ signing. signPom(deployment)
4967 }
50- snapshotRepository(url : " https://oss.sonatype.org/content/repositories/snapshots/" ) {
51- authentication(userName : getRepositoryUsername(), password : getRepositoryPassword())
68+
69+ if (localUpload) {
70+ repository(url : project. uri(localMavenRepo))
71+ } else {
72+ repository(url : " https://oss.sonatype.org/service/local/staging/deploy/maven2/" ) {
73+ authentication(userName : getRepositoryUsername(), password : getRepositoryPassword())
74+ }
75+ snapshotRepository(url : " https://oss.sonatype.org/content/repositories/snapshots/" ) {
76+ authentication(userName : getRepositoryUsername(), password : getRepositoryPassword())
77+ }
5278 }
53- }
5479
55- pom. project {
56- name project. ext. projectName
57- description project. description
58- packaging project. packaging
59- url ' http://www.jdroidframework.com'
60- inceptionYear ' 2011'
61- organization {
62- name ' Jdroid'
80+ pom. project {
81+ name project. ext. projectName
82+ description project. description
83+ packaging project. packaging
6384 url ' http://www.jdroidframework.com'
64- }
65- licenses {
66- license {
67- name ' The Apache License, Version 2.0'
68- url ' http://www.apache.org/licenses/LICENSE-2.0.txt'
69- distribution ' repo'
85+ inceptionYear ' 2011'
86+ organization {
87+ name ' Jdroid'
88+ url ' http://www.jdroidframework.com'
7089 }
71- }
72- developers {
73- developer {
74- name ' Maxi Rosson'
75- 76- roles {
77- role ' architect'
78- role ' developer'
90+ licenses {
91+ license {
92+ name ' The Apache License, Version 2.0'
93+ url ' http://www.apache.org/licenses/LICENSE-2.0.txt'
94+ distribution ' repo'
7995 }
8096 }
81- }
82- scm {
83- connection
' scm:git:[email protected] :maxirosson/jdroid-java-github-connector.git' 84- developerConnection
' scm:git:[email protected] :maxirosson/jdroid-java-github-connector.git' 85- url
' [email protected] :maxirosson/jdroid-java-github-connector.git' 86- }
87- issueManagement {
88- system ' GitHub'
89- url ' https://github.com/maxirosson/jdroid-java-github-connector/issues'
97+ developers {
98+ developer {
99+ name ' Maxi Rosson'
100+ 101+ roles {
102+ role ' architect'
103+ role ' developer'
104+ }
105+ }
106+ }
107+ scm {
108+ connection
' scm:git:[email protected] :maxirosson/jdroid-java-github.git' 109+ developerConnection
' scm:git:[email protected] :maxirosson/jdroid-java-github.git' 110+ url
' [email protected] :maxirosson/jdroid-java-github.git' 111+ }
112+ issueManagement {
113+ system ' GitHub'
114+ url ' https://github.com/maxirosson/jdroid-java-github/issues'
115+ }
90116 }
91117 }
92118 }
93119 }
94120 }
95-
96121}
97122
98- signing {
99- required { gradle. taskGraph. hasTask(" uploadArchives" ) }
100- sign configurations. archives
123+ if (getBooleanProp(' SIGNING_ENABLED' , true )) {
124+ signing {
125+ required { ! isSnapshot && gradle. taskGraph. hasTask(" uploadArchives" ) }
126+ sign configurations. archives
127+ }
101128}
102129
103130def getRepositoryUsername () {
104- return getProp(' NEXUS_USERNAME ' )
131+ return getProp(' JDROID_NEXUS_USERNAME ' )
105132}
106133
107134def getRepositoryPassword () {
108- getProp(' NEXUS_PASSWORD ' )
135+ return getProp(' JDROID_NEXUS_PASSWORD ' )
109136}
110137
111138public def getProp (String propertyName ) {
112139 return project. hasProperty(propertyName) ? project. ext. get(propertyName) : System . getenv(propertyName)
113140}
141+
142+ public Boolean getBooleanProp (String propertyName , Boolean defaultValue ) {
143+ def value = getProp(propertyName)
144+ if (value == null ) {
145+ return defaultValue
146+ } else if (value == ' true' ) {
147+ return true
148+ } else if (value == ' false' ) {
149+ return false
150+ } else {
151+ throw new GradleException (' Invalid Boolean value: ' + value)
152+ }
153+ }
154+
155+ task printVersion << {
156+ println version
157+ }
158+
159+ import com.jdroid.github.IRepositoryIdProvider ;
160+ import com.jdroid.github.Milestone ;
161+ import com.jdroid.github.Release ;
162+ import com.jdroid.github.RepositoryId ;
163+ import com.jdroid.github.client.GitHubClient ;
164+ import com.jdroid.github.service.MilestoneService ;
165+ import com.jdroid.github.service.ReleaseService ;
166+
167+ task closeGitHubMilestone << {
168+
169+ GitHubClient client = new com.jdroid.github.client.GitHubClient ();
170+ client. setSerializeNulls(false );
171+ client. setOAuth2Token(getProp(' GITHUB_OATH_TOKEN' ));
172+
173+ IRepositoryIdProvider repositoryIdProvider = RepositoryId . create(getProp(' REPOSITORY_OWNER' ), getProp(' REPOSITORY_NAME' ));
174+
175+ closeMilestone(client, repositoryIdProvider, " v${ version} " );
176+ }
177+
178+ public void closeMilestone (GitHubClient client , IRepositoryIdProvider repositoryIdProvider , String milestoneTitle ) throws IOException {
179+
180+ MilestoneService milestoneService = new MilestoneService (client);
181+ for (Milestone each : milestoneService. getMilestones(repositoryIdProvider, " open" )) {
182+ if (each. getTitle(). equals(milestoneTitle)) {
183+
184+ Milestone newMilestone = new Milestone ();
185+ newMilestone. setNumber(each. getNumber());
186+ newMilestone. setTitle(each. getTitle());
187+ newMilestone. setDescription(each. getDescription());
188+ newMilestone. setDueOn(new Date ());
189+ newMilestone. setState(" closed" );
190+ milestoneService. editMilestone(repositoryIdProvider, newMilestone);
191+ break ;
192+ }
193+ }
194+ }
195+
196+ task createGitHubRelease << {
197+ GitHubClient client = new GitHubClient ();
198+ client. setSerializeNulls(false );
199+ client. setOAuth2Token(getProp(' GITHUB_OATH_TOKEN' ));
200+
201+ IRepositoryIdProvider repositoryIdProvider = RepositoryId . create(getProp(' REPOSITORY_OWNER' ), getProp(' REPOSITORY_NAME' ));
202+
203+ def releaseNotesFile = project. file(" ./etc/releaseNotes.txt" )
204+
205+ createRelease(client, repositoryIdProvider, " v${ version} " , releaseNotesFile. getText());
206+ }
207+
208+ public void createRelease (GitHubClient client , IRepositoryIdProvider repositoryIdProvider , String name , String body ) throws IOException {
209+
210+ Release release = new Release ();
211+ release. setBody(body);
212+ release. setDraft(false );
213+ release. setName(name);
214+ release. setTagName(name);
215+ release. setPrerelease(false );
216+ release. setTargetCommitish(" production" );
217+
218+ ReleaseService releaseService = new ReleaseService (client);
219+ releaseService. createRelease(repositoryIdProvider, release);
220+ }
0 commit comments