OSDN Git Service

Bump Junit5-jupter@5.8.2
[dictzip-java/dictzip-java.git] / build.gradle
1 import org.apache.tools.ant.filters.ReplaceTokens
2
3 plugins {
4     id 'java-library'
5     id 'maven-publish'
6     id 'java-library-distribution'
7     id "signing"
8     id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
9     id 'com.palantir.git-version' version "0.12.3"
10 }
11
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)
18 } else {
19     version = versionDetails().lastTag.substring(1) + '-' + versionDetails().commitDistance + '-' + versionDetails().gitHash + '-SNAPSHOT'
20 }
21
22 // common settings
23 subprojects {
24     apply plugin: 'jacoco'
25     apply plugin: 'java'
26     apply plugin: 'checkstyle'
27     apply plugin: 'maven'
28     apply plugin: 'maven-publish'
29
30     [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
31     checkstyle {
32         config = resources.text.fromFile("${rootProject.projectDir}/config/checkstyle/checkstyle.xml")
33         ignoreFailures = true
34         toolVersion = '6.16.1'
35     }
36     version = rootProject.version
37     group = projectGroup
38
39     repositories {
40         mavenCentral()
41     }
42
43     dependencies {
44         testImplementation 'commons-io:commons-io:2.11.0'
45         testImplementation "org.junit.jupiter:junit-jupiter:5.8.2"
46     }
47     test {
48         useJUnitPlatform()
49     }
50
51     java {
52         sourceCompatibility = JavaVersion.VERSION_1_8
53         targetCompatibility = JavaVersion.VERSION_1_8
54         withSourcesJar()
55         withJavadocJar()
56     }
57
58     javadoc {
59         options.locale = 'en_US'
60     }
61
62     artifacts {
63         archives jar
64         archives sourcesJar
65         archives javadocJar
66     }
67 }
68
69 project(':dictzip-lib') {
70     apply plugin: 'java-library'
71     version = rootProject.version
72     install {
73         repositories.mavenInstaller {
74             pom.project {
75                 name = 'dictzip'
76                 packaging = 'jar'
77                 description = projectDesc
78                 url = projectUrl
79                 version = project.version
80                 licenses {
81                     license {
82                         name = licenseName
83                         url = licenseUrl
84                         distribution = 'repo'
85                     }
86                 }
87                 scm {
88                     url = githubUrl
89                     connection = "scm:git:${githubUrl}"
90                     developerConnection = "scm:git:${githubUrl}"
91                 }
92                 developers {
93                     developer {
94                         id = projectOwner
95                         name = developerName
96                         email = developerEmail
97                     }
98                 }
99             }
100         }
101     }
102
103     publishing {
104         publications {
105             mavenJava(MavenPublication) {
106                 from components.java
107                 artifactId = "dictzip"
108                 groupId = "io.github.dictzip"
109                 pom {
110                     name.set("dictzip")
111                     description.set(projectDesc)
112                     url.set(projectUrl)
113                     licenses {
114                         license {
115                             name.set("GNU General Public License v2.0 w/Classpath exception")
116                             url.set("https://www.gnu.org/software/classpath/license.html")
117                         }
118                     }
119                     scm {
120                         connection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
121                         developerConnection.set("scm:git:git://github.com/dictzip/dictzip-java.git")
122                         url.set(projectUrl)
123                     }
124                     developers {
125                         developer {
126                             id = "miurahr"
127                             name = "Hiroshi Miura"
128                             email = "miurahr@linux.com"
129                         }
130                     }
131                     issueManagement {
132                         url.set(projectUrl + "/issues")
133                     }
134                 }
135             }
136         }
137     }
138     nexusPublishing {
139         repositories {
140             sonatype {
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')
146             }
147         }
148     }
149
150     signing {
151         def signingKey = findProperty("signingKey")
152         def signingPassword = findProperty("signingPassword")
153         if (signingKey) {
154             useInMemoryPgpKeys(signingKey, signingPassword)
155         } else {
156             useGpgCmd()
157         }
158         sign publishing.publications.mavenJava
159     }
160     tasks.withType(Sign) {
161         def hasKey = project.hasProperty("signingKey") || project.hasProperty("signing.gnupg.keyName")
162         onlyIf { hasKey && versionDetails().isCleanTag }
163     }
164 }
165
166 project(':dictzip-cli') {
167     apply plugin: 'application'
168     mainClassName = 'org.dict.zip.cli.Main'
169     applicationName = 'dictzip'
170     version = rootProject.version
171     dependencies {
172         implementation project(':dictzip-lib')
173         implementation 'gnu.getopt:java-getopt:1.0.13'
174     }
175     task mandoc(type: Copy) {
176         from "doc/dictzip.1.in"
177         into 'build/docs'
178         rename { String fileName ->
179             fileName.replace('dictzip.1.in', 'dictzip.1')
180         }
181         filter(ReplaceTokens, tokens: [copyright: projectYears, version: project.version])
182     }
183
184     distTar {
185         compression = Compression.GZIP
186     }
187     distTar.dependsOn mandoc
188
189     distributions {
190         main {
191             baseName = 'dictzip'
192             contents {
193                 from('build/docs/dictzip.1') {
194                     into 'docs/man/man1'
195                 }
196                 from(javadocJar) {
197                     into 'docs'
198                 }
199                 from(sourcesJar) {
200                     into 'source'
201                 }
202             }
203         }
204     }
205 }