1 import org.apache.tools.ant.filters.ReplaceTokens
2 import groovy.swing.SwingBuilder
6 id "com.jfrog.bintray" version "1.6"
7 id "com.github.spotbugs" version "1.7.1"
13 apply plugin: 'jacoco'
14 apply plugin: 'checkstyle'
15 apply plugin: 'com.jfrog.bintray'
17 apply plugin: 'maven-publish'
19 sourceCompatibility = JavaVersion.VERSION_1_8
20 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
22 config = resources.text.fromFile("${rootProject.projectDir}/config/checkstyle/checkstyle.xml")
24 toolVersion = '6.16.1'
32 testImplementation 'org.testng:testng:6.9.10'
36 tasks.withType(JavaCompile) {
37 options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
41 options.locale = 'en_US'
44 task sourcesJar(type: Jar, dependsOn: classes) {
45 from sourceSets.main.allSource
48 task javadocJar(type: Jar, dependsOn: javadoc) {
49 from javadoc.destinationDir
59 // required { gradle.taskGraph.hasTask("uploadArchives") || gradle.taskGraph.hasTask("bintrayUpload")}
60 // sign configurations.archives
64 project(':dictzip-lib') {
66 testImplementation 'tokyo.northside:northside-io:0.2.0'
68 version = projectVersion
73 user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
74 key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
75 configurations = ['archives']
80 licenses = ['GPL-2.0+CE']
82 labels = ['java','dictzip']
83 publicDownloadNumbers = true
88 repositories.mavenInstaller {
92 description = projectDesc
94 version = project.version
104 connection = "scm:git:${githubUrl}"
105 developerConnection = "scm:git:${githubUrl}"
111 email = developerEmail
117 // maven publish to local repository.(for test)
119 repositories.mavenDeployer {
121 repository url: "file://$System.env.HOME/.m2/repository"
122 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
126 description = projectDesc
128 version = project.version
133 distribution = 'repo'
138 connection = "scm:git:${githubUrl}"
139 developerConnection = "scm:git:${githubUrl}"
145 email = developerEmail
153 project(':dictzip-cli') {
154 apply plugin: 'application'
155 mainClassName = 'org.dict.zip.cli.Main'
156 applicationName = 'dictzip'
159 implementation project(':dictzip-lib'),
160 'gnu.getopt:java-getopt:1.0.13'
161 testImplementation 'tokyo.northside:northside-io:0.2.0'
163 version = projectVersion
166 user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
167 key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
168 configurations = ['archives']
173 licenses = ['GPL-3.0']
175 labels = ['java','dictzip']
176 publicDownloadNumbers = true
180 task mandoc(type: Copy, overwrite: true) {
181 from "doc/dictzip.1.in"
183 rename { String fileName ->
184 fileName.replace('dictzip.1.in', 'dictzip.1')
186 filter(ReplaceTokens, tokens: [copyright: projectYears, version: projectVersion])
190 compression = Compression.GZIP
192 distTar.dependsOn mandoc
198 from('build/docs/dictzip.1') {
212 // askPassword - guarantee asking only once.
216 String askPassword(prompt) {
217 if (ext.'askPassword' != '') {
218 return ext.'askPassword'
221 if(System.console() == null) {
222 new SwingBuilder().edt {
223 dialog(modal: true, title: 'Enter password', alwaysOnTop: true, resizable: false, locationRelativeTo: null, pack: true, show: true) {
226 def input1 = passwordField()
227 button(defaultButton: true, text: 'OK', actionPerformed: {
228 keyPass = input1.password;
235 System.console().println()
236 keyPass = System.console().readPassword(prompt)
238 if (keyPass.size() <= 0) {
239 throw new InvalidUserDataException("You must enter the passwords to proceed.")
241 ext.'askPassword' = new String(keyPass)
245 gradle.taskGraph.whenReady { taskGraph ->
246 if (taskGraph.allTasks.any { it instanceof Sign }) {
248 ext.'signing.password' = askPassword("Enter password for PGP key ${property('signing.keyId')}: ")