-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathbuild.gradle
154 lines (131 loc) · 3.59 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'de.huxhorn.gradle:de.huxhorn.gradle.pgp-plugin:0.0.4'
}
}
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'idea'
repositories {
mavenCentral()
maven { url "http://m2repo.spockframework.org/snapshots" }
}
dependencies {
compile 'com.opencsv:opencsv:4.0'
compileOnly 'org.codehaus.groovy:groovy-all:1.8.8'
testCompile 'org.spockframework:spock-core:1.1-groovy-2.4-rc-2'
testCompile 'cglib:cglib-nodep:2.2'
testCompile 'org.objenesis:objenesis:1.2'
}
version = '1.3'
group = 'com.xlson.groovycsv'
sourceSets {
main {
groovy {
srcDir 'src'
}
}
test {
groovy {
srcDir 'test'
}
}
}
task groovydocJar(type: Jar, dependsOn: groovydoc) {
classifier = 'javadoc'
from 'build/docs/groovydoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives groovydocJar, sourcesJar
}
if(isSetupForDeployToMavenCentral()) {
signing {
sign configurations.archives
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.3.1'
}
task downloadDeps << {
def libDir = file('lib')
ant.delete(dir: libDir)
copy {
from configurations.testRuntime
into libDir
}
}
def isSetupForDeployToMavenCentral() {
def requiredProperties = ['ossrhUsername',
'ossrhPassword',
'signing.keyId',
'signing.password',
'signing.secretKeyRingFile']
for(prop in requiredProperties) {
if(!project.hasProperty(prop)) {
return false
}
}
return true
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
if(isSetupForDeployToMavenCentral()) {
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
}
pom.project {
name 'GroovyCSV'
packaging 'jar'
// optionally artifactId can be defined here
description 'Library for parsing csv in Groovy'
url 'http://github.com/xlson/groovycsv'
inceptionYear '2010'
scm {
connection 'scm:git:[email protected]:xlson/groovycsv.git'
developerConnection 'scm:git:[email protected]:xlson/groovycsv.git'
url 'http://github.com/xlson/groovycsv'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'xlson'
name 'Leonard Gram'
email '[email protected]'
url 'http://xlson.com/'
timezone '+1'
}
}
}
pom.withXml { XmlProvider xmlProvider ->
def xml = xmlProvider.asString()
def pomXml = new XmlParser().parseText(xml.toString())
pomXml.version[0] + { packaging('jar') }
def newXml = new StringWriter()
def printer = new XmlNodePrinter(new PrintWriter(newXml))
printer.preserveWhitespace = true
printer.print(pomXml)
xml.setLength(0)
xml.append(newXml.toString())
}
}
}
}