-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathbuild.gradle
215 lines (186 loc) · 4.88 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/**
* To create the Eclipse project and classpath files:
* ./gradlew cleanEclipse eclipse
*
* To build the PojoBuilder:
* ./gradlew build
*
* To publish a new release of PojoBuilder to Sonatype OSS Maven Repo:
* ./gradlew clean publish
*
* To publish a new release of PojoBuilder to the local maven repo:
* ./gradlew clean publishToMavenLocal
*/
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {}
}
if (!project.hasProperty('ossrhUsername') || !project.hasProperty('ossrhPassword')) {
println 'OSS repository hosting username or password not set'
ext.ossrhUsername = ''
ext.ossrhPassword = ''
}
group = 'net.karneim'
version = '4.3.1'
ext {
isReleaseVersion = !version.endsWith('SNAPSHOT')
buildDate = new Date().format("yyyy-MM-dd HH:mm:ss")
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'jacoco'
java {
java {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation 'com.squareup:javawriter:2.5.0'
testImplementation 'com.google.guava:guava:15.0'
testImplementation 'junit:junit:4.11'
testImplementation 'org.assertj:assertj-core:1.6.1'
}
jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(true)
}
}
eclipse {
classpath {
downloadSources = true
downloadJavadoc = false
}
}
sourceSets {
test {
java {
srcDir 'src/testdata/java'
srcDir 'src/test/java'
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
task annotationsJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('annotations')
from sourceSets.main.output.classesDirs
includeEmptyDirs = false
include '**/GeneratePojoBuilder.class'
include '**/FactoryProperties.class'
include '**/Visibility.class'
include '**/GwtIncompatible.class'
from sourceSets.main.output.resourcesDir
}
tasks.withType(Jar) {
into('META-INF') {
from 'COPYING'
}
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Created-Date': buildDate
)
}
}
task fatJar(type: Jar) {
group = 'build'
description = 'Assembles a jar archive containing the main classes and all dependencies.'
archiveBaseName.set('pojobuilder')
archiveVersion.set(project.version)
archiveClassifier.set('jar-with-dependencies')
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Created-Date': buildDate
)
}
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
with jar
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact fatJar
artifact sourcesJar
artifact javadocJar
artifact annotationsJar
pom {
name.set('PojoBuilder')
description.set('The PojoBuilder Generator is a Java 6 compliant annotation processor that generates a fluent builder class for POJOs (Plain Old Java Object)')
url.set('http://github.com/mkarneim/pojobuilder')
packaging = 'jar'
scm {
url.set('[email protected]:mkarneim/pojobuilder.git')
connection.set('scm:git:[email protected]:mkarneim/pojobuilder.git')
developerConnection.set('scm:git:[email protected]:mkarneim/pojobuilder.git')
tag.set('HEAD')
}
licenses {
license {
name.set('PUBLIC DOMAIN')
url.set('http://github.com/mkarneim/pojobuilder/blob/master/COPYING')
distribution.set('repo')
comments.set('Do-whatever-you-want license')
}
}
developers {
developer {
id.set('mkarneim')
name.set('Michael Karneim')
timezone.set('GMT+1')
}
}
}
}
}
repositories {
maven {
name = "sonatype"
url = isReleaseVersion
? uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
: uri("https://oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = project.ossrhUsername
password = project.ossrhPassword
}
}
}
}
def hasSigningKeys =
project.hasProperty('signing.secretKeyRingFile') &&
project.hasProperty('signing.keyId') &&
project.hasProperty('signing.password')
tasks.withType(Sign) {
onlyIf { isReleaseVersion && hasSigningKeys }
}
signing {
sign publishing.publications.mavenJava
}