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'
22 def props = project.file("dictzip-cli/src/main/resources/org/dict/zip/Version.properties")
23 task writeVersionFile {
24 def folder = props.getParentFile()
25 if (!folder.exists()) {
29 props.text = "version=" + project.version
32 jar.dependsOn("writeVersionFile")
36 apply plugin: 'jacoco'
38 apply plugin: 'checkstyle'
39 apply plugin: 'maven-publish'
41 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
43 config = resources.text.fromFile("${rootProject.projectDir}/config/checkstyle/checkstyle.xml")
45 toolVersion = '6.16.1'
47 version = rootProject.version
55 implementation "org.jetbrains:annotations:23.0.0"
56 testImplementation 'commons-io:commons-io:2.11.0'
57 testImplementation "org.junit.jupiter:junit-jupiter:5.8.2"
64 sourceCompatibility = JavaVersion.VERSION_1_8
65 targetCompatibility = JavaVersion.VERSION_1_8
71 options.locale = 'en_US'
81 project(':northside-io') {
82 apply plugin: 'java-library'
83 version = rootProject.version
85 implementation 'commons-io:commons-io:2.11.0'
89 project(':dictzip-lib') {
90 apply plugin: 'java-library'
91 version = rootProject.version
94 testImplementation project(':northside-io')
99 mavenJava(MavenPublication) {
101 artifactId = "dictzip"
102 groupId = "io.github.dictzip"
105 description.set(projectDesc)
109 name.set("GNU General Public License v2.0 w/Classpath exception")
110 url.set("https://www.gnu.org/software/classpath/license.html")
114 connection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
115 developerConnection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
121 name = "Hiroshi Miura"
122 email = "miurahr@linux.com"
126 url.set(projectUrl + "/issues")
135 stagingProfileId = "a1cf138b142cd"
136 nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
137 snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
138 username = project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : System.getenv('SONATYPE_USER')
139 password = project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : System.getenv('SONATYPE_PASS')
145 def signingKey = findProperty("signingKey")
146 def signingPassword = findProperty("signingPassword")
148 useInMemoryPgpKeys(signingKey, signingPassword)
152 sign publishing.publications.mavenJava
154 tasks.withType(Sign) {
155 def hasKey = project.hasProperty("signingKey") || project.hasProperty("signing.gnupg.keyName")
156 onlyIf { hasKey && versionDetails().isCleanTag }
160 project(':dictzip-cli') {
161 apply plugin: 'application'
162 mainClassName = 'org.dict.zip.cli.Main'
163 applicationName = 'dictzip'
164 version = rootProject.version
166 implementation project(':dictzip-lib')
167 implementation 'gnu.getopt:java-getopt:1.0.13'
168 testImplementation project(':northside-io')
170 task mandoc(type: Copy) {
171 from "doc/dictzip.1.in"
173 rename { String fileName ->
174 fileName.replace('dictzip.1.in', 'dictzip.1')
176 filter(ReplaceTokens, tokens: [copyright: projectYears, version: project.version])
180 compression = Compression.GZIP
182 distTar.dependsOn mandoc
187 from('build/docs/dictzip.1') {