Browse Source

Add support for publishing builds from gradle.

This is getting a bit repetitive :)
pull/3/head
Chris Smith 9 years ago
parent
commit
f3beb732a3
2 changed files with 53 additions and 1 deletions
  1. 1
    0
      .gitignore
  2. 52
    1
      build.gradle

+ 1
- 0
.gitignore View File

11
 /etc/nexus-teamcity.properties
11
 /etc/nexus-teamcity.properties
12
 /.gradle
12
 /.gradle
13
 /*/build
13
 /*/build
14
+/nexus-teamcity.gradle

+ 52
- 1
build.gradle View File

1
 subprojects {
1
 subprojects {
2
-    apply plugin: 'java'
2
+    def jgit = new org.mdonoughe.JGitDescribeTask()
3
+    jgit.dir = new File(projectDir, '../.git')
4
+    jgit.subdir = project.name
5
+    project.version = jgit.getDescription() + '-SNAPSHOT'
3
 
6
 
4
     group = 'com.dmdirc.parser'
7
     group = 'com.dmdirc.parser'
5
 
8
 
9
+    apply plugin: 'maven-publish'
10
+    apply plugin: 'java'
11
+
6
     sourceSets {
12
     sourceSets {
7
         main {
13
         main {
8
             java {
14
             java {
16
         }
22
         }
17
     }
23
     }
18
 
24
 
25
+    publishing {
26
+        publications {
27
+            mavenJava(MavenPublication) {
28
+                artifact jar
29
+            }
30
+        }
31
+        repositories {
32
+            maven {
33
+                name 'snapshots'
34
+                url 'http://nexus.dmdirc.com/nexus/content/repositories/snapshots/'
35
+            }
36
+        }
37
+    }
38
+
19
     sourceCompatibility = 1.7
39
     sourceCompatibility = 1.7
20
     targetCompatibility = 1.7
40
     targetCompatibility = 1.7
21
 
41
 
26
         testCompile group: 'org.mockito', name: 'mockito-all', version: '1.+'
46
         testCompile group: 'org.mockito', name: 'mockito-all', version: '1.+'
27
     }
47
     }
28
 
48
 
49
+    task getCredentials << {
50
+        def target = file('../nexus-teamcity.gradle')
51
+        if (!target.exists()) {
52
+            new URL('http://www.dmdirc.com/private/nexus-teamcity.gradle').withInputStream{
53
+                 i -> target.withOutputStream { it << i }
54
+            }
55
+        }
56
+
57
+        apply from: '../nexus-teamcity.gradle'
58
+        project.publishing.repositories[0].credentials {
59
+            username "$nexusUser"
60
+            password "$nexusPass"
61
+        }
62
+    }
63
+
64
+    task publishSnapshot(dependsOn: ['getCredentials', 'publishMavenJavaPublicationToSnapshotsRepository']) << {
65
+    }
29
 }
66
 }
30
 
67
 
31
 task wrapper(type: Wrapper) {
68
 task wrapper(type: Wrapper) {
43
         println "Couldn't find project $name"
80
         println "Couldn't find project $name"
44
     }
81
     }
45
 }
82
 }
83
+
84
+buildscript {
85
+    repositories {
86
+        mavenCentral()
87
+        maven {
88
+            url 'http://nexus.dmdirc.com/nexus/content/repositories/thirdparty/'
89
+        }
90
+    }
91
+
92
+    dependencies {
93
+        classpath group: 'com.github.shanemcc', name: 'jgit-describe', version: '0.5'
94
+        classpath group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '2.3.1.+'
95
+    }
96
+}

Loading…
Cancel
Save