Преглед изворни кода

Add support for publishing builds from gradle.

This is getting a bit repetitive :)
pull/3/head
Chris Smith пре 9 година
родитељ
комит
f3beb732a3
2 измењених фајлова са 53 додато и 1 уклоњено
  1. 1
    0
      .gitignore
  2. 52
    1
      build.gradle

+ 1
- 0
.gitignore Прегледај датотеку

@@ -11,3 +11,4 @@ build-before-profiler.xml
11 11
 /etc/nexus-teamcity.properties
12 12
 /.gradle
13 13
 /*/build
14
+/nexus-teamcity.gradle

+ 52
- 1
build.gradle Прегледај датотеку

@@ -1,8 +1,14 @@
1 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 7
     group = 'com.dmdirc.parser'
5 8
 
9
+    apply plugin: 'maven-publish'
10
+    apply plugin: 'java'
11
+
6 12
     sourceSets {
7 13
         main {
8 14
             java {
@@ -16,6 +22,20 @@ subprojects {
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 39
     sourceCompatibility = 1.7
20 40
     targetCompatibility = 1.7
21 41
 
@@ -26,6 +46,23 @@ subprojects {
26 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 68
 task wrapper(type: Wrapper) {
@@ -43,3 +80,17 @@ def find(name) {
43 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…
Откажи
Сачувај