1apply plugin: 'java'
2apply plugin: 'eclipse'
3apply plugin: 'maven'
4apply plugin: 'osgi'
5apply plugin: 'signing'
6
7ext {
8 shortVersion = '0.1'
9 isSnapshot = true
10 gitCommit = getGitCommit()
11 isReleaseVersion = !shortVersion
12 sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
13 signingRequired = isReleaseVersion
14 sonatypeSnapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
15 sonatypeStagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
16 buildDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
17}
18
19group = 'de.measite.minidns'
20description = "A minimal DNS client library with support for A, AAAA, NS and SRV records"
21sourceCompatibility = 1.7
22version = shortVersion
23if (isSnapshot) {
24 version += '-SNAPSHOT'
25}
26
27jar {
28 manifest {
29 instruction 'Implementation-GitRevision:', project.ext.gitCommit
30 }
31}
32
33gradle.taskGraph.whenReady { taskGraph ->
34 if (signingRequired
35 && taskGraph.allTasks.any { it instanceof Sign }) {
36 // Use Java 6's console to read from the console (no good for a CI environment)
37 Console console = System.console()
38 console.printf '\n\nWe have to sign some things in this build.\n\nPlease enter your signing details.\n\n'
39 def password = console.readPassword('GnuPG Private Key Password: ')
40
41 allprojects { ext.'signing.password' = password }
42
43 console.printf '\nThanks.\n\n'
44 }
45}
46
47uploadArchives {
48 repositories {
49 mavenDeployer {
50 if (signingRequired) {
51 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
52 }
53 repository(url: project.sonatypeStagingUrl) {
54 if (sonatypeCredentialsAvailable) {
55 authentication(userName: sonatypeUsername, password: sonatypePassword)
56 }
57 }
58 snapshotRepository(url: project.sonatypeSnapshotUrl) {
59 if (sonatypeCredentialsAvailable) {
60 authentication(userName: sonatypeUsername, password: sonatypePassword)
61 }
62 }
63
64 pom.project {
65 name 'minidns'
66 packaging 'jar'
67 inceptionYear '2014'
68 url 'https://github.com/rtreffer/minidns'
69 description project.description
70
71 issueManagement {
72 system 'GitHub'
73 url 'https://github.com/rtreffer/minidns/issues'
74 }
75
76 distributionManagement {
77 snapshotRepository {
78 id 'minidns.snapshot'
79 url project.sonatypeSnapshotUrl
80 }
81 }
82
83 scm {
84 url 'https://github.com/rtreffer/minidns'
85 connection 'scm:git:https://github.com/rtreffer/minidns.git'
86 developerConnection 'scm:git:https://github.com/rtreffer/minidns.git'
87 }
88
89 licenses {
90 license {
91 name 'The Apache Software License, Version 2.0'
92 url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
93 distribution 'repo'
94 }
95 }
96
97 developers {
98 developer {
99 id 'rtreffer'
100 name 'Rene Treffer'
101 }
102 developer {
103 id 'flow'
104 name 'Florian Schmaus'
105 email 'flow@geekplace.eu'
106 }
107 }
108 }
109 }
110 }
111 signing {
112 required { signingRequired }
113 sign configurations.archives
114 }
115}
116
117def getGitCommit() {
118 def dotGit = new File("$projectDir/.git")
119 if (!dotGit.isDirectory()) return 'non-git build'
120
121 def cmd = 'git describe --all --dirty=+'
122 def proc = cmd.execute()
123 def gitCommit = proc.text.trim()
124 assert !gitCommit.isEmpty()
125 gitCommit
126}