You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.gradle 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. subprojects {
  2. apply plugin: GitVersion
  3. group = 'com.dmdirc.parser'
  4. apply plugin: 'maven-publish'
  5. apply plugin: 'java'
  6. sourceSets {
  7. main {
  8. java {
  9. srcDir 'src'
  10. }
  11. }
  12. test {
  13. java {
  14. srcDir 'test'
  15. }
  16. }
  17. }
  18. publishing {
  19. publications {
  20. mavenJava(MavenPublication) {
  21. artifact jar
  22. pom.withXml {
  23. def root = asNode()
  24. root.appendNode('inceptionYear', '2006')
  25. root.appendNode('url', 'http://www.dmdirc.com/')
  26. root.appendNode('name', "${group}:${artifactId}")
  27. root.appendNode('description', project.name == 'common'
  28. ? 'Framework for building parsers for connecting to chat networks '
  29. : 'IRC library')
  30. def scm = root.appendNode('scm')
  31. scm.appendNode('url', 'https://github.com/DMDirc/parser')
  32. scm.appendNode('connection', 'scm:https://github.com/DMDirc/Parser.git')
  33. scm.appendNode('developerConnection', 'scm:ssh://git@github.com:DMDirc/Parser.git')
  34. def license = root.appendNode('licenses').appendNode('license')
  35. license.appendNode('name', 'MIT License')
  36. license.appendNode('url', 'http://www.opensource.org/licenses/mit-license.php')
  37. license.appendNode('distribution', 'repo')
  38. def issues = root.appendNode('issueManagement')
  39. issues.appendNode('system', 'GitHub Issues')
  40. issues.appendNode('url', 'https://github.com/DMDirc/Parser/issues')
  41. def developers = root.appendNode('developers')
  42. def chris = developers.appendNode('developer')
  43. chris.appendNode('name', 'Chris Smith')
  44. chris.appendNode('email', 'chris@dmdirc.com')
  45. def greg = developers.appendNode('developer')
  46. greg.appendNode('name', 'Greg Holmes')
  47. greg.appendNode('email', 'greg@dmdirc.com')
  48. def shane = developers.appendNode('developer')
  49. shane.appendNode('name', 'Shane McCormack')
  50. shane.appendNode('email', 'shane@dmdirc.com')
  51. def dependenciesNode = asNode().appendNode('dependencies')
  52. configurations.compile.allDependencies.each {
  53. def dependencyNode = dependenciesNode.appendNode('dependency')
  54. dependencyNode.appendNode('groupId', it.group)
  55. dependencyNode.appendNode('artifactId', it.name)
  56. dependencyNode.appendNode('version', it.version)
  57. }
  58. configurations.testCompile.allDependencies.each {
  59. def dependencyNode = dependenciesNode.appendNode('dependency')
  60. dependencyNode.appendNode('groupId', it.group)
  61. dependencyNode.appendNode('artifactId', it.name)
  62. dependencyNode.appendNode('version', it.version)
  63. dependencyNode.appendNode('scope', 'test')
  64. }
  65. }
  66. }
  67. }
  68. repositories {
  69. maven {
  70. name 'snapshots'
  71. url 'http://nexus.dmdirc.com/nexus/content/repositories/snapshots/'
  72. }
  73. }
  74. }
  75. sourceCompatibility = 1.7
  76. targetCompatibility = 1.7
  77. repositories.mavenCentral()
  78. dependencies {
  79. testCompile group: 'junit', name: 'junit', version: '4.+'
  80. testCompile group: 'org.mockito', name: 'mockito-all', version: '1.+'
  81. }
  82. task getCredentials << {
  83. def target = file('../nexus-teamcity.gradle')
  84. if (!target.exists()) {
  85. new URL('http://www.dmdirc.com/private/nexus-teamcity.gradle').withInputStream{
  86. i -> target.withOutputStream { it << i }
  87. }
  88. }
  89. apply from: '../nexus-teamcity.gradle'
  90. project.publishing.repositories[0].credentials {
  91. username "$nexusUser"
  92. password "$nexusPass"
  93. }
  94. }
  95. task publishSnapshot(dependsOn: ['getCredentials', 'publishMavenJavaPublicationToSnapshotsRepository']) << {
  96. }
  97. task javadocJar(type: Jar) {
  98. classifier = 'javadoc'
  99. from javadoc
  100. }
  101. task sourcesJar(type: Jar) {
  102. classifier = 'sources'
  103. from sourceSets.main.allSource
  104. }
  105. artifacts {
  106. archives javadocJar, sourcesJar
  107. }
  108. }
  109. task wrapper(type: Wrapper) {
  110. gradleVersion = '2.1'
  111. }
  112. def find(name) {
  113. if (allprojects.find { it.name == name }) {
  114. project(name)
  115. } else if (allprojects.find { it.name == 'parser:' + name }) {
  116. project('parser:' + name)
  117. } else if (allprojects.find { it.name == 'modules:parser:' + name }) {
  118. project('modules:parser:' + name)
  119. } else {
  120. println "Couldn't find project $name"
  121. }
  122. }
  123. buildscript {
  124. repositories {
  125. mavenCentral()
  126. maven {
  127. url 'http://nexus.dmdirc.com/nexus/content/repositories/thirdparty/'
  128. }
  129. }
  130. dependencies {
  131. classpath group: 'com.github.shanemcc', name: 'jgit-describe', version: '0.5'
  132. classpath group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '2.3.1.+'
  133. }
  134. }
  135. class GitVersion implements Plugin<Project> {
  136. void apply(Project project) {
  137. def jgit = new org.mdonoughe.JGitDescribeTask()
  138. jgit.dir = getGitDirectory(project)
  139. def subdir = getRelativeSubdir(project, jgit.dir)
  140. if (!subdir.isEmpty()) {
  141. jgit.subdir = subdir
  142. }
  143. def version = jgit.description
  144. project.version = getProjectVersion(version)
  145. }
  146. File getGitDirectory(Project project) {
  147. def target = project.projectDir
  148. def gitDir = new File(target, '.git')
  149. while (!gitDir.exists() && target.parentFile != null) {
  150. target = target.parentFile
  151. gitDir = new File(target, '.git')
  152. }
  153. return gitDir
  154. }
  155. String getRelativeSubdir(Project project, File gitDir) {
  156. def parent = gitDir.parentFile.absolutePath
  157. def target = project.projectDir.absolutePath
  158. return target.substring(parent.length())
  159. }
  160. String getProjectVersion(String gitVersion) {
  161. if (gitVersion.matches('.*-[0-9]+-[0-9a-f]+$')) {
  162. return gitVersion + '-SNAPSHOT'
  163. } else {
  164. return gitVersion
  165. }
  166. }
  167. }