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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. def jgit = new org.mdonoughe.JGitDescribeTask()
  2. jgit.dir = new File(projectDir, '.git')
  3. project.version = jgit.getDescription() + '-SNAPSHOT'
  4. group = 'com.dmdirc'
  5. apply plugin: 'maven-publish'
  6. apply plugin: 'java'
  7. apply plugin: 'findbugs'
  8. apply plugin: 'pmd'
  9. configurations {
  10. bundle
  11. plugin {
  12. transitive = false
  13. }
  14. compile {
  15. extendsFrom bundle
  16. }
  17. }
  18. configurations.all {
  19. resolutionStrategy.cacheDynamicVersionsFor 2, 'minutes'
  20. resolutionStrategy.cacheChangingModulesFor 2, 'minutes'
  21. }
  22. dependencies {
  23. compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.0'
  24. compile group: 'com.squareup.dagger', name: 'dagger-compiler', version: '1.2.1'
  25. compile group: 'com.google.auto.value', name: 'auto-value', version: '1.0-rc4'
  26. bundle group: 'com.squareup.dagger', name: 'dagger', version: '1.2.1'
  27. bundle group: 'com.esotericsoftware.yamlbeans', name: 'yamlbeans', version: '1.08'
  28. bundle group: 'com.brsanthu', name: 'migbase64', version: '2.2'
  29. bundle group: 'net.kencochrane.raven', name: 'raven', version: '5.0.1'
  30. bundle group: 'com.google.guava', name:'guava', version: '18.0'
  31. bundle group: 'net.engio', name: 'mbassador', version: '1.2.0'
  32. bundle group: 'com.dmdirc', name: 'util', version: '+', changing: true
  33. bundle group: 'com.dmdirc.parser', name: 'common', version: '+', changing: true
  34. plugin group: 'com.dmdirc', name: 'ui_swing', version: '+', changing: true
  35. plugin group: 'com.dmdirc', name: 'parser_irc', version: '+', changing: true
  36. plugin group: 'com.dmdirc', name: 'tabcompletion_bash', version: '+', changing: true
  37. plugin group: 'com.dmdirc', name: 'tabcompletion_mirc', version: '+', changing: true
  38. testCompile group: 'junit', name: 'junit', version: '4.12'
  39. testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.17'
  40. testCompile group: 'com.google.jimfs', name: 'jimfs', version: '1.0'
  41. pmd group: 'net.sourceforge.pmd', name: 'pmd-core', version: '5.2.3'
  42. pmd group: 'net.sourceforge.pmd', name: 'pmd-java', version: '5.2.3'
  43. }
  44. publishing {
  45. publications {
  46. mavenJava(MavenPublication) {
  47. groupId 'com.dmdirc'
  48. artifactId 'client'
  49. artifact jar
  50. }
  51. }
  52. repositories {
  53. maven {
  54. name 'snapshots'
  55. url 'http://artifactory.dmdirc.com/artifactory/repo'
  56. }
  57. }
  58. }
  59. sourceSets {
  60. main {
  61. java.srcDirs = ['src']
  62. resources.srcDirs = ['res']
  63. }
  64. test {
  65. java.srcDirs = ['test']
  66. resources.srcDirs = ['test-res']
  67. }
  68. }
  69. sourceCompatibility = 1.8
  70. targetCompatibility = 1.8
  71. repositories {
  72. mavenCentral()
  73. maven {
  74. url 'http://artifactory.dmdirc.com/artifactory/repo'
  75. }
  76. }
  77. pmd {
  78. ruleSets = []
  79. ruleSetFiles = files("$rootDir/etc/pmd/full.xml")
  80. toolVersion = '5.2.3'
  81. ignoreFailures = true
  82. }
  83. tasks.withType(FindBugs) {
  84. reports {
  85. html.enabled = true
  86. xml.enabled = false
  87. }
  88. }
  89. findbugs {
  90. reportLevel = 'low'
  91. effort = 'max'
  92. ignoreFailures = true
  93. }
  94. task getCredentials << {
  95. def target = file('nexus-teamcity.gradle')
  96. if (!target.exists()) {
  97. new URL('http://www.dmdirc.com/private/nexus-teamcity.gradle').withInputStream{
  98. i -> target.withOutputStream { it << i }
  99. }
  100. }
  101. apply from: 'nexus-teamcity.gradle'
  102. project.publishing.repositories[0].credentials {
  103. username "$nexusUser"
  104. password "$nexusPass"
  105. }
  106. }
  107. task publishSnapshot(dependsOn: ['getCredentials', 'publishMavenJavaPublicationToSnapshotsRepository']) << {
  108. }
  109. task createVersionConfig {
  110. inputs.dir 'src'
  111. inputs.dir 'res'
  112. outputs.file new File(buildDir, 'version.config')
  113. dependsOn classes
  114. doLast {
  115. def targetFile = new File(buildDir, 'version.config')
  116. targetFile.text = ''
  117. targetFile << "keysections:\n identity\n version\n updater\n bundledplugins_versions\n\n"
  118. targetFile << "identity:\n name=DMDirc version information\n globaldefault=true\n order=95000\n\n"
  119. targetFile << "version:\n version=${version}\n\n"
  120. targetFile << "updater:\n channel=${updaterChannel}\n\n"
  121. targetFile << "buildenv:\n"
  122. def compileConfiguration = project.configurations.getByName("compile")
  123. def resolvedConfiguration = compileConfiguration.resolvedConfiguration
  124. def resolvedArtifacts = resolvedConfiguration.resolvedArtifacts
  125. resolvedArtifacts.each { dp ->
  126. def version = dp.moduleVersion.id
  127. targetFile << " " + version.group + " " + version.name + " " + version.version + "\n"
  128. }
  129. }
  130. }
  131. task createFatVersionConfig {
  132. inputs.file new File(buildDir, 'version.config')
  133. outputs.file new File(buildDir, 'fat.version.config')
  134. dependsOn createVersionConfig
  135. doLast {
  136. def sourceFile = new File(buildDir, 'version.config')
  137. def targetFile = new File(buildDir, 'fat.version.config')
  138. java.nio.file.Files.copy(sourceFile.toPath(), targetFile.toPath(),
  139. java.nio.file.StandardCopyOption.REPLACE_EXISTING)
  140. targetFile << "\nbundledplugins_versions:\n"
  141. configurations.plugin.each { p ->
  142. targetFile << " " + p.name.replaceFirst('-', '=').replaceAll('.jar$', '\n');
  143. }
  144. }
  145. }
  146. test.dependsOn createVersionConfig
  147. jar {
  148. outputs.file "dist/DMDirc.jar"
  149. dependsOn createVersionConfig
  150. exclude 'com/dmdirc/version.config'
  151. from("$buildDir/version.config") {
  152. into 'com/dmdirc/'
  153. }
  154. from { configurations.bundle.collect { it.isDirectory() ? it : zipTree(it) } } {
  155. exclude 'META-INF/**'
  156. }
  157. manifest {
  158. attributes 'Main-Class': 'com.dmdirc.Main'
  159. }
  160. doLast {
  161. copy {
  162. from jar.archivePath
  163. into "dist/"
  164. rename ".*", "DMDirc.jar"
  165. }
  166. }
  167. }
  168. task('fatjar', type: Jar) {
  169. dependsOn createFatVersionConfig
  170. baseName = 'fat-client'
  171. from("$buildDir/fat.version.config") {
  172. into 'com/dmdirc'
  173. rename 'fat.version.config', 'version.config'
  174. }
  175. into('plugins') {
  176. from configurations.plugin
  177. rename '(.*?)-.*(\\.jar)', '$1$2'
  178. }
  179. with jar {
  180. exclude 'com/dmdirc/version.config'
  181. }
  182. manifest {
  183. attributes 'Main-Class': 'com.dmdirc.Main'
  184. }
  185. }
  186. buildscript {
  187. repositories {
  188. mavenCentral()
  189. maven {
  190. url 'http://artifactory.dmdirc.com/artifactory/repo'
  191. }
  192. }
  193. dependencies {
  194. classpath group: 'com.github.shanemcc', name: 'jgit-describe', version: '0.5'
  195. classpath group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '2.3.1.+'
  196. }
  197. }
  198. task wrapper(type: Wrapper) {
  199. gradleVersion = '2.2.1'
  200. }