1 import org.apache.tools.ant.filters.ReplaceTokens
6 id 'java-library-distribution'
8 id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
9 id 'com.palantir.git-version' version "0.12.3"
12 // calculate version string from git tag, hash and commit distance
13 // It treat as release tag when current HEAD has a tag,
14 // and repository is clean, no modification,and no untracked files,
15 if (versionDetails().isCleanTag) {
16 // drop first 'v' from version tag
17 version = gitVersion().substring(1)
19 version = versionDetails().lastTag.substring(1) + '-' + versionDetails().commitDistance + '-' + versionDetails().gitHash + '-SNAPSHOT'
24 apply plugin: 'jacoco'
26 apply plugin: 'checkstyle'
28 apply plugin: 'maven-publish'
30 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
32 config = resources.text.fromFile("${rootProject.projectDir}/config/checkstyle/checkstyle.xml")
34 toolVersion = '6.16.1'
36 version = rootProject.version
44 testImplementation 'commons-io:commons-io:2.11.0'
45 testImplementation "org.junit.jupiter:junit-jupiter:5.8.2"
52 sourceCompatibility = JavaVersion.VERSION_1_8
53 targetCompatibility = JavaVersion.VERSION_1_8
59 options.locale = 'en_US'
69 project(':dictzip-lib') {
70 apply plugin: 'java-library'
71 version = rootProject.version
73 repositories.mavenInstaller {
77 description = projectDesc
79 version = project.version
89 connection = "scm:git:${githubUrl}"
90 developerConnection = "scm:git:${githubUrl}"
96 email = developerEmail
105 mavenJava(MavenPublication) {
107 artifactId = "dictzip"
108 groupId = "io.github.dictzip"
111 description.set(projectDesc)
115 name.set("GNU General Public License v2.0 w/Classpath exception")
116 url.set("https://www.gnu.org/software/classpath/license.html")
120 connection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
121 developerConnection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
127 name = "Hiroshi Miura"
128 email = "miurahr@linux.com"
132 url.set(projectUrl + "/issues")
141 stagingProfileId = "a1cf138b142cd"
142 nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
143 snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
144 username = project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : System.getenv('SONATYPE_USER')
145 password = project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : System.getenv('SONATYPE_PASS')
151 def signingKey = findProperty("signingKey")
152 def signingPassword = findProperty("signingPassword")
154 useInMemoryPgpKeys(signingKey, signingPassword)
158 sign publishing.publications.mavenJava
160 tasks.withType(Sign) {
161 def hasKey = project.hasProperty("signingKey") || project.hasProperty("signing.gnupg.keyName")
162 onlyIf { hasKey && versionDetails().isCleanTag }
166 project(':dictzip-cli') {
167 apply plugin: 'application'
168 mainClassName = 'org.dict.zip.cli.Main'
169 applicationName = 'dictzip'
170 version = rootProject.version
172 implementation project(':dictzip-lib')
173 implementation 'gnu.getopt:java-getopt:1.0.13'
175 task mandoc(type: Copy) {
176 from "doc/dictzip.1.in"
178 rename { String fileName ->
179 fileName.replace('dictzip.1.in', 'dictzip.1')
181 filter(ReplaceTokens, tokens: [copyright: projectYears, version: project.version])
185 compression = Compression.GZIP
187 distTar.dependsOn mandoc
193 from('build/docs/dictzip.1') {