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'
27 apply plugin: 'maven-publish'
29 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
31 config = resources.text.fromFile("${rootProject.projectDir}/config/checkstyle/checkstyle.xml")
33 toolVersion = '6.16.1'
35 version = rootProject.version
43 implementation "org.jetbrains:annotations:23.0.0"
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
74 mavenJava(MavenPublication) {
76 artifactId = "dictzip"
77 groupId = "io.github.dictzip"
80 description.set(projectDesc)
84 name.set("GNU General Public License v2.0 w/Classpath exception")
85 url.set("https://www.gnu.org/software/classpath/license.html")
89 connection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
90 developerConnection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
96 name = "Hiroshi Miura"
97 email = "miurahr@linux.com"
101 url.set(projectUrl + "/issues")
110 stagingProfileId = "a1cf138b142cd"
111 nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
112 snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
113 username = project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : System.getenv('SONATYPE_USER')
114 password = project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : System.getenv('SONATYPE_PASS')
120 def signingKey = findProperty("signingKey")
121 def signingPassword = findProperty("signingPassword")
123 useInMemoryPgpKeys(signingKey, signingPassword)
127 sign publishing.publications.mavenJava
129 tasks.withType(Sign) {
130 def hasKey = project.hasProperty("signingKey") || project.hasProperty("signing.gnupg.keyName")
131 onlyIf { hasKey && versionDetails().isCleanTag }
135 project(':dictzip-cli') {
136 apply plugin: 'application'
137 mainClassName = 'org.dict.zip.cli.Main'
138 applicationName = 'dictzip'
139 version = rootProject.version
141 implementation project(':dictzip-lib')
142 implementation 'gnu.getopt:java-getopt:1.0.13'
144 task mandoc(type: Copy) {
145 from "doc/dictzip.1.in"
147 rename { String fileName ->
148 fileName.replace('dictzip.1.in', 'dictzip.1')
150 filter(ReplaceTokens, tokens: [copyright: projectYears, version: project.version])
154 compression = Compression.GZIP
156 distTar.dependsOn mandoc
161 from('build/docs/dictzip.1') {