This repository was archived by the owner on Jul 16, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
196 lines (177 loc) · 5.81 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
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java-library'
id 'maven-publish'
id 'java-library-distribution'
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
id 'com.palantir.git-version' version "0.13.0"
}
// calculate version string from git tag, hash and commit distance
// It treat as release tag when current HEAD has a tag,
// and repository is clean, no modification,and no untracked files,
if (versionDetails().isCleanTag) {
// drop first 'v' from version tag
version = gitVersion().substring(1)
} else {
version = versionDetails().lastTag.substring(1) + '-' + versionDetails().commitDistance + '-' + versionDetails().gitHash + '-SNAPSHOT'
}
def props = project.file("dictzip-cli/src/main/resources/org/dict/zip/Version.properties")
task writeVersionFile {
def folder = props.getParentFile()
if (!folder.exists()) {
folder.mkdirs()
}
props.delete()
props.text = "version=" + project.version
}
jar.dependsOn("writeVersionFile")
// common settings
subprojects {
apply plugin: 'jacoco'
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
checkstyle {
ignoreFailures = true
toolVersion = '6.16.1'
}
version = rootProject.version
group = projectGroup
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains:annotations:23.0.0"
testImplementation 'commons-io:commons-io:2.11.0'
testImplementation "org.junit.jupiter:junit-jupiter:5.8.2"
}
test {
useJUnitPlatform()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
javadoc {
options.locale = 'en_US'
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
}
project(':northside-io') {
apply plugin: 'java-library'
version = rootProject.version
dependencies {
implementation 'commons-io:commons-io:2.11.0'
}
}
project(':dictzip-lib') {
apply plugin: 'java-library'
apply plugin: "signing"
version = rootProject.version
dependencies {
testImplementation project(':northside-io')
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifactId = "dictzip"
pom {
name.set("dictzip")
description.set(projectDesc)
url.set(projectUrl)
licenses {
license {
name.set("GNU General Public License v2.0 w/Classpath exception")
url.set("https://www.gnu.org/software/classpath/license.html")
}
}
scm {
connection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
developerConnection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
url.set(projectUrl)
}
developers {
developer {
id.set("miurahr")
name.set("Hiroshi Miura")
email.set("[email protected]")
}
}
issueManagement {
url.set(projectUrl + "/issues")
}
}
}
}
}
nexusPublishing {
repositories {
sonatype {
stagingProfileId.set("a1cf138b142cd")
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : System.getenv('SONATYPE_USER')
password = project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : System.getenv('SONATYPE_PASS')
}
}
}
signing {
if (project.hasProperty("signingKey")) {
def signingKey = findProperty("signingKey").toString()
def signingPassword = findProperty("signingPassword").toString()
useInMemoryPgpKeys(signingKey, signingPassword)
} else {
useGpgCmd()
}
sign publishing.publications.mavenJava
}
tasks.withType(Sign) {
def hasKey = project.hasProperty("signingKey") || project.hasProperty("signing.gnupg.keyName")
onlyIf { hasKey && versionDetails().isCleanTag }
}
}
project(':dictzip-cli') {
apply plugin: 'application'
mainClassName = 'org.dict.zip.cli.Main'
applicationName = 'dictzip'
version = rootProject.version
dependencies {
implementation project(':dictzip-lib')
implementation 'gnu.getopt:java-getopt:1.0.13'
testImplementation project(':northside-io')
}
task mandoc(type: Copy) {
from "doc/dictzip.1.in"
into 'build/docs'
rename { String fileName ->
fileName.replace('dictzip.1.in', 'dictzip.1')
}
filter(ReplaceTokens, tokens: [copyright: projectYears, version: project.version])
}
distTar {
compression = Compression.GZIP
}
distTar.dependsOn mandoc
distributions {
main {
contents {
from('build/docs/dictzip.1') {
into 'docs/man/man1'
}
from(javadocJar) {
into 'docs'
}
from(sourcesJar) {
into 'source'
}
}
}
}
}