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 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import org.mdonoughe.JGitDescribeTask
  2. apply plugin: 'java'
  3. apply plugin: 'maven-publish'
  4. group = 'com.dmdirc'
  5. sourceSets {
  6. main {
  7. java {
  8. srcDir 'src'
  9. }
  10. }
  11. test {
  12. java {
  13. srcDir 'test'
  14. }
  15. resources {
  16. srcDir 'test-res'
  17. }
  18. }
  19. }
  20. sourceCompatibility = 1.7
  21. targetCompatibility = 1.7
  22. dependencies {
  23. testCompile group: 'junit', name: 'junit', version: '4.+'
  24. testCompile group: 'org.mockito', name: 'mockito-all', version: '1.+'
  25. }
  26. publishing {
  27. publications {
  28. mavenJava(MavenPublication) {
  29. from components.java
  30. }
  31. }
  32. repositories {
  33. maven {
  34. name 'snapshots'
  35. url 'http://nexus.dmdirc.com/nexus/content/repositories/snapshots/'
  36. }
  37. }
  38. }
  39. task wrapper(type: Wrapper) {
  40. gradleVersion = '2.1'
  41. }
  42. task getCredentials << {
  43. def target = file('nexus-teamcity.gradle')
  44. if (!target.exists()) {
  45. new URL('http://www.dmdirc.com/private/nexus-teamcity.gradle').withInputStream{
  46. i -> target.withOutputStream { it << i }
  47. }
  48. }
  49. apply from: 'nexus-teamcity.gradle'
  50. project.publishing.repositories[0].credentials {
  51. username "$nexusUser"
  52. password "$nexusPass"
  53. }
  54. }
  55. task getVersion << {
  56. def jgit = new org.mdonoughe.JGitDescribeTask()
  57. jgit.setDir(new File("$rootDir", '.git'))
  58. project.version = jgit.getDescription() + '-SNAPSHOT'
  59. project.tasks.withType(PublishToMavenRepository) {
  60. publishTask -> publishTask.publication.version = project.version
  61. }
  62. project.tasks.withType(GenerateMavenPom).each {
  63. generateMavenPomTask -> generateMavenPomTask.pom.getProjectIdentity().version = project.version
  64. }
  65. }
  66. task publishSnapshot(dependsOn: ['getCredentials', 'getVersion', 'publishMavenJavaPublicationToSnapshotsRepository']) << {
  67. }
  68. buildscript {
  69. repositories {
  70. mavenCentral()
  71. maven {
  72. url 'http://nexus.dmdirc.com/nexus/content/repositories/thirdparty/'
  73. }
  74. }
  75. dependencies {
  76. classpath group: 'com.github.shanemcc', name: 'jgit-describe', version: '0.5'
  77. classpath group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '2.3.1.+'
  78. }
  79. }