-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
179 lines (156 loc) · 5.68 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
import org.gradle.plugins.signing.Sign
import javax.swing.*
plugins {
id 'idea'
id 'maven-publish'
id "org.javamodularity.moduleplugin" version "1.7.0"
id "com.github.ethankhall.semantic-versioning" version "1.1.0"
id "com.github.hierynomus.license" version "0.15.0"
id "com.jfrog.bintray" version "1.8.5"
id "net.saliman.properties" version "1.5.1"
}
modularity.mixedJavaRelease 7
project.version.with {
major = awtColorFactoryVersionMajor as int
minor= awtColorFactoryVersionMinor as int
patch = awtColorFactoryVersionPatch as int
if (project.hasProperty('awtColorFactoryVersionLabel')) {
preRelease = awtColorFactoryVersionLabel
}
releaseBuild = Boolean.valueOf(awtColorFactoryReleaseBuild)
}
ext {
awtColorFactoryVersion = project.version as String
awtColorFactoryTag = Boolean.valueOf(awtColorFactoryReleaseBuild) ? "v$ext.awtColorFactoryVersion" : 'master'
moduleName = 'org.beryx.awt.color'
}
def pomConfig = {
url "https://github.com/beryx/awt-color-factory"
developers {
developer {
id "siordache"
name "Serban Iordache"
}
}
scm {
connection "https://github.com/beryx/awt-color-factory.git"
developerConnection "https://github.com/beryx/awt-color-factory.git"
url "https://github.com/beryx/awt-color-factory"
}
}
apply plugin: 'signing'
repositories {
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
apply plugin: 'java-library'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'com.github.hierynomus.license'
group = 'org.beryx'
version = awtColorFactoryVersion
def defaultEncoding = 'UTF-8'
[compileJava, compileTestJava]*.options*.encoding = defaultEncoding
license {
header rootProject.file("license-header.txt")
skipExistingHeaders true
ignoreFailures false
}
signing {
sign configurations.archives
}
signArchives {
onlyIf { gradle.taskGraph.allTasks.findAll {task -> isPublishTask(task)} }
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.2.0'
}
jar {
manifest {
attributes 'Implementation-Title': "awt-color-factory",
'Implementation-Version': awtColorFactoryVersion
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: classes) {
classifier "javadoc"
from javadoc
}
artifacts {
archives(sourcesJar, javadocJar)
}
publishing {
publications {
"awt-color-factory"(MavenPublication) {
from components.java
artifact sourcesJar { classifier "sources" }
artifact javadocJar { classifier "javadoc" }
groupId 'org.beryx'
artifactId project.name
version awtColorFactoryVersion
pom.withXml {
def root = asNode()
root.appendNode('name', "Module $project.name")
root.appendNode('description', "The $project.name artifact")
root.children().last() + pomConfig
// We cannot configure the licenses in pomConfig due to a name conflict with the 'license' extension defined by the com.github.hierynomus.license plugin
def licenseNode = root.appendNode('licenses').appendNode('license')
licenseNode.appendNode('name', 'GNU General Public License, version 2, with the Classpath Exception')
licenseNode.appendNode('url', 'https://openjdk.java.net/legal/gplv2+ce.html')
licenseNode.appendNode('distribution', 'repo')
}
}
}
}
def readPasswordFromConsole(title, prompt) {
JPanel panel = new JPanel()
JLabel label = new JLabel(prompt)
JPasswordField pass = new JPasswordField(24)
panel.add(label)
panel.add(pass)
def options = ["OK", "Cancel"] as Object[]
int option = JOptionPane.showOptionDialog(null, panel, title,
JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, null)
if(option != 0) throw new InvalidUserDataException("Operation cancelled by the user.")
new String(pass.password)
}
def isPublishTask(task) {
task.name.startsWith('publish')
}
gradle.taskGraph.whenReady { taskGraph ->
if (gradle.taskGraph.allTasks.findAll {task -> isPublishTask(task)}) {
if(!project.hasProperty('signingKeyId') || !project.hasProperty('signingSecretKeyRingFile'))
throw new InvalidUserDataException("Please configure your signing credentials in gradle-local.properties.")
def password = readPasswordFromConsole('Please enter your PGP credentials:', 'PGP Private Key Password')
allprojects { ext."signing.keyId" = signingKeyId }
allprojects { ext."signing.secretKeyRingFile" = signingSecretKeyRingFile }
allprojects { ext."signing.password" = password }
}
}
bintray {
user = project.hasProperty('bintrayUser') ? project.getProperty('bintrayUser') : "unknownUser"
key = project.hasProperty('bintrayKey') ? project.getProperty('bintrayKey') : "unknownKey"
publications = ['awt-color-factory']
pkg {
repo = 'maven'
name = 'awt-color-factory'
userOrg = 'beryx'
licenses = ['GPL-2.0+CE']
vcsUrl = 'https://github.com/beryx/awt-color-factory.git'
version {
name = awtColorFactoryVersion
desc = "AWT Color Factory $awtColorFactoryVersion"
released = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSSZZ")
vcsTag = awtColorFactoryVersion
gpg {
sign = true
}
}
}
}