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
27repositories {
28 mavenLocal()
29 mavenCentral()
30}
31
32jar {
33 manifest {
34 instruction 'Implementation-GitRevision:', project.ext.gitCommit
35 }
36}
37
38gradle.taskGraph.whenReady { taskGraph ->
39 if (signingRequired
40 && taskGraph.allTasks.any { it instanceof Sign }) {
41 // Use Java 6's console to read from the console (no good for a CI environment)
42 Console console = System.console()
43 console.printf '\n\nWe have to sign some things in this build.\n\nPlease enter your signing details.\n\n'
44 def password = console.readPassword('GnuPG Private Key Password: ')
45
46 allprojects { ext.'signing.password' = password }
47
48 console.printf '\nThanks.\n\n'
49 }
50}
51
52uploadArchives {
53 repositories {
54 mavenDeployer {
55 if (signingRequired) {
56 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
57 }
58 repository(url: project.sonatypeStagingUrl) {
59 if (sonatypeCredentialsAvailable) {
60 authentication(userName: sonatypeUsername, password: sonatypePassword)
61 }
62 }
63 snapshotRepository(url: project.sonatypeSnapshotUrl) {
64 if (sonatypeCredentialsAvailable) {
65 authentication(userName: sonatypeUsername, password: sonatypePassword)
66 }
67 }
68
69 pom.project {
70 name 'minidns'
71 packaging 'jar'
72 inceptionYear '2014'
73 url 'https://github.com/rtreffer/minidns'
74 description project.description
75
76 issueManagement {
77 system 'GitHub'
78 url 'https://github.com/rtreffer/minidns/issues'
79 }
80
81 distributionManagement {
82 snapshotRepository {
83 id 'minidns.snapshot'
84 url project.sonatypeSnapshotUrl
85 }
86 }
87
88 scm {
89 url 'https://github.com/rtreffer/minidns'
90 connection 'scm:git:https://github.com/rtreffer/minidns.git'
91 developerConnection 'scm:git:https://github.com/rtreffer/minidns.git'
92 }
93
94 licenses {
95 license {
96 name 'The Apache Software License, Version 2.0'
97 url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
98 distribution 'repo'
99 }
100 }
101
102 developers {
103 developer {
104 id 'rtreffer'
105 name 'Rene Treffer'
106 }
107 developer {
108 id 'flow'
109 name 'Florian Schmaus'
110 email 'flow@geekplace.eu'
111 }
112 }
113 }
114 }
115 }
116 signing {
117 required { signingRequired }
118 sign configurations.archives
119 }
120}
121
122def getGitCommit() {
123 def dotGit = new File("$projectDir/.git")
124 if (!dotGit.isDirectory()) return 'non-git build'
125
126 def cmd = 'git describe --all --dirty=+'
127 def proc = cmd.execute()
128 def gitCommit = proc.text.trim()
129 assert !gitCommit.isEmpty()
130 gitCommit
131}