|
@@ -1,8 +1,7 @@
|
1
|
1
|
subprojects {
|
2
|
|
- apply plugin: GitVersion
|
3
|
|
-
|
4
|
2
|
group = 'com.dmdirc.parser'
|
5
|
3
|
|
|
4
|
+ apply plugin: 'com.dmdirc.git-version'
|
6
|
5
|
apply plugin: 'maven-publish'
|
7
|
6
|
apply plugin: 'java'
|
8
|
7
|
|
|
@@ -126,53 +125,10 @@ def find(name) {
|
126
|
125
|
buildscript {
|
127
|
126
|
repositories {
|
128
|
127
|
mavenCentral()
|
129
|
|
- maven {
|
130
|
|
- url 'http://artifactory.dmdirc.com/artifactory/repo'
|
131
|
|
- }
|
|
128
|
+ maven { url 'https://dl.bintray.com/dmdirc/releases/' }
|
132
|
129
|
}
|
133
|
130
|
|
134
|
131
|
dependencies {
|
135
|
|
- classpath group: 'com.github.shanemcc', name: 'jgit-describe', version: '0.5'
|
136
|
|
- classpath group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '2.3.1.+'
|
|
132
|
+ classpath group: 'com.dmdirc', name: 'git-version', version: '1.0'
|
137
|
133
|
}
|
138
|
134
|
}
|
139
|
|
-
|
140
|
|
-class GitVersion implements Plugin<Project> {
|
141
|
|
- void apply(Project project) {
|
142
|
|
- def jgit = new org.mdonoughe.JGitDescribeTask()
|
143
|
|
- jgit.dir = getGitDirectory(project)
|
144
|
|
-
|
145
|
|
- def subdir = getRelativeSubdir(project, jgit.dir)
|
146
|
|
- if (!subdir.isEmpty()) {
|
147
|
|
- jgit.subdir = subdir
|
148
|
|
- }
|
149
|
|
-
|
150
|
|
- def version = jgit.description
|
151
|
|
- project.version = getProjectVersion(version)
|
152
|
|
- }
|
153
|
|
-
|
154
|
|
- File getGitDirectory(Project project) {
|
155
|
|
- def target = project.projectDir
|
156
|
|
- def gitDir = new File(target, '.git')
|
157
|
|
- while (!gitDir.exists() && target.parentFile != null) {
|
158
|
|
- target = target.parentFile
|
159
|
|
- gitDir = new File(target, '.git')
|
160
|
|
- }
|
161
|
|
- return gitDir
|
162
|
|
- }
|
163
|
|
-
|
164
|
|
- String getRelativeSubdir(Project project, File gitDir) {
|
165
|
|
- def parent = gitDir.parentFile.absolutePath
|
166
|
|
- def target = project.projectDir.absolutePath
|
167
|
|
- return target.substring(parent.length())
|
168
|
|
- }
|
169
|
|
-
|
170
|
|
- String getProjectVersion(String gitVersion) {
|
171
|
|
- if (gitVersion.matches('.*-[0-9]+-[0-9a-f]+$')) {
|
172
|
|
- return gitVersion + '-SNAPSHOT'
|
173
|
|
- } else {
|
174
|
|
- return gitVersion
|
175
|
|
- }
|
176
|
|
- }
|
177
|
|
-
|
178
|
|
-}
|